aboutsummaryrefslogtreecommitdiff
path: root/lib/include/service.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/include/service.h')
-rw-r--r--lib/include/service.h33
1 files changed, 26 insertions, 7 deletions
diff --git a/lib/include/service.h b/lib/include/service.h
index 05ab8de..f388f87 100644
--- a/lib/include/service.h
+++ b/lib/include/service.h
@@ -3,6 +3,7 @@
#define SERVICE_H
#include <sys/types.h>
+#include <stdint.h>
typedef struct exec_t {
struct exec_t *next;
@@ -11,6 +12,14 @@ typedef struct exec_t {
} exec_t;
enum {
+ STATE_OFF,
+ STATE_RUNNING,
+ STATE_QUEUED,
+ STATE_COMPLETED,
+ STATE_FAILED,
+};
+
+enum {
/*
Start the service in the background and continue with
other services. The service will eventually terminate.
@@ -44,17 +53,13 @@ enum {
SVC_FLAG_HAS_EXEC = 0x10,
};
+/* persistent service configuration read from disk */
typedef struct service_t {
struct service_t *next;
char *fname; /* source file name */
-
- int type; /* SVC_* service type */
- int target; /* TGT_* service target */
char *desc; /* description string */
char *ctty; /* controlling tty or log file */
- int rspwn_limit; /* maximum respawn count */
- unsigned int flags; /* SVC_FLAG_* bit field */
/* linked list of command lines to execute */
exec_t *exec;
@@ -62,8 +67,13 @@ typedef struct service_t {
char *before; /* services that must be executed later */
char *after; /* services that must be executed first */
- int num_before;
- int num_after;
+ uint32_t num_before;
+ uint32_t num_after;
+
+ uint16_t rspwn_limit; /* maximum respawn count */
+ uint16_t flags; /* SVC_FLAG_* bit field */
+ uint8_t type; /* SVC_* service type */
+ uint8_t target; /* TGT_* service target */
char name[]; /* canonical service name */
} service_t;
@@ -72,6 +82,15 @@ typedef struct {
service_t *targets[TGT_MAX];
} service_list_t;
+/* run time configuration in-memory for managing services */
+typedef struct {
+ service_t *svc; /* the underlying service description */
+ pid_t pid; /* if still running, the pid */
+ uint16_t rspwn_count; /* services respawn counter */
+ uint8_t state; /* what STATE_* the service is currently in */
+ uint8_t status; /* if exited, process exit status */
+} svc_run_data_t;
+
/*
Read a service from a file.
*/