diff options
author | deva <deva> | 2010-07-05 09:34:59 +0000 |
---|---|---|
committer | deva <deva> | 2010-07-05 09:34:59 +0000 |
commit | 04168eca33079dd27c60c894a54d76d4bc627c55 (patch) | |
tree | 246360083dfbcfda9d1c525ed283de3b684f66ff | |
parent | 59ff1aa927164b41a53cf78964b9bd6545bd7292 (diff) |
Make server able to re-init writing of its log file (for logrotate).
-rw-r--r-- | server/src/pracrod.cc | 24 |
1 files 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); |