From 04168eca33079dd27c60c894a54d76d4bc627c55 Mon Sep 17 00:00:00 2001 From: deva Date: Mon, 5 Jul 2010 09:34:59 +0000 Subject: Make server able to re-init writing of its log file (for logrotate). --- server/src/pracrod.cc | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/server/src/pracrod.cc b/server/src/pracrod.cc index e023bff..64fb538 100644 --- a/server/src/pracrod.cc +++ b/server/src/pracrod.cc @@ -113,16 +113,18 @@ void childwait(int) } } +static FILE *logfp = stderr; +static std::string logfile; + void reload(int) { - int port; - printf("Reload!\n"); - port = configparser->lookup("port"); - configparser->reload(); - - { // Force wake the server process for reinitialization. - TCPSocket socket; - socket.connect("localhost", port); + if(logfp != stderr) { + fclose(logfp); + logfp = fopen(logfile.c_str(), "a"); + if(!logfp) { + fprintf(stderr, "Could not write to logfile: '%s'\n", optarg); + logfp = stderr; + } } } @@ -174,7 +176,6 @@ E0OPPYamkDI/+6Hx2KECQHF9xV1XatyXuFmfRAInK2BtfGY5UIvJaLxVD3Z1+i6q\n\ int main(int argc, char *argv[]) { - static FILE *logfp = stderr; int c; char *configfile = NULL; char *user = NULL; @@ -183,7 +184,6 @@ int main(int argc, char *argv[]) char *xml_basedir = NULL; char *debugstr = NULL; std::string database; - std::string logfile; int option_index = 0; while(1) { @@ -309,8 +309,8 @@ int main(int argc, char *argv[]) } signal(SIGHUP, reload); - signal(SIGCLD, childwait); - if(foreground) signal (SIGINT, ctrl_c); + // signal(SIGCLD, childwait); + signal(SIGINT, ctrl_c); PracroDaemon daemon; daemon.run(user, group, !foreground); -- cgit v1.2.3