From: Pieter Lexis Date: Thu, 16 Apr 2015 09:00:25 +0000 (+0200) Subject: dnsdist: add --supervised option X-Git-Tag: dnsdist-1.0.0-alpha1~248^2~88^2~10^2~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=505ca3d14d099c10ca2c4e0c1bab3d09bc2b84b9;p=pdns dnsdist: add --supervised option This option allows a supervisor (like systemd, daemontools or supervisord) to keep the process, but we don't open a LUA console. --- diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index fc4a5cf66..d9c1837c1 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -828,6 +828,7 @@ struct vector remotes; bool beDaemon{false}; bool beClient{false}; + bool beSupervised{false}; string command; string config; } g_cmdLine; @@ -858,6 +859,7 @@ try {"command", optional_argument, 0, 'c'}, {"local", required_argument, 0, 'l'}, {"daemon", 0, 0, 'd'}, + {"supervised", 0, 0, 's'}, {"help", 0, 0, 'h'}, {0,0,0,0} }; @@ -889,12 +891,16 @@ try cout<<"-e,--execute cmd Connect to dnsdist and execute 'cmd'\n"; cout<<"-h,--help Display this helpful message\n"; cout<<"-l,--local address Listen on this local address\n"; + cout<<"--supervised Don't open a console, I'm supervised\n"; + cout<<" (use with e.g. systemd and daemontools)\n"; cout<<"\n"; exit(EXIT_SUCCESS); break; case 'l': g_cmdLine.locals.push_back(trim_copy(string(optarg))); break; + case 's': + g_cmdLine.beSupervised=true; case 'v': g_verbose=true; break; @@ -1016,12 +1022,12 @@ try thread stattid(maintThread); - if(!g_cmdLine.beDaemon) { - stattid.detach(); - doConsole(); + if(g_cmdLine.beDaemon || g_cmdLine.beSupervised) { + stattid.join(); } else { - stattid.join(); + stattid.detach(); + doConsole(); } _exit(EXIT_SUCCESS);