Skip to content

Instantly share code, notes, and snippets.

@oraclejavanet
Forked from ccarrasc/my-service.service
Created December 9, 2018 03:58
Show Gist options
  • Save oraclejavanet/1756edbe0a6ba929b4ad0564151d67f1 to your computer and use it in GitHub Desktop.
Save oraclejavanet/1756edbe0a6ba929b4ad0564151d67f1 to your computer and use it in GitHub Desktop.
Install a Node.js service for systemctl on CentOS 7
[Unit]
After=network.target
[Service]
ExecStart=/usr/bin/node /var/node/my-service/app.js
#Type=forking
Restart=always
StandardOutput=syslog
TimeoutSec=90
SyslogIdentifier=my-service
User=nobody
Group=nobody
Environment=PATH=/usr/bin:/usr/local/bin
Environment=NODE_ENV=production
[Install]
WantedBy=multi-user.target
#! /bin/bash
curl -sL https://rpm.nodesource.com/setup | bash -
yum install -y nodejs gcc-c++ make
sudo mkdir -p /var/node/my-service/
# ... cp project into /var/node/my-service/
cd /var/node/my-service/
npm install
sudo cp my-service.service /etc/systemd/system/
systemctl enable my-service
systemctl start my-service.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment