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.
|
- Set USER and LOGNAME environment variables when dropping privileges.
|
||||||
Fixes issues with software like rootless Podman that determines user
|
Fixes issues with software like rootless Podman that determines user
|
||||||
identity from environment variables, by Aaron Andersen
|
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
|
### Fixes
|
||||||
- Fix #464: invalid user:group examples in cgroups.md
|
- 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
|
command is called, it is expected of services to touch their PID files
|
||||||
for Finit to reassert their conditions.
|
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,
|
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
|
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
|
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)
|
static int reload(svc_t *svc, void *user_data)
|
||||||
{
|
{
|
||||||
|
char cond[MAX_COND_LEN];
|
||||||
|
|
||||||
(void)user_data;
|
(void)user_data;
|
||||||
|
|
||||||
if (!svc)
|
if (!svc)
|
||||||
@@ -122,6 +124,20 @@ static int reload(svc_t *svc, void *user_data)
|
|||||||
else
|
else
|
||||||
service_timeout_cancel(svc);
|
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);
|
svc_mark_dirty(svc);
|
||||||
service_step(svc);
|
service_step(svc);
|
||||||
|
|
||||||
|
|||||||
@@ -361,9 +361,6 @@ restart:
|
|||||||
|
|
||||||
/* Restore terse mode and run hooks before shutdown */
|
/* Restore terse mode and run hooks before shutdown */
|
||||||
if (runlevel == 0 || runlevel == 6) {
|
if (runlevel == 0 || runlevel == 6) {
|
||||||
/* Hide cursor, we're going down ... */
|
|
||||||
dprint(STDOUT_FILENO, "\033[?25l", 6);
|
|
||||||
|
|
||||||
api_exit();
|
api_exit();
|
||||||
log_exit();
|
log_exit();
|
||||||
plugin_run_hooks(HOOK_SHUTDOWN);
|
plugin_run_hooks(HOOK_SHUTDOWN);
|
||||||
|
|||||||
+11
-2
@@ -5,6 +5,7 @@
|
|||||||
# - bar must not start until foo is ready
|
# - bar must not start until foo is ready
|
||||||
# - bar must be stopped when foo goes down
|
# - bar must be stopped when foo goes down
|
||||||
# - bar must be restarted when foo is restarted
|
# - 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
|
# Regression test bug #314, that bar is not in a restart loop when foo
|
||||||
# is stopped. Also, verify that changing between runlevels, where foo
|
# is stopped. Also, verify that changing between runlevels, where foo
|
||||||
@@ -49,6 +50,13 @@ test_one()
|
|||||||
run "initctl status"
|
run "initctl status"
|
||||||
assert "bar is restarted" "$(texec initctl |grep bar | awk '{print $1;}')" != "$pid"
|
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
|
# Wait for spice to be stolen by the Harkonnen
|
||||||
sleep 3
|
sleep 3
|
||||||
# bar should now have detected the loss of spice and be in restart
|
# bar should now have detected the loss of spice and be in restart
|
||||||
@@ -61,8 +69,9 @@ test_one()
|
|||||||
assert_status "bar" "waiting"
|
assert_status "bar" "waiting"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
run "initctl debug"
|
||||||
sep
|
sep
|
||||||
test_one "pid/foo"
|
test_one "pid/foo"
|
||||||
sep
|
sep
|
||||||
run "initctl debug"
|
#run "initctl debug"
|
||||||
test_one "service/foo/running"
|
test_one "service/foo/ready"
|
||||||
+1
-1
@@ -52,4 +52,4 @@ done
|
|||||||
echo "$pid" > /tmp/oldpid
|
echo "$pid" > /tmp/oldpid
|
||||||
|
|
||||||
#echo "PID $pid, kill -9 ..."
|
#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
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (melange) {
|
||||||
|
mine(melange);
|
||||||
|
vanish = -2;
|
||||||
|
}
|
||||||
|
|
||||||
if (do_pidfile > 0)
|
if (do_pidfile > 0)
|
||||||
pidfile(NULL);
|
pidfile(NULL);
|
||||||
reloading = 0;
|
reloading = 0;
|
||||||
|
|||||||
Reference in new issue
Block a user