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