mirror of
https://github.com/troglobit/finit.git
synced 2026-10-15 10:29:35 +00:00
conf: replace the '!' condition prefix with reload-signal and required
A condition list could be led by '!', which is not a condition and not
a negation. It is a flag on the block, and it means two unrelated
things depending on which block it sits in: a service or sysv does not
handle SIGHUP and must be restarted to reload, while a run or task
must not hold up bootstrap. Writing '<!>' with no condition at all is
legal, which gives away that it was never an operator.
Give each meaning its own key, valid only where it applies:
service foo { reload-signal = "none" } # restart to reload
task bar { required = false } # do not hold up bootstrap
Using either on a block type it does not apply to warns, as does a '!'
left in a conditions list. Both still translate to that same '!',
which is all a legacy line can carry, so reload-signal takes SIGHUP or
none for now; str2sig() already accepts any case and an optional SIG
prefix.
This also clears the way for the conditions list to grow real
operators, '+' and '-' for asserted and deasserted, without '!'
sitting among them meaning something else entirely.
The '~' prefix stays. It belongs to the list: it marks a dependency
whose reload should propagate here.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
2 files changed
+79
-3
No files matched your search
@@ -182,3 +182,39 @@ run "initctl reload"
|
||||
retry 'assert_num_children 1 service.sh'
|
||||
assert "daemon-owned pidfile is not created by Finit" \
|
||||
"$(texec ls /run/notmine.pid 2>/dev/null)" = ""
|
||||
|
||||
say 'reload-signal = none emits the legacy noreload flag'
|
||||
run "echo 'service service.sh {' > $FINIT_CONF"
|
||||
run "echo ' description = \"Test service\"' >> $FINIT_CONF"
|
||||
run "echo ' reload-signal = \"none\"' >> $FINIT_CONF"
|
||||
run "echo ' command = \"service.sh\"' >> $FINIT_CONF"
|
||||
run "echo '}' >> $FINIT_CONF"
|
||||
run "initctl reload"
|
||||
|
||||
retry 'assert_num_children 1 service.sh'
|
||||
assert_desc "Test service" service.sh
|
||||
|
||||
say 'Case and short forms of SIGHUP are all the default, no flag'
|
||||
for s in SIGHUP sighup HUP hup; do
|
||||
run "echo 'service service.sh {' > $FINIT_CONF"
|
||||
run "echo ' description = \"Test service\"' >> $FINIT_CONF"
|
||||
run "echo \" reload-signal = '$s'\" >> $FINIT_CONF"
|
||||
run "echo ' command = \"service.sh\"' >> $FINIT_CONF"
|
||||
run "echo '}' >> $FINIT_CONF"
|
||||
run "initctl reload"
|
||||
retry 'assert_num_children 1 service.sh'
|
||||
done
|
||||
|
||||
# 'required' and 'reload-signal' both translate to the legacy ! that
|
||||
# leads the condition list, but each is valid only for the block types
|
||||
# where that ! carries its meaning.
|
||||
say 'required = false on a task does not hold up bootstrap'
|
||||
run "echo 'task pwrfail {' > $FINIT_CONF"
|
||||
run "echo ' description = \"Power failure\"' >> $FINIT_CONF"
|
||||
run "echo ' conditions = { \"sys/pwr/fail\" }' >> $FINIT_CONF"
|
||||
run "echo ' required = false' >> $FINIT_CONF"
|
||||
run "echo ' command = \"/bin/true\"' >> $FINIT_CONF"
|
||||
run "echo '}' >> $FINIT_CONF"
|
||||
run "initctl reload"
|
||||
|
||||
retry 'assert_desc "Power failure" pwrfail'
|
||||
Reference in new issue
Block a user