996Worker
996Worker
发布于 2021-12-19 / 257 阅读
0
0

systemd脚本自启动node程序

步骤

以服务名pano为例.

  1. vim /usr/lib/systemd/system/pano.service
  2. 插入以下文字并保存:
[Unit]
Description=pano - main site of site_name.com
Documentation=http://www.site_name.com/docs/

[Service]
ExecStart=/usr/local/bin/node /www/www.site_name.com/node/bin/www
ExecStop=/bin/kill -s QUIT $MAINPID
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=nobody
User=nobody
Group=nobody
Environment=NODE_ENV=production

[Install]
WantedBy=multi-user.target
  1. 重载服务
    systemctl enable pano
    systemctl start pano

评论