Last active
May 16, 2017 01:02
-
-
Save jtlindsey/c1798cec32431b9c9a44331fa64fc36b to your computer and use it in GitHub Desktop.
Running a nodejs expressjs application on linux with systemd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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