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

CEO & Founder (BdBooking.com - Online Hotel Booking System), CEO & Founder (TaskGum.com - Task Managment Software), CEO & Founder (InnKeyPro.com - Hotel ERP), Software Engineer & Solution Architect

How To Setup a Subdomain with SSL on Amazon Linux 2 AMI

I assume that you can login to Amazon Linux 2 AMI ...

Read more

MySQL “Order By Clause” Not Working with “SELECT DISTINCT and ORDER BY” after MySQL Update to 5.7

I have recently updated our MySQL server to MySQL ...

Read more

WHM:: PHP Mail is Not Working-Showing Its Disable

When your mail does not work, one example could be...

Read more

There are 0 comments

Leave a Reply

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