2
0
Fork 0

[angel,tests] implement and use "one-shot" option to not restart crashed workers

This commit is contained in:
Stefan Bühler 2013-05-31 20:47:43 +02:00
parent 64cabac477
commit 38aad8128e
4 changed files with 7 additions and 2 deletions

View File

@ -53,6 +53,8 @@ struct liServer {
liPlugins plugins;
liLog log;
gboolean one_shot; /* don't restart instance if it goes down */
};
struct liInstanceResource {

View File

@ -29,6 +29,7 @@ int main(int argc, char *argv[]) {
gchar const *module_dir = def_module_dir;
gboolean module_resident = FALSE;
gchar const *config_path = NULL;
gboolean one_shot = FALSE; /* don't restart instance */
gboolean res;
int result = 0;
@ -38,6 +39,7 @@ int main(int argc, char *argv[]) {
{ "config", 'c', 0, G_OPTION_ARG_FILENAME, &config_path, "filename/path of the config", "PATH" },
{ "module-dir", 'm', 0, G_OPTION_ARG_STRING, &module_dir, "module directory [default: " DEFAULT_LIBDIR "]", "PATH" },
{ "module-resident", 0, 0, G_OPTION_ARG_NONE, &module_resident, "never unload modules (e.g. for valgrind)", NULL },
{ "one-shot", 'o', 0, G_OPTION_ARG_NONE, &one_shot, "don't restart instance, useful for testing", NULL },
{ "version", 'v', 0, G_OPTION_ARG_NONE, &show_version, "show version and exit", NULL },
{ NULL, 0, 0, 0, NULL, NULL, NULL }
};
@ -78,6 +80,7 @@ int main(int argc, char *argv[]) {
g_thread_init(NULL);
srv = li_server_new(module_dir, module_resident);
srv->one_shot = one_shot;
if (!li_plugins_config_load(srv, config_path)) {
result = -1;

View File

@ -282,7 +282,7 @@ void li_instance_state_reached(liInstance *i, liInstanceState s) {
/* last child died */
if (i->s_dest == LI_INSTANCE_FINISHED) {
i->s_cur = LI_INSTANCE_FINISHED;
} else {
} else if (!i->srv->one_shot) {
instance_spawn(i);
}
break;

View File

@ -189,7 +189,7 @@ class Lighttpd(Service):
else:
self.fork(base.Env.worker, '-m', base.Env.plugindir, '-c', base.Env.lighttpdconf)
else:
self.fork(base.Env.angel, '-m', base.Env.plugindir, '-c', base.Env.angelconf)
self.fork(base.Env.angel, '-o', '-m', base.Env.plugindir, '-c', base.Env.angelconf)
self.waitconnect(base.Env.port)
class FastCGI(Service):