Code Monkey home page Code Monkey logo

mjml-tcpserver's Introduction

MJML TCP-Server

A MJML Server over TCP protocol.

Mainly created for django-mjml.


Using directly

You can run the server just running the file with arguments like:

$ node tcpserver.js --host=0.0.0.0 --port=28101 --mjml.minify=true --mjml.validationLevel=strict

Using Docker

Build the image:

$ docker build -t mjml-tcpserver .

You can specify build arguments:

$ docker build -t mjml-tcpserver \
  --build-arg MJML_VERSION=4.13.0 \
  --build-arg EXPOSE=28101 \
  --no-cache .

Look at the Dockerfile to see the default values of arguments.

Then run a docker container:

$ docker run -d --rm -p 28101:28101 mjml-tcpserver

You can set host and port of the server using env vars:

$ docker run -d --rm -p 28105:28105 -e HOST=127.0.0.1 -e PORT=28105 mjml-tcpserver

To set mjml options pass arguments as cmd using mjml. prefix:

$ docker run -d --rm -p 28101:28101 mjml-tcpserver --mjml.minify=true --mjml.validationLevel=strict

All MJML arguments are listed here.

Stop the server on touch a file

If you wish the server to be stopped when a file is touched, use --touchstop=/tmp/mjmltcpserver.stop.

Be sure the file exists. In case with Docker you can mount that file using a volume.

Daemonize the server using supervisor

Example of configuration file:

/etc/supervisor/conf.d/mjmltcpserver.conf

[program:mjmltcpserver]
user=user
environment=NODE_PATH=/home/user/node_modules
command=node
    /home/user/mjml-tcpserver/tcpserver.js
    --port=28101 --host=127.0.0.1 --touchstop=/tmp/mjmltcpserver.stop --mjml.minify=true --mjml.validationLevel=strict
stdout_logfile=/var/log/supervisor/mjmltcpserver.log
autostart=true
autorestart=true
redirect_stderr=true
stopwaitsecs=10
stopsignal=INT

Docker compose

Example:

services:
  mjml-1:
    image: liminspace/mjml-tcpserver:1
    restart: always
    ports:
      - "28101:28101"

  mjml-2:
    image: liminspace/mjml-tcpserver:1
    restart: always
    environment:
      HOST: "0.0.0.0"
      PORT: "28102"
    expose:
      - "28102"
    ports:
      - "28102:28102"
    command: ["--mjml.minify=true", "--mjml.validationLevel=strict"]

  mjml-3:
    build:
      context: .
      args:
        - MJML_VERSION=4.13.0
        - EXPOSE=28103
    restart: always
    ports:
      - "28103:28103"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.