我正试图永远在启动时启动一个简单的nodejs应用程序作为使用systemd的概念证明,并且对我来说无法让它工作。
如果我这样做,它绝对可以:
systemctl start simple-empty-app.service
但是,如果我重新启动系统它甚至没有尝试加载,syslog中似乎没有任何东西表明它甚至正在尝试它(但是还有一些其他系统启动消息,所以我知道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
重新启动后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: 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
答案 0 :(得分:1)
修正了它,只需要以下部分:
[安装] WantedBy = multi-user.target