src/server/daemon/main.c

changeset 179
ef6827505bd2
parent 158
77f4f0079428
child 254
4784c14aa639
--- a/src/server/daemon/main.c	Fri Feb 24 11:17:53 2017 +0100
+++ b/src/server/daemon/main.c	Mon Mar 06 17:32:26 2017 +0100
@@ -39,10 +39,13 @@
 #include "../util/plist.h"
 #include "../util/date.h"
 
+#include "../../ucx/string.h"
+
 #include "webserver.h"
 #include "log.h"
 #include "httprequest.h"
 #include "httplistener.h"
+#include "srvctrl.h"
 
 #include "configmanager.h"
 
@@ -81,7 +84,7 @@
  */
 void sig_term(int sig) {
     webserver_shutdown();
-    exit(EXIT_SUCCESS);
+    //exit(EXIT_SUCCESS);
 }
 
 void* log_pipe_thread(void *data) {
@@ -164,17 +167,22 @@
     int status;
     status = webserver_init();
     if(status != 0) {
-        log_ereport(LOG_FAILURE, "Cannot initialize server.");
+        log_ereport(LOG_FAILURE, "cannot initialize server.");
         return EXIT_FAILURE;
     }
 
     status = webserver_run();
     if(status != 0) {
-        log_ereport(LOG_FAILURE, "Cannot run server.");
+        log_ereport(LOG_FAILURE, "cannot run server.");
         return EXIT_FAILURE;
     }
-     
+    
+    if(srvctrl_wait()) {
+        return EXIT_FAILURE;
+    }
+    
     /* TODO: join threads (or not?) */
+/*
     while(1) {
         if(is_daemon) {
             fflush(stdout);
@@ -185,6 +193,7 @@
             break;
         }
     }
+*/
 
     return EXIT_SUCCESS;
 }

mercurial