]> err.no Git - varnish/commitdiff
Make autostart a tweakable parameter, this is useful for debugging
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sun, 20 Aug 2006 13:38:34 +0000 (13:38 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sun, 20 Aug 2006 13:38:34 +0000 (13:38 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@846 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/heritage.h
varnish-cache/bin/varnishd/mgt_child.c
varnish-cache/bin/varnishd/mgt_param.c
varnish-cache/bin/varnishd/varnishd.c

index b9019f34a4f58be707b046f001ab7ea7eea4aa87..2f57f69fe5c1e3a3f7825e296075cf83652f04c7 100644 (file)
@@ -43,6 +43,9 @@ struct params {
        /* Acceptor hints */
        unsigned                sess_timeout;
        unsigned                send_timeout;
+
+       /* Management hints */
+       unsigned                auto_restart;
 };
 
 extern struct params *params;
index f52e64b56e25fde9e959d1ac8e7d936c397144da..2857f25840db8b433086449db2ae5f7da2bc13fa 100644 (file)
@@ -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);
index 1ef7569d3fc5a54611542a1a61a80a452f006b3f..31d31297339beb9c233041d86dec0f1e473a9c33 100644 (file)
@@ -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 }
 };
 
index b41dc672efeadc299ae70d7cd01613e64f8dfbc9..8e079e5d47ec180603db12e4554417c600f3ae40 100644 (file)
@@ -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) {