Dynamically manage service states based on user defined conditions

Old event system has been replaced with a more generic condition
concept. The idea is that finit plugins may provide arbitrary
conditions that services may specify as dependencies that they require
to run.

In order to accomodate this, the service management has been
redesigned to use a state machine.
This commit is contained in:
Tobias Waldekranz committed 2016-01-05 15:01:58 +01:00
1 parent 7a3408c173
commit 2232aea0f7
17 files changed
+879 -736

No files matched your search

+6 -6
View File
@@ -28,6 +28,7 @@
#include <string.h>
#include "finit.h"
#include "cond.h"
#include "service.h"
#include "tty.h"
#include "libite/lite.h"
@@ -113,7 +114,7 @@ int conf_parse_runlevels(char *runlevels)
return bitmask;
}
void conf_parse_events(svc_t *svc, char *events)
void conf_parse_cond(svc_t *svc, char *cond)
{
size_t i = 0;
char *ptr;
@@ -126,11 +127,11 @@ void conf_parse_events(svc_t *svc, char *events)
/* By default we assume UNIX daemons support SIGHUP */
svc->sighup = 1;
if (!events)
if (!cond)
return;
/* First character must be '!' if SIGHUP is not supported. */
ptr = events;
ptr = cond;
if (ptr[i] == '!') {
svc->sighup = 0;
ptr++;
@@ -140,13 +141,12 @@ void conf_parse_events(svc_t *svc, char *events)
i++;
ptr[i] = 0;
if (i >= sizeof(svc->events)) {
if (i >= sizeof(svc->cond)) {
FLOG_WARN("Too long event list in declaration of %s: %s", svc->cmd, ptr);
return;
}
svc->state = SVC_CONDHALT_STATE;
strlcpy(svc->events, ptr, sizeof(svc->events));
strlcpy(svc->cond, ptr, sizeof(svc->cond));
}
static void parse_static(char *line)