Monday, July 29, 2019

Making Node.js service always alive on Ubuntu Server

Making file /etc/systemd/system/hello_world.service , this would be the main file as a configuration to SystemD service
[Unit]
Description=Node.js Hello World Http Server
[Service]
PIDFile=/tmp/hello_world-99.pid
User=<Your Username>
Group=<Your User Group>
Restart=always
KillSignal=SIGQUIT
WorkingDirectory=/home/<username>/hello_world/
ExecStart=/usr/bin/node /home/<username>/hello_world/server.js
[Install]
WantedBy=multi-user.target

sudo systemctl enable hello_world.service
sudo systemctl start|stop|status hello_world.service

No comments: