S
S
Stepgor2019-06-20 13:07:58
Node.js
Stepgor, 2019-06-20 13:07:58

How to make a daemon that starts and restarts the server?

I upload the project to the host for the first time, everything works, but I need to make a daemon that turns on and restarts the server, the directory with the site /home/test/node, you need to include main.js, I created the appserver.service file in /etc/systemd/system , I tried many different options, I think that the problem is in ExecStart, how to write this path correctly? Ubuntu 16.04

[Unit]
Description=Node.js Example Server
#Requires=After=mysql.service       # Requires the mysql service to run first

[Service]
ExecStart=/bin/bash -c '$$(which node) home/test/node/main.js
# Required on some systems
#WorkingDirectory=/opt/nodeserver
Restart=always
# Restart service after 10 seconds if node service crashes
RestartSec=10
# Output to syslog
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=nodejs-example
#User=<alternate user>
#Group=<alternate group>
Environment=NODE_ENV=production PORT=3000

[Install]
WantedBy=multi-user.target

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AUser0, 2019-06-20
@AUser0

I recommend monit.
Very convenient!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question