Run node as service on CentOS

2018-11-05  本文已影响0人  goldenfiredo

1 Create /etc/systemd/system/nodeserver.service

[Unit]Description=Node.js Example Server#Requires=After=mysql.service # Requires the mysql service to run first[Service]ExecStart=/usr/local/bin/node /opt/nodeserver/server.js# Required on some systems#WorkingDirectory=/opt/nodeserverRestart=always

# Restart service after 10 seconds if node service crashes RestartSec=10

# Output to syslogStandardOutput=syslogStandardError=syslogSyslogIdentifier=nodejs-example#User=<alternate user>#Group=<alternate group>Environment=NODE_ENV=production PORT=1337

[Install]WantedBy=multi-user.target

2 systemctl enable nodeserver.service

3 systemctl start nodeserver.service

4 systemctl status nodeserver.service

5 systemctl restart nodeserver.service

6 ps -ef | grep server.js

上一篇 下一篇

猜你喜欢

热点阅读