emqx.service 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. [Unit]
  2. Description=emqx daemon
  3. After=network.target
  4. [Service]
  5. User=emqx
  6. Group=emqx
  7. # The ExecStart= is foreground, so 'simple' here
  8. Type=simple
  9. Environment=HOME=/var/lib/emqx
  10. # log to file by default (if no log handler config)
  11. Environment=EMQX_DEFAULT_LOG_HANDLER=file
  12. # Start 'foreground' but not 'start' (daemon) mode.
  13. # Because systemd monitor/restarts 'simple' services
  14. ExecStart=/bin/bash /usr/bin/emqx foreground
  15. # Give EMQX enough file descriptors
  16. LimitNOFILE=1048576
  17. # ExecStop is commented out so systemd will send a SIGTERM when 'systemctl stop'.
  18. # SIGTERM is handled by EMQX and it then performs a graceful shutdown
  19. # emqx stop will ping node, always return 0 to make sure next command will be executed
  20. ExecStop=/bin/bash -c '/usr/bin/emqx stop; exit 0'
  21. # If the process is still running, force kill it
  22. ExecStop=/bin/bash -c 'if [ ps -p $MAINPID >/dev/null 2>&1 ]; then kill -15 $MAINPID; fi'
  23. # Wait long enough before force kill for graceful shutdown
  24. TimeoutStopSec=120s
  25. Restart=on-failure
  26. # Do not restart immediately so the peer nodes in the cluster have
  27. # enough time to handle the 'DOWN' events of this node
  28. RestartSec=120s
  29. [Install]
  30. WantedBy=multi-user.target