diff 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
line wrap: on
line diff
--- a/OrthancServer/main.cpp	Sat Jun 09 14:23:54 2018 +0200
+++ b/OrthancServer/main.cpp	Mon Jun 11 09:20:04 2018 +0200
@@ -488,6 +488,8 @@
     << "  --upgrade\t\tallow Orthanc to upgrade the version of the" << std::endl
     << "\t\t\tdatabase (beware that the database will become" << std::endl
     << "\t\t\tincompatible with former versions of Orthanc)" << std::endl
+    << "  --no-jobs\t\tDon't restart the jobs that were stored during" << std::endl
+    << "\t\t\tthe last execution of Orthanc" << std::endl
     << "  --version\t\toutput version information and exit" << std::endl
     << std::endl
     << "Exit status:" << std::endl
@@ -956,7 +958,8 @@
 
 static bool ConfigureServerContext(IDatabaseWrapper& database,
                                    IStorageArea& storageArea,
-                                   OrthancPlugins *plugins)
+                                   OrthancPlugins *plugins,
+                                   bool loadJobsFromDatabase)
 {
   // These configuration options must be set before creating the
   // ServerContext, otherwise the possible Lua scripts will not be
@@ -969,7 +972,7 @@
 
   DicomUserConnection::SetDefaultTimeout(Configuration::GetGlobalUnsignedIntegerParameter("DicomScuTimeout", 10));
 
-  ServerContext context(database, storageArea, false /* not running unit tests */);
+  ServerContext context(database, storageArea, false /* not running unit tests */, loadJobsFromDatabase);
   context.SetCompressionEnabled(Configuration::GetGlobalBoolParameter("StorageCompression", false));
   context.SetStoreMD5ForAttachments(Configuration::GetGlobalBoolParameter("StoreMD5ForAttachments", true));
 
@@ -1040,7 +1043,8 @@
 static bool ConfigureDatabase(IDatabaseWrapper& database,
                               IStorageArea& storageArea,
                               OrthancPlugins *plugins,
-                              bool upgradeDatabase)
+                              bool upgradeDatabase,
+                              bool loadJobsFromDatabase)
 {
   database.Open();
 
@@ -1059,7 +1063,8 @@
     throw OrthancException(ErrorCode_IncompatibleDatabaseVersion);
   }
 
-  bool success = ConfigureServerContext(database, storageArea, plugins);
+  bool success = ConfigureServerContext
+    (database, storageArea, plugins, loadJobsFromDatabase);
 
   database.Close();
 
@@ -1069,7 +1074,8 @@
 
 static bool ConfigurePlugins(int argc, 
                              char* argv[],
-                             bool upgradeDatabase)
+                             bool upgradeDatabase,
+                             bool loadJobsFromDatabase)
 {
   std::auto_ptr<IDatabaseWrapper>  databasePtr;
   std::auto_ptr<IStorageArea>  storage;
@@ -1104,14 +1110,16 @@
   assert(database != NULL);
   assert(storage.get() != NULL);
 
-  return ConfigureDatabase(*database, *storage, &plugins, upgradeDatabase);
+  return ConfigureDatabase(*database, *storage, &plugins,
+                           upgradeDatabase, loadJobsFromDatabase);
 
 #elif ORTHANC_ENABLE_PLUGINS == 0
   // The plugins are disabled
   databasePtr.reset(Configuration::CreateDatabaseWrapper());
   storage.reset(Configuration::CreateStorageArea());
 
-  return ConfigureDatabase(*databasePtr, *storage, NULL, upgradeDatabase);
+  return ConfigureDatabase(*databasePtr, *storage, NULL,
+                           upgradeDatabase, loadJobsFromDatabase);
 
 #else
 #  error The macro ORTHANC_ENABLE_PLUGINS must be set to 0 or 1
@@ -1121,9 +1129,10 @@
 
 static bool StartOrthanc(int argc, 
                          char* argv[],
-                         bool upgradeDatabase)
+                         bool upgradeDatabase,
+                         bool loadJobsFromDatabase)
 {
-  return ConfigurePlugins(argc, argv, upgradeDatabase);
+  return ConfigurePlugins(argc, argv, upgradeDatabase, loadJobsFromDatabase);
 }
 
 
@@ -1140,6 +1149,7 @@
   Logging::Initialize();
 
   bool upgradeDatabase = false;
+  bool loadJobsFromDatabase = true;
   const char* configurationFile = NULL;
 
 
@@ -1230,6 +1240,10 @@
     {
       upgradeDatabase = true;
     }
+    else if (argument == "--no-jobs")
+    {
+      loadJobsFromDatabase = false;
+    }
     else if (boost::starts_with(argument, "--config="))
     {
       // TODO WHAT IS THE ENCODING?
@@ -1293,7 +1307,7 @@
     {
       OrthancInitialize(configurationFile);
 
-      bool restart = StartOrthanc(argc, argv, upgradeDatabase);
+      bool restart = StartOrthanc(argc, argv, upgradeDatabase, loadJobsFromDatabase);
       if (restart)
       {
         OrthancFinalize();