Mercurial > hg > orthanc
diff OrthancServer/main.cpp @ 2010:4dafe2a0d3ab
Support of SIGHUP signal (restart Orthanc only if the configuration files have changed)
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 09 Jun 2016 17:57:47 +0200 |
parents | e2dd40abce72 |
children | bcc575732aef |
line wrap: on
line diff
--- a/OrthancServer/main.cpp Thu Jun 09 17:25:34 2016 +0200 +++ b/OrthancServer/main.cpp Thu Jun 09 17:57:47 2016 +0200 @@ -651,16 +651,34 @@ context.GetLua().Execute("Initialize"); - ServerBarrierEvent event = Toolbox::ServerBarrier(restApi.LeaveBarrierFlag()); - bool restart = restApi.IsResetRequestReceived(); + bool restart; + + for (;;) + { + ServerBarrierEvent event = Toolbox::ServerBarrier(restApi.LeaveBarrierFlag()); + restart = restApi.IsResetRequestReceived(); - if (!restart && - event == ServerBarrierEvent_Reload) - { - printf("RECEIVED SIGHUP\n"); + if (!restart && + event == ServerBarrierEvent_Reload) + { + if (Configuration::HasConfigurationChanged()) + { + LOG(WARNING) << "A SIGHUP signal has been received, resetting Orthanc"; + restart = true; + break; + } + else + { + LOG(WARNING) << "A SIGHUP signal has been received, but is ignored as the configuration has not changed"; + continue; + } + } + else + { + break; + } } - context.GetLua().Execute("Finalize"); #if ORTHANC_PLUGINS_ENABLED == 1