From 3453e3df7c9225f9c35a0d6d183a5a2b7e866931 Mon Sep 17 00:00:00 2001 From: phk Date: Sun, 20 Aug 2006 13:38:34 +0000 Subject: [PATCH] Make autostart a tweakable parameter, this is useful for debugging git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@846 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/heritage.h | 3 +++ varnish-cache/bin/varnishd/mgt_child.c | 4 +++- varnish-cache/bin/varnishd/mgt_param.c | 25 ++++++++++++++++++++++++- varnish-cache/bin/varnishd/varnishd.c | 1 + 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/varnish-cache/bin/varnishd/heritage.h b/varnish-cache/bin/varnishd/heritage.h index b9019f34..2f57f69f 100644 --- a/varnish-cache/bin/varnishd/heritage.h +++ b/varnish-cache/bin/varnishd/heritage.h @@ -43,6 +43,9 @@ struct params { /* Acceptor hints */ unsigned sess_timeout; unsigned send_timeout; + + /* Management hints */ + unsigned auto_restart; }; extern struct params *params; diff --git a/varnish-cache/bin/varnishd/mgt_child.c b/varnish-cache/bin/varnishd/mgt_child.c index f52e64b5..2857f258 100644 --- a/varnish-cache/bin/varnishd/mgt_child.c +++ b/varnish-cache/bin/varnishd/mgt_child.c @@ -247,8 +247,10 @@ mgt_sigchld(struct ev *e, int what) child_fds[0] = -1; fprintf(stderr, "Child cleaned\n"); - if (child_state == CH_DIED) + if (child_state == CH_DIED && params->auto_restart) start_child(); + else if (child_state == CH_DIED) + child_state = CH_STOPPED; else if (child_state == CH_STOPPING) child_state = CH_STOPPED; return (0); diff --git a/varnish-cache/bin/varnishd/mgt_param.c b/varnish-cache/bin/varnishd/mgt_param.c index 1ef7569d..31d31297 100644 --- a/varnish-cache/bin/varnishd/mgt_param.c +++ b/varnish-cache/bin/varnishd/mgt_param.c @@ -160,6 +160,26 @@ tweak_send_timeout(struct cli *cli, struct parspec *par, const char *arg) /*--------------------------------------------------------------------*/ +static void +tweak_auto_restart(struct cli *cli, struct parspec *par, const char *arg) +{ + unsigned u; + + (void)par; + if (arg != NULL) { + u = strtoul(arg, NULL, 0); + if (u != 0 && u != 1) { + cli_out(cli, "Only zero and one allowed.\n"); + cli_result(cli, CLIS_PARAM); + return; + } + params->auto_restart = u; + } + cli_out(cli, "%u {1 = yes, 0 = no}\n", params->auto_restart); +} + +/*--------------------------------------------------------------------*/ + /* * Make sure to end all lines with either a space or newline of the * formatting will go haywire. @@ -221,7 +241,10 @@ static struct parspec parspec[] = { DELAYED_EFFECT "See getopt(3) under SO_SNDTIMEO for more information.\n" "Default is 600 seconds. " }, - + { "auto_restart", tweak_auto_restart, + "Restart child process automatically if it dies. " + "1 = yes, 0 = no.\n" + "Default is 1. " }, { NULL, NULL, NULL } }; diff --git a/varnish-cache/bin/varnishd/varnishd.c b/varnish-cache/bin/varnishd/varnishd.c index b41dc672..8e079e5d 100644 --- a/varnish-cache/bin/varnishd/varnishd.c +++ b/varnish-cache/bin/varnishd/varnishd.c @@ -341,6 +341,7 @@ main(int argc, char *argv[]) params->mem_workspace = 4096; params->sess_timeout = 15; params->send_timeout = 600; + params->auto_restart = 1; while ((o = getopt(argc, argv, "b:df:h:p:s:t:T:Vw:")) != -1) switch (o) { -- 2.39.5