最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

system design - What is the expected behavior for stopping an inactive systemd service that is configured to auto-start? - Stack

programmeradmin1浏览0评论

I have a service file foo.service that is configured to auto-start after a target init_done.target.

[Unit]
After=init_done.target
...
[Install]
WantedBy=multi-user.arget

If I run systemctl stop foo.service before foo.service is ready (i.e., init_done.target has become active), a message can be seen in the log: "Stopped Foo Service."

systemctl status foo
● foo.service - Foo Service
   Loaded: loaded (/etc/systemd/system/foo.service; enabled; vendor preset: enabled)
   Active: inactive (dead)

Feb 12 01:23:45 user systemd[1]: Stopped Foo Service.

I presumed this systemctl stop command is a no-op, because foo.service has yet to become active which means there is nothing to stop.

However, it turns out that running the systemctl stop foo.service command this early on in the boot sequence actually prevents foo.service from starting even when init_done.target eventually becomes active. This is surprising to me because I thought using systemctl stop in this manner should be a no-op as I explained above. Is this the expected behavior? And where can I find documentation on this? I've read through the man page and can't find a direct answer on what should happen when systemctl stop is used on an inactive target that is configured to auto-start after a specific target becomes active.

For the record, the systemctl in question is on version 229.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论