Commands Linux CentOS
Nodejs Service Run on Server Reboot in Linux CentOS
January 2, 2018
0
,

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

 

About author

ZERIN

How To Check SHA 2/TLS 1.2 compatibility of your Linux server for Uninterrupted Communication

My nodejs software is installed in /root/soccer/pu...

Read more
standard tcp ports

Common Ports to Set for Linux New Server in Firewall

My nodejs software is installed in /root/soccer/pu...

Read more

How To migrate SVN repository to Another Repository?

My nodejs software is installed in /root/soccer/pu...

Read more

There are 0 comments

Leave a Reply

Your email address will not be published. Required fields are marked *