[systemd-devel] Idea: adding WantsFileBefore= and WantsFileAfter=?

Ryan Gonzalez rymg19 at gmail.com
Tue Mar 20 21:08:33 UTC 2018


Hello!!

Recently, I was trying to help out someone on IRC move some sysvinit 
scripts over to systemd units, and there was one interesting issue that 
came up. Many older daemons will create sockets at some unspecified point 
in their startup sequence, with no indication of when this occurs. In this 
case, it was a bit after the pid file, so systemd started running units 
that required this socket ready before it was actually ready.

Using socket activation here would be great, but again, this is an older 
daemon, and AFAIK socket activation *always* requires a deamon to read the 
socket path over stdin.

Here's my idea: what if there were WantsFileBefore= and WantsFileAfter= 
options, that could be used like this:

[Service]
Type=oneshot
ExecStart=/usr/bin/my-service
WantsFileBefore=this-file-should-be-existant-before-running-service
WantsFileAfter=systemd-should-wait-until-this-file-exists-before-continuing

In short, WantsFileBefore=file would be roughly equivalent to 
ExecPreStart=wait-for-file file, and WantsFileAfter=file would be roughly 
equivalent to ExecPostStart=wait-for-file file. Of course, now there would 
be no need to useless shell commands.

Thoughts?

-- 
Ryan (ライアン)
Yoko Shimomura, ryo (supercell/EGOIST), Hiroyuki Sawano >> everyone else
https://refi64.com/



More information about the systemd-devel mailing list