]> git.stg.codes - stg.git/blobdiff - projects/stargazer/main.cpp
Ticket 26. The 'settings' parametr added in the manager.reload() method.
[stg.git] / projects / stargazer / main.cpp
index 3db3b2669ede87b264d6c417108e2fb35342f6bc..b878b39c41cf5ca146a81ce7712fb3f1e7c4c684 100644 (file)
@@ -66,7 +66,7 @@ namespace
 std::set<pid_t> executers;
 
 void StartTimer();
-int StartScriptExecuter(char * procName, int msgKey, int * msgID, SETTINGS_IMPL * settings);
+int StartScriptExecuter(char * procName, int msgKey, int * msgID);
 int ForkAndWait(const std::string & confDir);
 void KillExecuters();
 
@@ -89,9 +89,9 @@ else
 }
 //-----------------------------------------------------------------------------
 #if defined(LINUX) || defined(DARWIN)
-int StartScriptExecuter(char * procName, int msgKey, int * msgID, SETTINGS_IMPL * settings)
+int StartScriptExecuter(char * procName, int msgKey, int * msgID)
 #else
-int StartScriptExecuter(char *, int msgKey, int * msgID, SETTINGS_IMPL * settings)
+int StartScriptExecuter(char *, int msgKey, int * msgID)
 #endif
 {
 STG_LOGGER & WriteServLog = GetStgLogger();
@@ -132,7 +132,6 @@ switch (pid)
         return -1;
 
     case 0:
-        delete settings;
 #if defined(LINUX) || defined(DARWIN)
         Executer(*msgID, pid, procName);
 #else
@@ -251,7 +250,7 @@ WriteServLog("Stg v. %s", SERVER_VERSION);
 
 for (size_t i = 0; i < settings.GetExecutersNum(); i++)
     {
-    int ret = StartScriptExecuter(argv[0], settings.GetExecMsgKey(), &msgID, &settings);
+    int ret = StartScriptExecuter(argv[0], settings.GetExecMsgKey(), &msgID);
     if (ret < 0)
         {
         STG_LOGGER & WriteServLog = GetStgLogger();
@@ -339,8 +338,22 @@ while (running)
     switch (sig)
         {
         case SIGHUP:
+            {
+            SETTINGS_IMPL newSettings(settings);
+            if (newSettings.ReadSettings())
+                {
+                STG_LOGGER & WriteServLog = GetStgLogger();
+
+                if (newSettings.GetLogFileName() != "")
+                    WriteServLog.SetLogFileName(newSettings.GetLogFileName());
+
+                WriteServLog("ReadSettings error. %s", newSettings.GetStrError().c_str());
+                return -1;
+                }
+            settings = newSettings;
             traffCnt.Reload();
-            manager.reload();
+            manager.reload(settings);
+            }
             break;
         case SIGTERM:
             running = false;