comparison OrthancServer/main.cpp @ 2671:06c0a6b8a871 jobs

new command-line argument: --no-jobs
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 11 Jun 2018 09:20:04 +0200
parents 389d050a2e66
children 83c991aeb611
comparison
equal deleted inserted replaced
2670:c5646f766b3e 2671:06c0a6b8a871
486 << " --verbose\t\tbe verbose in logs" << std::endl 486 << " --verbose\t\tbe verbose in logs" << std::endl
487 << " --trace\t\thighest verbosity in logs (for debug)" << std::endl 487 << " --trace\t\thighest verbosity in logs (for debug)" << std::endl
488 << " --upgrade\t\tallow Orthanc to upgrade the version of the" << std::endl 488 << " --upgrade\t\tallow Orthanc to upgrade the version of the" << std::endl
489 << "\t\t\tdatabase (beware that the database will become" << std::endl 489 << "\t\t\tdatabase (beware that the database will become" << std::endl
490 << "\t\t\tincompatible with former versions of Orthanc)" << std::endl 490 << "\t\t\tincompatible with former versions of Orthanc)" << std::endl
491 << " --no-jobs\t\tDon't restart the jobs that were stored during" << std::endl
492 << "\t\t\tthe last execution of Orthanc" << std::endl
491 << " --version\t\toutput version information and exit" << std::endl 493 << " --version\t\toutput version information and exit" << std::endl
492 << std::endl 494 << std::endl
493 << "Exit status:" << std::endl 495 << "Exit status:" << std::endl
494 << " 0 if success," << std::endl 496 << " 0 if success," << std::endl
495 #if defined(_WIN32) 497 #if defined(_WIN32)
954 } 956 }
955 957
956 958
957 static bool ConfigureServerContext(IDatabaseWrapper& database, 959 static bool ConfigureServerContext(IDatabaseWrapper& database,
958 IStorageArea& storageArea, 960 IStorageArea& storageArea,
959 OrthancPlugins *plugins) 961 OrthancPlugins *plugins,
962 bool loadJobsFromDatabase)
960 { 963 {
961 // These configuration options must be set before creating the 964 // These configuration options must be set before creating the
962 // ServerContext, otherwise the possible Lua scripts will not be 965 // ServerContext, otherwise the possible Lua scripts will not be
963 // able to properly issue HTTP/HTTPS queries 966 // able to properly issue HTTP/HTTPS queries
964 HttpClient::ConfigureSsl(Configuration::GetGlobalBoolParameter("HttpsVerifyPeers", true), 967 HttpClient::ConfigureSsl(Configuration::GetGlobalBoolParameter("HttpsVerifyPeers", true),
967 HttpClient::SetDefaultTimeout(Configuration::GetGlobalUnsignedIntegerParameter("HttpTimeout", 0)); 970 HttpClient::SetDefaultTimeout(Configuration::GetGlobalUnsignedIntegerParameter("HttpTimeout", 0));
968 HttpClient::SetDefaultProxy(Configuration::GetGlobalStringParameter("HttpProxy", "")); 971 HttpClient::SetDefaultProxy(Configuration::GetGlobalStringParameter("HttpProxy", ""));
969 972
970 DicomUserConnection::SetDefaultTimeout(Configuration::GetGlobalUnsignedIntegerParameter("DicomScuTimeout", 10)); 973 DicomUserConnection::SetDefaultTimeout(Configuration::GetGlobalUnsignedIntegerParameter("DicomScuTimeout", 10));
971 974
972 ServerContext context(database, storageArea, false /* not running unit tests */); 975 ServerContext context(database, storageArea, false /* not running unit tests */, loadJobsFromDatabase);
973 context.SetCompressionEnabled(Configuration::GetGlobalBoolParameter("StorageCompression", false)); 976 context.SetCompressionEnabled(Configuration::GetGlobalBoolParameter("StorageCompression", false));
974 context.SetStoreMD5ForAttachments(Configuration::GetGlobalBoolParameter("StoreMD5ForAttachments", true)); 977 context.SetStoreMD5ForAttachments(Configuration::GetGlobalBoolParameter("StoreMD5ForAttachments", true));
975 978
976 try 979 try
977 { 980 {
1038 1041
1039 1042
1040 static bool ConfigureDatabase(IDatabaseWrapper& database, 1043 static bool ConfigureDatabase(IDatabaseWrapper& database,
1041 IStorageArea& storageArea, 1044 IStorageArea& storageArea,
1042 OrthancPlugins *plugins, 1045 OrthancPlugins *plugins,
1043 bool upgradeDatabase) 1046 bool upgradeDatabase,
1047 bool loadJobsFromDatabase)
1044 { 1048 {
1045 database.Open(); 1049 database.Open();
1046 1050
1047 unsigned int currentVersion = database.GetDatabaseVersion(); 1051 unsigned int currentVersion = database.GetDatabaseVersion();
1048 1052
1057 << currentVersion << " to " << ORTHANC_DATABASE_VERSION 1061 << currentVersion << " to " << ORTHANC_DATABASE_VERSION
1058 << ": Please run Orthanc with the \"--upgrade\" argument"; 1062 << ": Please run Orthanc with the \"--upgrade\" argument";
1059 throw OrthancException(ErrorCode_IncompatibleDatabaseVersion); 1063 throw OrthancException(ErrorCode_IncompatibleDatabaseVersion);
1060 } 1064 }
1061 1065
1062 bool success = ConfigureServerContext(database, storageArea, plugins); 1066 bool success = ConfigureServerContext
1067 (database, storageArea, plugins, loadJobsFromDatabase);
1063 1068
1064 database.Close(); 1069 database.Close();
1065 1070
1066 return success; 1071 return success;
1067 } 1072 }
1068 1073
1069 1074
1070 static bool ConfigurePlugins(int argc, 1075 static bool ConfigurePlugins(int argc,
1071 char* argv[], 1076 char* argv[],
1072 bool upgradeDatabase) 1077 bool upgradeDatabase,
1078 bool loadJobsFromDatabase)
1073 { 1079 {
1074 std::auto_ptr<IDatabaseWrapper> databasePtr; 1080 std::auto_ptr<IDatabaseWrapper> databasePtr;
1075 std::auto_ptr<IStorageArea> storage; 1081 std::auto_ptr<IStorageArea> storage;
1076 1082
1077 #if ORTHANC_ENABLE_PLUGINS == 1 1083 #if ORTHANC_ENABLE_PLUGINS == 1
1102 } 1108 }
1103 1109
1104 assert(database != NULL); 1110 assert(database != NULL);
1105 assert(storage.get() != NULL); 1111 assert(storage.get() != NULL);
1106 1112
1107 return ConfigureDatabase(*database, *storage, &plugins, upgradeDatabase); 1113 return ConfigureDatabase(*database, *storage, &plugins,
1114 upgradeDatabase, loadJobsFromDatabase);
1108 1115
1109 #elif ORTHANC_ENABLE_PLUGINS == 0 1116 #elif ORTHANC_ENABLE_PLUGINS == 0
1110 // The plugins are disabled 1117 // The plugins are disabled
1111 databasePtr.reset(Configuration::CreateDatabaseWrapper()); 1118 databasePtr.reset(Configuration::CreateDatabaseWrapper());
1112 storage.reset(Configuration::CreateStorageArea()); 1119 storage.reset(Configuration::CreateStorageArea());
1113 1120
1114 return ConfigureDatabase(*databasePtr, *storage, NULL, upgradeDatabase); 1121 return ConfigureDatabase(*databasePtr, *storage, NULL,
1122 upgradeDatabase, loadJobsFromDatabase);
1115 1123
1116 #else 1124 #else
1117 # error The macro ORTHANC_ENABLE_PLUGINS must be set to 0 or 1 1125 # error The macro ORTHANC_ENABLE_PLUGINS must be set to 0 or 1
1118 #endif 1126 #endif
1119 } 1127 }
1120 1128
1121 1129
1122 static bool StartOrthanc(int argc, 1130 static bool StartOrthanc(int argc,
1123 char* argv[], 1131 char* argv[],
1124 bool upgradeDatabase) 1132 bool upgradeDatabase,
1125 { 1133 bool loadJobsFromDatabase)
1126 return ConfigurePlugins(argc, argv, upgradeDatabase); 1134 {
1135 return ConfigurePlugins(argc, argv, upgradeDatabase, loadJobsFromDatabase);
1127 } 1136 }
1128 1137
1129 1138
1130 static bool DisplayPerformanceWarning() 1139 static bool DisplayPerformanceWarning()
1131 { 1140 {
1138 int main(int argc, char* argv[]) 1147 int main(int argc, char* argv[])
1139 { 1148 {
1140 Logging::Initialize(); 1149 Logging::Initialize();
1141 1150
1142 bool upgradeDatabase = false; 1151 bool upgradeDatabase = false;
1152 bool loadJobsFromDatabase = true;
1143 const char* configurationFile = NULL; 1153 const char* configurationFile = NULL;
1144 1154
1145 1155
1146 /** 1156 /**
1147 * Parse the command-line options. 1157 * Parse the command-line options.
1227 } 1237 }
1228 } 1238 }
1229 else if (argument == "--upgrade") 1239 else if (argument == "--upgrade")
1230 { 1240 {
1231 upgradeDatabase = true; 1241 upgradeDatabase = true;
1242 }
1243 else if (argument == "--no-jobs")
1244 {
1245 loadJobsFromDatabase = false;
1232 } 1246 }
1233 else if (boost::starts_with(argument, "--config=")) 1247 else if (boost::starts_with(argument, "--config="))
1234 { 1248 {
1235 // TODO WHAT IS THE ENCODING? 1249 // TODO WHAT IS THE ENCODING?
1236 std::string configurationSample; 1250 std::string configurationSample;
1291 { 1305 {
1292 for (;;) 1306 for (;;)
1293 { 1307 {
1294 OrthancInitialize(configurationFile); 1308 OrthancInitialize(configurationFile);
1295 1309
1296 bool restart = StartOrthanc(argc, argv, upgradeDatabase); 1310 bool restart = StartOrthanc(argc, argv, upgradeDatabase, loadJobsFromDatabase);
1297 if (restart) 1311 if (restart)
1298 { 1312 {
1299 OrthancFinalize(); 1313 OrthancFinalize();
1300 LOG(WARNING) << "Logging system is resetting"; 1314 LOG(WARNING) << "Logging system is resetting";
1301 Logging::Reset(); 1315 Logging::Reset();