我试图永远在启动时启动一个简单的 nodejs 应用程序,作为使用 systemd 的概念证明,并且我一生都无法让它工作。
如果我这样做,它绝对可以正常工作:
systemctl start simple-empty-app.service
但是,如果我重新启动系统,它甚至不会尝试加载,syslog 中似乎没有任何内容表明它甚至正在尝试它(但还有一些其他 systemd 启动消息,所以我知道 systemd 正在做它的事情。 ..)。
我的.service
脚本如下所示:
[Unit]
Description=This is an empty tiny app for testing the nodejs deployment agent
[Service]
StandardOutput=syslog
SyslogIdentifier=simple-empty-app
Type=forking
Environment=ENV=production
Environment=PATH=/usr/bin:/usr/local/bin
WorkingDirectory=/var/opt/nodejs-agent/node_modules/simple-empty-app
ExecStart=/usr/local/bin/forever start --pidFile /var/run/simple-empty-app.pid /var/opt/nodejs-agent/node_modules/simple-empty-app/app.js
ExecStop=/usr/local/bin/forever stop /var/opt/nodejs-agent/node_modules/simple-empty-app/app.js
PIDFile=/var/run/simple-empty-app.pid
User=root
Asystemctl status simple-empty-app.service
重启后显示:
simple-empty-app.service - This is an empty tiny app for testing the nodejs deployment agent
Loaded: loaded (/var/opt/nodejs-agent/node_modules/simple-empty-app/simple-empty-app.service; linked)
Active: inactive (dead)
CGroup: name=systemd:/system/simple-empty-app.service
只是为了证明它是手动启动的:
root@karls-debian:~# systemctl start simple-empty-app.service
root@karls-debian:~# systemctl status simple-empty-app.service
simple-empty-app.service - This is an empty tiny app for testing the nodejs deployment agent
Loaded: loaded (/var/opt/nodejs-agent/node_modules/simple-empty-app/simple-empty-app.service; linked)
Active: active (running) since Fri, 11 Apr 2014 17:34:24 +0100; 4s ago
Process: 1558 ExecStart=/usr/local/bin/forever start --pidFile /var/run/simple-empty-app.pid /var/opt/nodejs-agent/node_modules/simple-empty-app/app.js (code=exited, status=0/SUCCESS)
Main PID: 1566 (node)
有人有什么想法吗?如果它有帮助,显然我已经从 debian repo追溯安装systemd
,因为它不是系统化的。systemd-sysv
我在 Wheezy