My nodejs software is installed in /root/soccer/public_html/ folder. I have a .sh script that start the service of nodejs, the .sh script name: node_auto.sh which file content is as follows:
###################################
#!/bin/bash
# My first script
echo “Expost node Path ”
export NODE_PATH=”/usr/local/lib/node_modules/npm/node_modules”
echo “Start ProGateway servere”
forever start app.js
forever list
###########################
Linux Command that I ran:
# chmod 744 /root/soccer/public_html/node_auto.sh
# cd /etc/systemd/system/
I wrote a service script first in /etc/systemd/system/ folder:
# nano nodejs.service
File Content is:
######################################
[Unit]
After=mysql.service
[Service]
ExecStart=/root/soccer/public_html/node_auto.sh
Type=simple
User=root
Group=root
WorkingDirectory=/root/soccer/public_html/
[Install]
WantedBy=default.target
######################################
# chmod 664 /etc/systemd/system/nodejs.service
# systemctl daemon-reload
# systemctl enable nodejs.service
To See if the Service has been installed properly, ran the following command:
# systemctl list-unit-files
There are 0 comments