美文网首页
Run node as service on CentOS

Run node as service on CentOS

作者: goldenfiredo | 来源:发表于2018-11-05 09:19 被阅读0次

    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

    相关文章

      网友评论

          本文标题:Run node as service on CentOS

          本文链接:https://www.haomeiwen.com/subject/jhpjxqtx.html