Improved handling of restarts ("run this on changes") #129
Labels
No Label
bugfix
cleanup
discussion
documentation
doing
done
feature
improvement
packaging
Stale
testing
TODO
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: ungleich-public/cdist#129
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Created by: matthijskooijman
In my manifest, I'm running into problems handling restarts of services after config files or installed binaries are changed. There's a few sides to this.
__config_file
supports an--onchange
option, which runs arbitrary commands when a config file changes. However, when multiple config files are involved in the same service, this has a number of problems:No other types seem to have such an
--onchange
option. A lot of them do emit messages when they run / change things, but you cannot currently configure any handlers for them in the manifest directly AFAUI. Instead, you must define a new type "__restart_my_service" that checks the message list for any changed files or other relevant messages and restarts the service if any are found. Having such a specific type does not seem useful to me, and this also implies hardcoding the list of relevant messages, which you'd rather control from the manifest AFAICS.Ideally, I could do something like:
This invented a
__systemd_restart_unit
to actually do the restart, something more generic could also work. There's two parts to such a solution:--on-change-message
is used to make the type emit a custom message, which is checked by__system_restart_unit
to decide whether to run or not.foo-restart
message. In the above example, this would either needCDIST_ORDER_DEPENDENCY
, or explicitly naming all of them (or cdist must be extended to recognize this particular pattern).If all dependencies are listed, you might consider introducing another dependency type in addition to the current
require
, which could handle both ordering and running only if neeed. E.g.:Here, the
onlyif
dependency says to only run if any of the mentioned dependencies ran, and implicitly to also run after all of the mentioned dependencies.Perhaps you could reverse this:
Which is a bit more elegant, but might also be more complex to implement?
A message-based approach is probably more flexible than these dependency-based approaches, but also a bit more verbose...
I'm not quite sure what implementation would be best (I'm just guessing, the best approach is probably not listed here), but I'd like to see something to implement this usecase (unless something exists that I'm missing?).
I suspect this might tie in with #624 a little.
closed