Mercurial > hg > orthanc
comparison OrthancServer/main.cpp @ 2941:e292798f9980
OrthancConfiguration::SetServerIndex()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 29 Nov 2018 15:16:32 +0100 |
parents | 4767d36679ed |
children | 2e751f615e03 |
comparison
equal
deleted
inserted
replaced
2940:4767d36679ed | 2941:e292798f9980 |
---|---|
1029 << "you can now start Orthanc without the \"--upgrade\" argument"; | 1029 << "you can now start Orthanc without the \"--upgrade\" argument"; |
1030 } | 1030 } |
1031 } | 1031 } |
1032 | 1032 |
1033 | 1033 |
1034 | |
1035 namespace | |
1036 { | |
1037 class ServerContextConfigurator : public boost::noncopyable | |
1038 { | |
1039 private: | |
1040 ServerContext& context_; | |
1041 OrthancPlugins* plugins_; | |
1042 | |
1043 public: | |
1044 ServerContextConfigurator(ServerContext& context, | |
1045 OrthancPlugins* plugins) : | |
1046 context_(context), | |
1047 plugins_(plugins) | |
1048 { | |
1049 { | |
1050 OrthancConfiguration::WriterLock lock; | |
1051 lock.GetConfiguration().SetServerIndex(context.GetIndex()); | |
1052 } | |
1053 | |
1054 #if ORTHANC_ENABLE_PLUGINS == 1 | |
1055 if (plugins_ != NULL) | |
1056 { | |
1057 plugins_->SetServerContext(context_); | |
1058 context_.SetPlugins(*plugins_); | |
1059 } | |
1060 #endif | |
1061 } | |
1062 | |
1063 ~ServerContextConfigurator() | |
1064 { | |
1065 { | |
1066 OrthancConfiguration::WriterLock lock; | |
1067 lock.GetConfiguration().ResetServerIndex(); | |
1068 } | |
1069 | |
1070 #if ORTHANC_ENABLE_PLUGINS == 1 | |
1071 if (plugins_ != NULL) | |
1072 { | |
1073 plugins_->ResetServerContext(); | |
1074 context_.ResetPlugins(); | |
1075 } | |
1076 #endif | |
1077 } | |
1078 }; | |
1079 } | |
1080 | |
1081 | |
1034 static bool ConfigureServerContext(IDatabaseWrapper& database, | 1082 static bool ConfigureServerContext(IDatabaseWrapper& database, |
1035 IStorageArea& storageArea, | 1083 IStorageArea& storageArea, |
1036 OrthancPlugins *plugins, | 1084 OrthancPlugins *plugins, |
1037 bool loadJobsFromDatabase) | 1085 bool loadJobsFromDatabase) |
1038 { | 1086 { |
1079 | 1127 |
1080 context.GetJobsEngine().GetRegistry().SetMaxCompletedJobs | 1128 context.GetJobsEngine().GetRegistry().SetMaxCompletedJobs |
1081 (lock.GetConfiguration().GetUnsignedIntegerParameter("JobsHistorySize", 10)); | 1129 (lock.GetConfiguration().GetUnsignedIntegerParameter("JobsHistorySize", 10)); |
1082 } | 1130 } |
1083 | 1131 |
1084 | 1132 { |
1085 #if ORTHANC_ENABLE_PLUGINS == 1 | 1133 ServerContextConfigurator configurator(context, plugins); |
1086 if (plugins) | 1134 return ConfigureHttpHandler(context, plugins, loadJobsFromDatabase); |
1087 { | 1135 } |
1088 plugins->SetServerContext(context); | |
1089 context.SetPlugins(*plugins); | |
1090 } | |
1091 #endif | |
1092 | |
1093 bool restart = false; | |
1094 ErrorCode error = ErrorCode_Success; | |
1095 | |
1096 try | |
1097 { | |
1098 restart = ConfigureHttpHandler(context, plugins, loadJobsFromDatabase); | |
1099 } | |
1100 catch (OrthancException& e) | |
1101 { | |
1102 error = e.GetErrorCode(); | |
1103 } | |
1104 | |
1105 #if ORTHANC_ENABLE_PLUGINS == 1 | |
1106 if (plugins) | |
1107 { | |
1108 plugins->ResetServerContext(); | |
1109 context.ResetPlugins(); | |
1110 } | |
1111 #endif | |
1112 | |
1113 if (error != ErrorCode_Success) | |
1114 { | |
1115 throw OrthancException(error); | |
1116 } | |
1117 | |
1118 return restart; | |
1119 } | 1136 } |
1120 | 1137 |
1121 | 1138 |
1122 static bool ConfigureDatabase(IDatabaseWrapper& database, | 1139 static bool ConfigureDatabase(IDatabaseWrapper& database, |
1123 IStorageArea& storageArea, | 1140 IStorageArea& storageArea, |