chiark / gitweb /
f9dbfea5e68325cf344a4c09db2a00d3d89a3de0
[elogind.git] / service.h
1 /*-*- Mode: C; c-basic-offset: 8 -*-*/
2
3 #ifndef fooservicehfoo
4 #define fooservicehfoo
5
6 typedef struct Service Service;
7
8 #include "unit.h"
9
10 typedef enum ServiceState {
11         SERVICE_DEAD,
12         SERVICE_START_PRE,
13         SERVICE_START,
14         SERVICE_START_POST,
15         SERVICE_RUNNING,
16         SERVICE_RELOAD,
17         SERVICE_STOP,              /* No STOP_PRE state, instead just register multiple STOP executables */
18         SERVICE_STOP_SIGTERM,
19         SERVICE_STOP_SIGKILL,
20         SERVICE_STOP_POST,
21         SERVICE_FINAL_SIGTERM,     /* In case the STOP_POST executable hangs, we shoot that down, too */
22         SERVICE_FINAL_SIGKILL,
23         SERVICE_MAINTAINANCE,
24         SERVICE_AUTO_RESTART,
25         _SERVICE_STATE_MAX,
26 } ServiceState;
27
28 typedef enum ServiceRestart {
29         SERVICE_ONCE,
30         SERVICE_RESTART_ON_SUCCESS,
31         SERVICE_RESTART_ALWAYS
32 } ServiceRestart;
33
34 typedef enum ServiceType {
35         SERVICE_FORKING,
36         SERVICE_SIMPLE
37 } ServiceType;
38
39 typedef enum ServiceExecCommand {
40         SERVICE_EXEC_START_PRE,
41         SERVICE_EXEC_START,
42         SERVICE_EXEC_START_POST,
43         SERVICE_EXEC_RELOAD,
44         SERVICE_EXEC_STOP,
45         SERVICE_EXEC_STOP_POST,
46         _SERVICE_EXEC_MAX
47 } ServiceExecCommand;
48
49 struct Service {
50         Meta meta;
51
52         ServiceType type;
53         ServiceRestart restart;
54
55         /* If set we'll read the main daemon PID from this file */
56         char *pid_file;
57
58         usec_t restart_usec;
59         usec_t timeout_usec;
60
61         ExecCommand* exec_command[_SERVICE_EXEC_MAX];
62         ExecContext exec_context;
63
64         ServiceState state;
65
66         ExecStatus main_exec_status;
67
68         ExecCommand *control_command;
69         pid_t main_pid, control_pid;
70         bool main_pid_known:1;
71
72         bool failure:1; /* if we shut down, remember why */
73         Watch timer_watch;
74 };
75
76 const UnitVTable service_vtable;
77
78 #endif