diff --git a/doc/conditions.md b/doc/conditions.md index 531177e2..aafe30d3 100644 --- a/doc/conditions.md +++ b/doc/conditions.md @@ -169,7 +169,7 @@ Debugging If a service is not being started as it should, the problem might be that one of its conditions is not in the expected state. Use the command `initctl status` to inspect service status. Services in the -`ready` state are pending a condition. +`waiting` state are pending a condition. In that situation, running `initctl cond show` reveals which of the conditions that are not satisfied. Listed as `off` below. diff --git a/doc/svc-machine.png b/doc/svc-machine.png index 15955703..02c84e7c 100644 Binary files a/doc/svc-machine.png and b/doc/svc-machine.png differ diff --git a/doc/svc-machine.svg b/doc/svc-machine.svg index 94f77e3f..2bcb5492 100644 --- a/doc/svc-machine.svg +++ b/doc/svc-machine.svg @@ -1,4 +1,4 @@ -
STOPPING
STOPPING
HALTED
HALTED
READY
READY
'
'
WAITING
WAITING
RUNNING
RUNNING
CLEANUP
CLEANUP
SETUP
SETUP
post:
post:
~C
~C
-C
-C
+C
+C
-E
-E
+C and pre:
+C and pre:
-E or -C
-E or -C
+C
+C
start
start
+E
+E
E - Enabled
C - Condition(s)
pre: - pre-script
post: - post-script
E - Enabled...
idempotent!
idempotent!
DONE
DONE
run/task
run/ta...
manual:yes +restart
manual:yes +restart
STARTING
STARTING
pre: done
pre: done
Text is not SVG - cannot display
\ No newline at end of file +
STOPPING
STOPPING
HALTED
HALTED
WAITING
WAITING
PAUSED
PAUSED
RUNNING
RUNNING
CLEANUP
CLEANUP
SETUP
SETUP
post:
post:
~C
~C
-C
-C
+C
+C
-E
-E
+C and pre:script
+C and pre:script
-E or -C
-E or -C
+C
+C
start
start
+E
+E
E - Enabled
C - Condition(s)
P - PID file ready
R - Readiness
pre: - pre-script
post: - post-script
E - Enabled...
DONE
DONE
run/task
run/ta...
manual:yes and
initctl (re)start
manual:yes and...
STARTING
STARTING
pre:script done
pre:script done
initctl reload

SIGSTOP while figuring out if process should be in this .conf generation
initctl reload...
initctl reload

Enabled and READY but waiting for a condition, e.g. another process.
initctl reload...
ready:script
ready:script
+R
 or +P
+R...
When service signals 'ready' we call the ready script and then emit the <svc> condtion to trigger other run/task/services
When service signals 're...
NULL conditions are also conditions ...
NULL conditions are...
Text is not SVG - cannot display
\ No newline at end of file diff --git a/plugins/pidfile.c b/plugins/pidfile.c index eb52120d..3aa90ac8 100644 --- a/plugins/pidfile.c +++ b/plugins/pidfile.c @@ -234,9 +234,9 @@ static void pidfile_reconf(void *arg) } /* - * This will call service_step(), which in turn will schedule itself - * as long as stepped services change state. Services going from - * WAITING to RUNNING will reassert their conditions in that loop, + * This calls service_step(), which in turn schedules itself as + * long as stepped services change state. Services going from + * PAUSED to RUNNING reassert their conditions in that loop, * which in turn may unlock other services, and so on. */ service_step_all(SVC_TYPE_SERVICE | SVC_TYPE_RUNTASK); @@ -283,9 +283,9 @@ static void pidfile_init(void *arg) * * service /sbin/dropbear ... * - * Which provides the condition, will not be set by - * pidfile.so during `initctl reload` because dropbear is still - * SIGSTP:ed waiting for . + * This service provides the condition, which will not be + * set by pidfile.so during `initctl reload` because dropbear is still + * SIGSTP:ed (in state PAUSED) waiting for . */ static plugin_t plugin = { .name = __FILE__, diff --git a/src/service.c b/src/service.c index 99c0687d..8eebaf48 100644 --- a/src/service.c +++ b/src/service.c @@ -1993,14 +1993,14 @@ restart: switch (svc->state) { case SVC_HALTED_STATE: if (enabled) - svc_set_state(svc, SVC_READY_STATE); + svc_set_state(svc, SVC_WAITING_STATE); break; case SVC_DONE_STATE: if (svc_is_changed(svc)) svc_set_state(svc, SVC_HALTED_STATE); if (svc_is_runtask(svc) && svc_is_manual(svc) && enabled) - svc_set_state(svc, SVC_READY_STATE); + svc_set_state(svc, SVC_WAITING_STATE); break; case SVC_STOPPING_STATE: @@ -2046,7 +2046,7 @@ restart: svc_set_state(svc, SVC_STARTING_STATE); break; - case SVC_READY_STATE: + case SVC_WAITING_STATE: if (!enabled) { svc_set_state(svc, SVC_HALTED_STATE); } else if (cond_get_agg(svc->cond) == COND_ON) { @@ -2125,7 +2125,7 @@ restart: case COND_FLUX: kill(svc->pid, SIGSTOP); - svc_set_state(svc, SVC_WAITING_STATE); + svc_set_state(svc, SVC_PAUSED_STATE); break; case COND_ON: @@ -2148,7 +2148,7 @@ restart: } break; - case SVC_WAITING_STATE: + case SVC_PAUSED_STATE: if (!enabled) { kill(svc->pid, SIGCONT); service_stop(svc); @@ -2157,7 +2157,7 @@ restart: if (!svc->pid) { (*restart_cnt)++; - svc_set_state(svc, SVC_READY_STATE); + svc_set_state(svc, SVC_WAITING_STATE); break; } diff --git a/src/svc.h b/src/svc.h index 3b000c70..dc810490 100644 --- a/src/svc.h +++ b/src/svc.h @@ -61,8 +61,8 @@ typedef enum { SVC_STOPPING_STATE, /* Waiting to collect the child process */ SVC_CLEANUP_STATE, /* Running post: script */ SVC_SETUP_STATE, /* Running pre: script */ - SVC_WAITING_STATE, /* Condition is in flux, process SIGSTOPed */ - SVC_READY_STATE, /* Enabled but condition not satisfied */ + SVC_PAUSED_STATE, /* Condition is in flux, process SIGSTOPed */ + SVC_WAITING_STATE, /* Enabled but condition not satisfied */ SVC_STARTING_STATE, /* Conditions OK and pre: script done, start */ SVC_RUNNING_STATE, /* Process running */ } svc_state_t; @@ -353,8 +353,8 @@ static inline char *svc_status(svc_t *svc) return "stopping"; } - case SVC_WAITING_STATE: - return "waiting"; + case SVC_PAUSED_STATE: + return "paused"; case SVC_CLEANUP_STATE: return "cleanup"; @@ -362,8 +362,8 @@ static inline char *svc_status(svc_t *svc) case SVC_SETUP_STATE: return "setup"; - case SVC_READY_STATE: - return "ready"; + case SVC_WAITING_STATE: + return "waiting"; case SVC_RUNNING_STATE: return "running";