How to create a systemd service

How to create a systemd service based on the example of a node.js application

vim /etc/systemd/system/nodeapp.service
[Unit]
Description=NodeJS Web Application
After=network.target

[Service]
ExecStart=/usr/bin/node /var/www/server.js
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=nodeapp
User=web
Group=web
Environment=PATH=/usr/bin:/usr/local/bin
Environment=NODE_ENV=production
WorkingDirectory=/var/www/

[Install]
WantedBy=multi-user.target

Leave a Reply