我在CentOS 7中有一个自定义的systemd服务,其启动脚本位于以下版本的控制下/srv/etc/systemd/website.service
:
[Unit]
Description=website
After=syslog.target network.target
[Service]
Type=forking
User=website
ExecStart=/opt/perl5/perls/perl-5.20.2/bin/hypnotoad /var/www/domains/<domain>/script/site.pl
ExecStop=/opt/perl5/perls/perl-5.20.2/bin/hypnotoad --stop /var/www/domains/<domain>/script/site.pl
[Install]
WantedBy=multi-user.target
如果我运行systemctl enable /srv/etc/systemd/website.service
它,可以很好地创建符号链接,并且可以运行systemctl start website
并且服务启动,但是它抱怨缺少[Install]部分,这显然是不正确的:
$ sudo systemctl enable /srv/etc/systemd/website.service
Created symlink from /etc/systemd/system/website.service to /srv/etc/systemd/website.service.
The unit files have no [Install] section. They are not meant to be enabled
using systemctl.
Possible reasons for having this kind of units are:
1) A unit may be statically enabled by being symlinked from another unit's
.wants/ or .requires/ directory.
2) A unit's purpose may be to act as a helper for some other unit which has
a requirement dependency on it.
3) A unit may be started when needed via activation (socket, path, timer,
D-Bus, udev, scripted systemctl call, ...).
重新启动后,服务不会启动,并systemctl start website
返回Failed to start website.service: Unit not found
。如果我运行systemctl daemon-reload
,该start
命令将再次起作用。
但是,如果我将文件复制到/ etc / systemd / system并运行systemctl enable website
,那么一切都会按预期进行,并且该服务会在重启后立即启动。
实际上是否可以做我想做的事情,还是我只需要记住要进行任何更改就可以从Git存储库中手动复制systemd脚本?
您应该检查启动服务时是否已安装符号链接引用的驱动器。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句