Browse Source

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

personal/stbuehler/wip
Stefan Bühler 8 years ago
parent
commit
38aad8128e
  1. 2
      include/lighttpd/angel_server.h
  2. 3
      src/angel/angel_main.c
  3. 2
      src/angel/angel_server.c
  4. 2
      tests/service.py

2
include/lighttpd/angel_server.h

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

3
src/angel/angel_main.c

@ -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;

2
src/angel/angel_server.c

@ -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;

2
tests/service.py

@ -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):

Loading…
Cancel
Save