cbowdon / daemons.el

An Emacs UI for managing init system services
GNU General Public License v3.0
101 stars 12 forks source link

Support arbitrary actions for shepherd services #19

Closed bricewge closed 1 year ago

bricewge commented 4 years ago

shepherd allows one to define arbitrary actions for each services taking any number of arguments.

As an example, the root service support, by default, several actions in addition to the more common ones (ie: start, disable, status, ...) that are specific of this service. Like power-off to shutdown your system that takes no other arguments or eval that takes some Guile code as an argument to be executed by shepherd. To get the list of the actions a service support we can use the doc action with the list-actions. Following is a little example of such usage:

$ herd doc root
The root service is used to operate on shepherd itself
$ herd doc root list-actions
root (help status halt power-off load eval unload reload daemonize persistency no-persistency cd restart)
$ herd eval root '(* 2 21)'
Évaluation de l'expression utilisateur (* 2 21).
42
$ sudo herd power-off root
# The system shutdown.

I couldn't find any supported system daemons which accept arbitrary actions. How should I went about implement such a feature for shepherd in daemons.el?

cbowdon commented 4 years ago

Wow, interesting. I guess in the UI this would be something like M-x daemons-action and then a prompt?

The existing commands are very limited as you've probably seen - it must be a shell command to be executed with the daemon's name. I'm a bit reluctant to mess with this because it's stable and I don't want to commit time to a proper refactoring. So I think an additive change would be best, adding :interactive-commands to the daemons-define-submodule, then three new functions:

all analagous to the existing non-interactive versions. There'd also need to be boilerplate for daemons-action and daemons-action-at-point.

It's a bit repetitive, but IMO a bit safer so if you went this route I'd be happy to merge. Thanks for your interest, always happy people are using this package!