]>
Commit | Line | Data |
---|---|---|
5cb5a6ff LP |
1 | /*-*- Mode: C; c-basic-offset: 8 -*-*/ |
2 | ||
3 | #ifndef fooservicehfoo | |
4 | #define fooservicehfoo | |
5 | ||
6 | typedef struct Service Service; | |
7 | ||
87f0e418 | 8 | #include "unit.h" |
5cb5a6ff LP |
9 | |
10 | typedef enum ServiceState { | |
11 | SERVICE_DEAD, | |
12 | SERVICE_START_PRE, | |
13 | SERVICE_START, | |
14 | SERVICE_START_POST, | |
15 | SERVICE_RUNNING, | |
5cb5a6ff | 16 | SERVICE_RELOAD, |
034c6ed7 LP |
17 | SERVICE_STOP, /* No STOP_PRE state, instead just register multiple STOP executables */ |
18 | SERVICE_STOP_SIGTERM, | |
19 | SERVICE_STOP_SIGKILL, | |
5cb5a6ff | 20 | SERVICE_STOP_POST, |
034c6ed7 LP |
21 | SERVICE_FINAL_SIGTERM, /* In case the STOP_POST executable hangs, we shoot that down, too */ |
22 | SERVICE_FINAL_SIGKILL, | |
5cb5a6ff | 23 | SERVICE_MAINTAINANCE, |
034c6ed7 | 24 | SERVICE_AUTO_RESTART, |
5cb5a6ff LP |
25 | _SERVICE_STATE_MAX, |
26 | } ServiceState; | |
27 | ||
034c6ed7 | 28 | typedef enum ServiceRestart { |
5cb5a6ff | 29 | SERVICE_ONCE, |
034c6ed7 LP |
30 | SERVICE_RESTART_ON_SUCCESS, |
31 | SERVICE_RESTART_ALWAYS | |
32 | } ServiceRestart; | |
33 | ||
34 | typedef enum ServiceType { | |
35 | SERVICE_FORKING, | |
36 | SERVICE_SIMPLE | |
37 | } ServiceType; | |
5cb5a6ff LP |
38 | |
39 | typedef enum ServiceExecCommand { | |
40 | SERVICE_EXEC_START_PRE, | |
41 | SERVICE_EXEC_START, | |
42 | SERVICE_EXEC_START_POST, | |
5cb5a6ff | 43 | SERVICE_EXEC_RELOAD, |
5cb5a6ff LP |
44 | SERVICE_EXEC_STOP, |
45 | SERVICE_EXEC_STOP_POST, | |
46 | _SERVICE_EXEC_MAX | |
47 | } ServiceExecCommand; | |
48 | ||
49 | struct Service { | |
50 | Meta meta; | |
51 | ||
034c6ed7 LP |
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; | |
5cb5a6ff LP |
60 | |
61 | ExecCommand* exec_command[_SERVICE_EXEC_MAX]; | |
62 | ExecContext exec_context; | |
63 | ||
034c6ed7 LP |
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; | |
5cb5a6ff | 71 | |
034c6ed7 LP |
72 | bool failure:1; /* if we shut down, remember why */ |
73 | int timer_id; | |
5cb5a6ff LP |
74 | }; |
75 | ||
87f0e418 | 76 | const UnitVTable service_vtable; |
5cb5a6ff LP |
77 | |
78 | #endif |