aboutsummaryrefslogtreecommitdiff
path: root/src/pies.h
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2019-05-24 12:45:25 +0300
committerSergey Poznyakoff <gray@gnu.org>2019-05-24 13:50:39 +0300
commit6dd0ec08db301984b8f8f9082f28006d5915c183 (patch)
treee916ad37fbd3cbcaf85103667f28e0d47f3c2e45 /src/pies.h
parent2a646ee7cbbcb6f4bbd8f38bb3c1e1418550f3fc (diff)
downloadpies-6dd0ec08db301984b8f8f9082f28006d5915c183.tar.gz
pies-6dd0ec08db301984b8f8f9082f28006d5915c183.tar.bz2
Initial implementation of "startup" components.
These are components that are run at program startup. Starting other components is delayed until all startup components terminate. This is similar to SysV "bootwait" components. Upon termination, startup components are removed from the configuration. They are not renewed upon configuratuion reload. * src/comp.c (comp_array_remove): Remove from the depmap as well. (component_ref_decr): Use comp_array_remove for active components and plain component_free for inactive ones. (component_build_depmap): Use comp_array_remove. (component_config_commit): Special handling for pies_comp_startup components. * src/pies.c (modetab): New component modes: "startup" and "shutdown". (main): Run program_init_startup. * src/pies.h (pies_comp_mode): New modes: pies_comp_startup and pies_comp_shutdown. (program_init_startup): New proto. * src/progman.c (progman_waiting_p): Return 1 if a startup component is still running. (program_init_startup): New function. (progman_cleanup): Handle pies_comp_startup termination. * src/socket.c (switch_eids): Avoid unnecessary calls to setegid and seteuid. * tests/atlocal.in (auxdir): New variable. * tests/mailer: Move to tests/aux/ * tests/respawn: Move to tests/aux/ * tests/retcode: Move to tests/aux/ * tests/aux/startup: New auxiliary program. * tests/redirect.at: Start components from $auxdir. * tests/respawn.at: Likewise. * tests/ret-exec.at: Likewise. * tests/ret-notify.at: Likewise. * tests/startup.at: New file. * tests/testsuite.at: Include startup.at * tests/Makefile.am: Add new tests.
Diffstat (limited to 'src/pies.h')
-rw-r--r--src/pies.h38
1 files changed, 23 insertions, 15 deletions
diff --git a/src/pies.h b/src/pies.h
index a7f6567..bdc406b 100644
--- a/src/pies.h
+++ b/src/pies.h
@@ -104,7 +104,7 @@ struct action
104 enum return_action act; /* Action to take when the component terminates */ 104 enum return_action act; /* Action to take when the component terminates */
105 char *addr; /* Addresses to notify about it. */ 105 char *addr; /* Addresses to notify about it. */
106 char *message; /* Notification mail. */ 106 char *message; /* Notification mail. */
107 char *command; /* Execute this command */ 107 char *command; /* Execute this command */
108}; 108};
109 109
110 110
@@ -137,14 +137,21 @@ enum pies_comp_mode
137 component via the UNIX domain socket. Corresponds to 137 component via the UNIX domain socket. Corresponds to
138 `start_action = pass' in MeTA1. */ 138 `start_action = pass' in MeTA1. */
139 pies_comp_pass_fd, 139 pies_comp_pass_fd,
140 140
141 /* Components of this type runs once on program startup. Running other
142 components is delayed until the last startup component finishes. */
143 pies_comp_startup,
144
145 /* FIXME: Runs before program termination */
146 pies_comp_shutdown,
147
141 /* 148 /*
142 ** Init-style components 149 ** Init-style components
143 */ 150 */
144 pies_mark_sysvinit, 151 pies_mark_sysvinit,
145 /* Start the process when the specified runlevel is entered and wait 152 /* Start the process when the specified runlevel is entered and wait
146 for its termination */ 153 for its termination */
147 pies_comp_wait = pies_mark_sysvinit, 154 pies_comp_wait = pies_mark_sysvinit,
148 /* Execute the component once, when the specified runlevel is entered */ 155 /* Execute the component once, when the specified runlevel is entered */
149 pies_comp_once, 156 pies_comp_once,
150 /* Execute the component during system boot. Ignore runlevel settings. */ 157 /* Execute the component during system boot. Ignore runlevel settings. */
@@ -162,7 +169,7 @@ enum pies_comp_mode
162 pies_comp_powerokwait, 169 pies_comp_powerokwait,
163 /* Execute the process when SIGINT is delivered, i.e. someone has 170 /* Execute the process when SIGINT is delivered, i.e. someone has
164 pressed the Ctrl+Alt+Del combination. */ 171 pressed the Ctrl+Alt+Del combination. */
165 pies_comp_ctrlaltdel, 172 pies_comp_ctrlaltdel,
166 /* Execute the component when a specified ondemand runlevel is called */ 173 /* Execute the component when a specified ondemand runlevel is called */
167 pies_comp_ondemand, 174 pies_comp_ondemand,
168 /* Execute the component on the system boot. */ 175 /* Execute the component on the system boot. */
@@ -184,16 +191,16 @@ enum pies_comp_mode
184 191
185#define CF_DISABLED 0x001 /* The componenet is disabled */ 192#define CF_DISABLED 0x001 /* The componenet is disabled */
186#define CF_PRECIOUS 0x002 /* The component is precious (should not 193#define CF_PRECIOUS 0x002 /* The component is precious (should not
187 be disabled) */ 194 be disabled) */
188#define CF_WAIT 0x004 /* Wait for the component instance to 195#define CF_WAIT 0x004 /* Wait for the component instance to
189 terminate. */ 196 terminate. */
190#define CF_TCPMUX 0x008 /* A plain TCPMUX service */ 197#define CF_TCPMUX 0x008 /* A plain TCPMUX service */
191#define CF_TCPMUXPLUS 0x010 /* A TCPMUX-plus service, i.e. pies 198#define CF_TCPMUXPLUS 0x010 /* A TCPMUX-plus service, i.e. pies
192 must emit a '+' response before starting 199 must emit a '+' response before starting
193 it */ 200 it */
194#define CF_INTERNAL 0x020 /* An internal inetd service */ 201#define CF_INTERNAL 0x020 /* An internal inetd service */
195#define CF_SOCKENV 0x040 /* Component wants socket information in 202#define CF_SOCKENV 0x040 /* Component wants socket information in
196 the environment */ 203 the environment */
197#define CF_RESOLVE 0x080 /* Resolve IP addresses */ 204#define CF_RESOLVE 0x080 /* Resolve IP addresses */
198#define CF_SIGGROUP 0x100 /* Send signals to the process group */ 205#define CF_SIGGROUP 0x100 /* Send signals to the process group */
199 206
@@ -210,9 +217,9 @@ struct component
210 struct component *prev, *next; /* Components form doubly-linked list. */ 217 struct component *prev, *next; /* Components form doubly-linked list. */
211 int listidx; /* Index of the list. */ 218 int listidx; /* Index of the list. */
212 size_t arridx; /* Index of this component. */ 219 size_t arridx; /* Index of this component. */
213 size_t ref_count; /* Reference count. */ 220 size_t ref_count; /* Reference count. */
214 struct prog *prog; /* Prog associated with this component. */ 221 struct prog *prog; /* Prog associated with this component. */
215 222
216 enum pies_comp_mode mode; 223 enum pies_comp_mode mode;
217 char *tag; /* Entry tag (for diagnostics purposes) */ 224 char *tag; /* Entry tag (for diagnostics purposes) */
218 char *program; /* Program name */ 225 char *program; /* Program name */
@@ -232,7 +239,7 @@ struct component
232 239
233 /* For exec (init) components */ 240 /* For exec (init) components */
234 char *runlevels; 241 char *runlevels;
235 242
236 /* For inetd components */ 243 /* For inetd components */
237 size_t max_rate; /* Maximum number of invocations per minute */ 244 size_t max_rate; /* Maximum number of invocations per minute */
238 size_t max_ip_connections; /* Max. number of connections per IP address */ 245 size_t max_ip_connections; /* Max. number of connections per IP address */
@@ -253,9 +260,9 @@ struct component
253 char *access_denied_message; 260 char *access_denied_message;
254 char *max_instances_message; 261 char *max_instances_message;
255 char *max_ip_connections_message; 262 char *max_ip_connections_message;
256 263
257 /* Redirectors: */ 264 /* Redirectors: */
258 int facility; /* Syslog facility. */ 265 int facility; /* Syslog facility. */
259 struct redirector redir[2]; /* Repeaters for stdout and stderr */ 266 struct redirector redir[2]; /* Repeaters for stdout and stderr */
260 /* Actions to execute on various exit codes: */ 267 /* Actions to execute on various exit codes: */
261 struct grecs_list *act_list; 268 struct grecs_list *act_list;
@@ -334,6 +341,7 @@ int pies_read_config (void);
334int pies_reread_config (void); 341int pies_reread_config (void);
335 342
336void register_prog (struct component *comp); 343void register_prog (struct component *comp);
344void program_init_startup (void);
337int progman_waiting_p (void); 345int progman_waiting_p (void);
338void progman_start (void); 346void progman_start (void);
339void progman_gc (void); 347void progman_gc (void);
@@ -594,7 +602,7 @@ struct sysvinit_request
594#define SYSV_ACCT_BOOT 0 602#define SYSV_ACCT_BOOT 0
595#define SYSV_ACCT_RUNLEVEL 1 603#define SYSV_ACCT_RUNLEVEL 1
596#define SYSV_ACCT_PROC_START 2 604#define SYSV_ACCT_PROC_START 2
597#define SYSV_ACCT_PROC_STOP 3 605#define SYSV_ACCT_PROC_STOP 3
598 606
599void sysvinit_acct (int what, const char *user, const char *id, pid_t pid, 607void sysvinit_acct (int what, const char *user, const char *id, pid_t pid,
600 const char *line); 608 const char *line);

Return to:

Send suggestions and report system problems to the System administrator.