[systemd-devel] clarification on daemon-reload
alexandre.detiste at gmail.com
Sun May 17 23:35:07 PDT 2015
Le lundi 18 mai 2015, 07:51:18 Igor Bukanov a écrit :
> What I would like to know is what is the exact behavior of systemctl
> daemon-reload. I am writing a service that creates/modifies other
> units by placing files under /run and I would like to know what are
> the limitations. In my case I cannot use a systemd.generator as the
> service depends on a mounted directory.
You could have a generator that first create a one-shot .service
if it's directory is not mounted at boot.
This one-shot .service looks like that:
| ExecStart=/bin/sh -c "/usr/bin/systemctl daemon-reload ; /usr/bin/systemctl try-restart your-service"
At it's second run (when called by daemon-reload), the generator does the right thing.
The /bin-sh -c "..." is needed to encapsulate the try-restart;
if it's not there, as this .service file doesn't exist anymore; the try-restart is never run.
It's ugly, but it works reliably.
More information about the systemd-devel