码迷,mamicode.com
首页 > Web开发 > 详细

debian系列systemd 配置nodejs服务

时间:2019-11-03 12:25:08      阅读:100      评论:0      收藏:0      [点我收藏+]

标签:nbsp   root   process   hellip   mon   des   pat   启动服务   work   

1  新建service配置文件

  vi /etc/systemd/system/node.service

[Unit]
Description=My super nodejs app

[Service]
# set the working directory to have consistent relative paths
WorkingDirectory=/home/root/Heroku/

# start the server file (file is relative to WorkingDirectory here)
ExecStart=/usr/bin/node /home/root/Heroku/server.js

# if process crashes, always try to restart
Restart=always

# let 500ms between the crash and the restart
RestartSec=500ms

# send log tot syslog here (it doesn‘t compete with other log config in the app itself)
StandardOutput=syslog
StandardError=syslog

# nodejs process name in syslog
SyslogIdentifier=nodejs

# user and group starting the app
User=root
Group=root

# set the environement (dev, prod…)
Environment=NODE_ENV=production


[Install]
# start node at multi user system level (= sysVinit runlevel 3)
WantedBy=multi-user.target

2 启动服务

  service star node

3 查看服务启动状态

  systemctl status node

4 开机启动

  systemctl enable node

 

参考:

https://riptutorial.com/node-js/example/28713/node-js-as-a-systemd-damon

debian系列systemd 配置nodejs服务

标签:nbsp   root   process   hellip   mon   des   pat   启动服务   work   

原文地址:https://www.cnblogs.com/wolbo/p/11785524.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!