We have an issue with some of our configuration management tools where daemon-reload and daemon-reexec are necessary for updated service units. Unfortunately, running either briefly interferes with normal service manipulation commands like start, stop, and restart. A tool running on the wrong side of a daemon-reload ends up thinking the service it was working with is broken.<div>
<br></div><div>It's possible to retry a systemctl start, etc. command multiple times if a daemon-reload is running, but it's kind of dirty.</div><div><br></div><div>I figured it's worth sharing this Gist of a Python script I wrote to smartly wrap systemctl. It takes out a shared lock for normal commands and an exclusive one for daemon-* commands. This causes normal commands to wait on completion of daemon-* before attempting service manipulation. I don't recommend using this to replace the normal systemctl command globally, but it is a good drop-in when you have multiple tools that might cause each other problems as I described above.</div>
<div><br></div><div>Here's the code: <a href="https://gist.github.com/2488169">https://gist.github.com/2488169</a></div>