Skip to content

Instantly share code, notes, and snippets.

@jtlindsey
Last active May 16, 2017 01:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtlindsey/c1798cec32431b9c9a44331fa64fc36b to your computer and use it in GitHub Desktop.
Save jtlindsey/c1798cec32431b9c9a44331fa64fc36b to your computer and use it in GitHub Desktop.
Running a nodejs expressjs application on linux with systemd
# place file in following location
/etc/systemd/system/<application name>.service
[Unit]
Description=<application Name>
After=mongodb.service # Example that Requires the mongod service to run first
[Service]
# make sure to run the following as a regular user so node is found after each node upgrade
# n=$(which node);n=${n%/bin/node}; chmod -R 755 $n/bin/*; sudo cp -r $n/{bin,lib,share} /usr/local
ExecStart=/usr/local/bin/node /opt/<application folder name>/bin/www
WorkingDirectory=/opt/<application folder name>
Restart=always
SyslogIdentifier=<application name log identifier>
#User=<optional user>
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment