On reload/restart we must wait for services to stop first

This patch adds support for declaring *why* a service is being stopped
or reloaded.  This is later used when all stopped services have been
collected by the `service_monitor()` to issue start or postponed SIGHUP.

As an added benefit we can now also see why a service is not running.
If it has been paused by a user, halted when moving to another runlevel,
waiting for a condition (event), or similar.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2015-11-22 10:11:27 +01:00
1 parent b1d57d6828
commit 924bf041bc
9 files changed
+92 -36

No files matched your search

+8 -3
View File
@@ -108,8 +108,13 @@ static int call(int (*action)(svc_t *), char *buf, size_t len)
return result;
}
static int service_pause(svc_t *svc)
{
return service_stop(svc, SVC_PAUSED_STATE);
}
static int do_start (char *buf, size_t len) { return call(service_start, buf, len); }
static int do_stop (char *buf, size_t len) { return call(service_stop, buf, len); }
static int do_pause (char *buf, size_t len) { return call(service_pause, buf, len); }
static int do_reload (char *buf, size_t len) { return call(service_reload, buf, len); }
static int do_restart(char *buf, size_t len) { return call(service_restart, buf, len); }
@@ -258,7 +263,7 @@ static void cb(uev_t *w, void *UNUSED(arg), int UNUSED(events))
debug = !debug;
break;
case INIT_CMD_RELOAD:
case INIT_CMD_RELOAD: /* 'init q' and 'initctl reload' */
service_reload_dynamic();
break;
@@ -267,7 +272,7 @@ static void cb(uev_t *w, void *UNUSED(arg), int UNUSED(events))
break;
case INIT_CMD_STOP_SVC:
result = do_stop(rq.data, sizeof(rq.data));
result = do_pause(rq.data, sizeof(rq.data));
break;
case INIT_CMD_RELOAD_SVC: