Suppose we have a nice application written in nodejs in the folder /src/www/myNiceNodejsApp.
We will create a system service to start and manage the app on system boot.
Create a file /etc/systemd/system/myNiceNodejsApp.service
[Unit]
Description=myNiceNodejsApp Node.js service
After=network.target
[Service]
Type=simple
Restart=always
User=nobody
Group=nobody
# customize port
Environment=NODE_PORT=8888
ExecStart=/bin/node /srv/www/myNiceNodejsApp/index.js
Restart=on-failure
# syslog
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=myNiceNodejsApp
[Install]
WantedBy=multi-user.target
Enable service and start
systemctl daemon-reload
systemctl start myNiceNodejsApp
systemctl enable myNiceNodejsApp