chiark / gitweb /
first attempt in implementinging execution logic
[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 "name.h"
9 #include "socket.h"
10 #include "timer.h"
11
12 typedef enum ServiceState {
13         SERVICE_DEAD,
14         SERVICE_START_PRE,
15         SERVICE_START,
16         SERVICE_START_POST,
17         SERVICE_RUNNING,
18         SERVICE_RELOAD_PRE,
19         SERVICE_RELOAD,
20         SERVICE_RELOAD_POST,
21         SERVICE_STOP_PRE,
22         SERVICE_STOP,
23         SERVICE_SIGTERM,
24         SERVICE_SIGKILL,
25         SERVICE_STOP_POST,
26         SERVICE_MAINTAINANCE,
27         _SERVICE_STATE_MAX,
28 } ServiceState;
29
30 typedef enum ServiceMode {
31         SERVICE_ONCE,
32         SERVICE_RESTART
33 } ServiceMode;
34
35 typedef enum ServiceExecCommand {
36         SERVICE_EXEC_START_PRE,
37         SERVICE_EXEC_START,
38         SERVICE_EXEC_START_POST,
39         SERVICE_EXEC_RELOAD_PRE,
40         SERVICE_EXEC_RELOAD,
41         SERVICE_EXEC_RELOAD_POST,
42         SERVICE_EXEC_STOP_PRE,
43         SERVICE_EXEC_STOP,
44         SERVICE_EXEC_STOP_POST,
45         _SERVICE_EXEC_MAX
46 } ServiceExecCommand;
47
48 struct Service {
49         Meta meta;
50
51         ServiceState state;
52         ServiceMode mode;
53
54         ExecCommand* exec_command[_SERVICE_EXEC_MAX];
55         ExecContext exec_context;
56
57         pid_t service_pid, control_pid;
58
59         Socket *socket;
60         Timer *timer;
61 };
62
63 const NameVTable service_vtable;
64
65 #endif