More systemd friendly?#72
Conversation
anjohnson
left a comment
There was a problem hiding this comment.
Feels yucky.
This is partly why we use Makefiles to generate systemd.unit files from templates, using envsubst to expand them.
| // reallocate argv[] storage, and expand any unexpanded arguments | ||
| std::vector<std::string> argvStore; | ||
| for(char** av = childArgv; *av; av++) { | ||
| if((*av)[0]=='$') { // expand command from environment |
There was a problem hiding this comment.
The documentation for this needs to point out that it only accepts environment variables as a complete argument. As implemented an argument can't have a variable somewhere in the middle.
There was a problem hiding this comment.
If there is enough interest, I would implement shell style unquoting and argument splitting.
I have seen (and been responsible for) several variations on this theme. Not least the Still, this PR would not make these scripts go away. Only to reduce the content emitted to shorter |
|
Another idea. Using |
Oh my. That sounds like the next generation of the CA Gateway's killer and restart scripts... (It's a one-off and considerably different, I know.) To be honest, I'd rather go (same for the Gateway, btw.) for a configuration file containing One could find a generic C++ class that works for both procServ and the Gateway. |
A half-baked idea for how to make procServ, with its long argument lists, friendlier for use with systemd. Since systemd does not expand environment variables in
ExecStart=, teach procServ to do so.eg.
/etc/systemd/system/procServ@.serviceThis allows a unit override file to change only
$PROCCMDwithout needing to repeat the whole longExecStart=.eg.
/etc/systemd/system/procServ@foo.service/override.confWould be a more concise expression of what, where, and who.
I'm not sure what the semantics would be to handle command arguments. As written, this PR expands one environment variable as one argument. eg
PROCCMD=foo barwouldexec "foo bar"instead ofexec "foo" "bar"as might be expected.Maybe a better way would be to do indirection for procServ argument values, and add a new argument for the un-split command? eg.