1 /*-*- Mode: C; c-basic-offset: 8 -*-*/
6 typedef struct Service Service;
11 typedef enum ServiceState {
18 SERVICE_STOP, /* No STOP_PRE state, instead just register multiple STOP executables */
22 SERVICE_FINAL_SIGTERM, /* In case the STOP_POST executable hangs, we shoot that down, too */
23 SERVICE_FINAL_SIGKILL,
27 _SERVICE_STATE_INVALID = -1
30 typedef enum ServiceRestart {
32 SERVICE_RESTART_ON_SUCCESS,
33 SERVICE_RESTART_ALWAYS,
35 _SERVICE_RESTART_INVALID = -1
38 typedef enum ServiceType {
39 SERVICE_FORKING, /* forks by itself (i.e. traditional daemons) */
40 SERVICE_SIMPLE, /* we fork and go on right-away (i.e. modern socket activated daemons)*/
41 SERVICE_FINISH, /* we fork and wait until the program finishes (i.e. programs like fsck which run and need to finish before we continue) */
43 _SERVICE_TYPE_INVALID = -1
46 typedef enum ServiceExecCommand {
47 SERVICE_EXEC_START_PRE,
49 SERVICE_EXEC_START_POST,
52 SERVICE_EXEC_STOP_POST,
54 _SERVICE_EXEC_INVALID = -1
61 ServiceRestart restart;
63 /* If set we'll read the main daemon PID from this file */
69 ExecCommand* exec_command[_SERVICE_EXEC_MAX];
70 ExecContext exec_context;
74 ExecStatus main_exec_status;
76 ExecCommand *control_command;
77 pid_t main_pid, control_pid;
78 bool main_pid_known:1;
80 bool failure:1; /* if we shut down, remember why */
86 const UnitVTable service_vtable;
88 const char* service_state_to_string(ServiceState i);
89 ServiceState service_state_from_string(const char *s);
91 const char* service_restart_to_string(ServiceRestart i);
92 ServiceRestart service_restart_from_string(const char *s);
94 const char* service_type_to_string(ServiceType i);
95 ServiceType service_type_from_string(const char *s);
97 const char* service_exec_command_to_string(ServiceExecCommand i);
98 ServiceExecCommand service_exec_command_from_string(const char *s);