Posted on

How to set up a Node Project as a Service in Centos

You will need to create a Service file in, for example: /etc/systemd/system/Monty.service

in this file include the following:

[Unit]
Description=Mikes Monty Example
#Requires=After=mysql.service # Requires the mysql service to run first

[Service]
ExecStart=/bin/node /home/m4kr/public_html/Monty/node_modules/react-app-rewired/scripts/start.js
WorkingDirectory=/home/m4kr/public_html/Monty
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=monty
#User=root
#Group=root
Environment=NODE_ENV=development PORT=3000

[Install]
WantedBy=multi-user.target