用systemd腳本自動啓動node js程序

vi /usr/lib/systemd/system/pano.servicenode

[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
# systemctl enable pano
# systemctl start pano

 

nginx的啓動腳本/usr/lib/systemd/system/nginx.servicenginx

[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network.target remote-fs.target nss-lookup.target
 
[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t -c /etc/nginx/nginx.conf
ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
 
[Install]
WantedBy=multi-user.target
相關文章
相關標籤/搜索