Hi All, this document shows you how to create a service file for the npm start command.

Requirement
* NPM
* Root access to the server(Linux)

Step 1: Create a folder

mkdir /tmp/npm-project1

Step 2: Create a service file for stop/start the service,

vi /etc/systemd/system/my-app.service

 

Service]
WorkingDirectory=/tmp/npm-project1
ExecStart=/usr/local/bin/npm start
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=centos
User=centos
Group=centos

[Install]
WantedBy=multi-user.target

NOTE: you working and npm binary may change as per your environment

Explanation
The service file created will navigate to code saved directory and start npm. All the logs related to this service are logged in to Syslog.

© 2020, Techrunnr. All rights reserved.

#1
#2
#3
Questions Answered
Articles Written
Overall Points

Prabhin Prabharkaran

He is Technical professional. He is a person who loves to share tricks and tips on the Internet. He Posts what he does!!

0 Comments

Leave a Reply