mirror of
https://github.com/troglobit/finit.git
synced 2026-11-21 19:51:46 +00:00
Merge pull request #472 from finit-project/reload-foo
This commit is contained in:
7 files changed
+42
-6
No files matched your search
@@ -14,6 +14,10 @@ All relevant changes are documented in this file.
|
||||
- Set USER and LOGNAME environment variables when dropping privileges.
|
||||
Fixes issues with software like rootless Podman that determines user
|
||||
identity from environment variables, by Aaron Andersen
|
||||
- Add `remain:yes` option for run/task oneshot commands, similar to the
|
||||
systemd `RemainAfterExit=yes`, by Aaron Andersen
|
||||
- Clear service conditions on `initctl reload NAME` to ensure dependent
|
||||
services are properly updated
|
||||
|
||||
### Fixes
|
||||
- Fix #464: invalid user:group examples in cgroups.md
|
||||
|
||||
@@ -194,6 +194,10 @@ When Finit configuration files are changed and the `initctl reload`
|
||||
command is called, it is expected of services to touch their PID files
|
||||
for Finit to reassert their conditions.
|
||||
|
||||
Similarly, when a single service is reloaded with `initctl reload NAME`,
|
||||
its conditions are cleared and reasserted, ensuring dependent services
|
||||
are properly updated.
|
||||
|
||||
Daemons that don't create PID files, or fail to touch them on reload,
|
||||
can be worked around by using the `pid:/path/to/file.pid` syntax in
|
||||
the service stanza for the daemon. It is far from optimal since any
|
||||
|
||||
@@ -112,6 +112,8 @@ static int restart(svc_t *svc, void *user_data)
|
||||
|
||||
static int reload(svc_t *svc, void *user_data)
|
||||
{
|
||||
char cond[MAX_COND_LEN];
|
||||
|
||||
(void)user_data;
|
||||
|
||||
if (!svc)
|
||||
@@ -122,6 +124,20 @@ static int reload(svc_t *svc, void *user_data)
|
||||
else
|
||||
service_timeout_cancel(svc);
|
||||
|
||||
/*
|
||||
* Clear conditions before reload to ensure dependent services
|
||||
* are properly updated. The conditions are reasserted when
|
||||
* the service touches its PID file after processing SIGHUP.
|
||||
*
|
||||
* Note: only clear 'ready' for services where the pidfile
|
||||
* inotify handler reasserts it (pid/none). For s6/systemd
|
||||
* services readiness relies on their respective notification
|
||||
* mechanism which may not re-trigger on SIGHUP.
|
||||
*/
|
||||
cond_clear(mkcond(svc, cond, sizeof(cond)));
|
||||
if (svc->notify == SVC_NOTIFY_PID || svc->notify == SVC_NOTIFY_NONE)
|
||||
service_ready(svc, 0);
|
||||
|
||||
svc_mark_dirty(svc);
|
||||
service_step(svc);
|
||||
|
||||
|
||||
@@ -361,9 +361,6 @@ restart:
|
||||
|
||||
/* Restore terse mode and run hooks before shutdown */
|
||||
if (runlevel == 0 || runlevel == 6) {
|
||||
/* Hide cursor, we're going down ... */
|
||||
dprint(STDOUT_FILENO, "\033[?25l", 6);
|
||||
|
||||
api_exit();
|
||||
log_exit();
|
||||
plugin_run_hooks(HOOK_SHUTDOWN);
|
||||
|
||||
+11
-2
@@ -5,6 +5,7 @@
|
||||
# - bar must not start until foo is ready
|
||||
# - bar must be stopped when foo goes down
|
||||
# - bar must be restarted when foo is restarted
|
||||
# - bar must be restarted when foo is reloaded (per-service reload)
|
||||
#
|
||||
# Regression test bug #314, that bar is not in a restart loop when foo
|
||||
# is stopped. Also, verify that changing between runlevels, where foo
|
||||
@@ -49,6 +50,13 @@ test_one()
|
||||
run "initctl status"
|
||||
assert "bar is restarted" "$(texec initctl |grep bar | awk '{print $1;}')" != "$pid"
|
||||
|
||||
say "Verify bar is restarted when foo is reloaded (per-service) ..."
|
||||
retry 'assert_status "bar" "running"' 5 1
|
||||
pid=$(texec initctl |grep bar | awk '{print $1;}')
|
||||
run "initctl reload foo"
|
||||
retry 'assert_status "bar" "running"' 5 1
|
||||
assert "bar is restarted on reload" "$(texec initctl |grep bar | awk '{print $1;}')" != "$pid"
|
||||
|
||||
# Wait for spice to be stolen by the Harkonnen
|
||||
sleep 3
|
||||
# bar should now have detected the loss of spice and be in restart
|
||||
@@ -61,8 +69,9 @@ test_one()
|
||||
assert_status "bar" "waiting"
|
||||
}
|
||||
|
||||
run "initctl debug"
|
||||
sep
|
||||
test_one "pid/foo"
|
||||
sep
|
||||
run "initctl debug"
|
||||
test_one "service/foo/running"
|
||||
#run "initctl debug"
|
||||
test_one "service/foo/ready"
|
||||
+1
-1
@@ -52,4 +52,4 @@ done
|
||||
echo "$pid" > /tmp/oldpid
|
||||
|
||||
#echo "PID $pid, kill -9 ..."
|
||||
kill -9 "$pid"
|
||||
kill -9 "$pid" 2>/dev/null || true
|
||||
@@ -325,6 +325,12 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (melange) {
|
||||
mine(melange);
|
||||
vanish = -2;
|
||||
}
|
||||
|
||||
if (do_pidfile > 0)
|
||||
pidfile(NULL);
|
||||
reloading = 0;
|
||||
|
||||
Reference in new issue
Block a user