我正在尝试在 Ubuntu 18.04 主机上添加新的 sysV 服务。但是service
命令行为与手册中描述不符- 尽管 /etc/init.d 中存在文件,“服务”仍然抱怨没有 systemd 服务文件:
[email protected]:/etc/init.d# ls -l /etc/init.d/my-test-app
lrwxrwxrwx 1 root root 32 Mar 16 10:58 /etc/init.d/my-test-app -> /var/services/my-test.jar
[email protected]:/etc/init.d#
[email protected]:/etc/init.d#
[email protected]:/etc/init.d# service my-test-app status
Unit my-test-app.service could not be found.
[email protected]:/etc/init.d#
[email protected]:/etc/init.d#
[email protected]:/etc/init.d# /etc/init.d/my-test-app status
Running [9519]
[email protected]:/etc/init.d#
是因为我使用了符号链接吗?还是其他原因?
答案1
systemd
和 SysV init 系统之间的向后兼容性依赖于 提供的钩子systemd-sysv-generator
,如下所述:
生成器应该在启动时自动运行,但是如果你想避免重新启动,似乎可以通过调用来按需运行它们
systemctl daemon-reload
从man systemctl
:
daemon-reload Reload the systemd manager configuration. This will rerun all generators (see systemd.generator(7)), reload all unit files, and recreate the entire dependency tree. While the daemon is being reloaded, all sockets systemd listens on behalf of user configuration will stay accessible.