changeset 3165:1fe524e211af

New configuration option: "SaveJobs" to specify whether jobs are stored in the database
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 24 Jan 2019 18:24:13 +0100
parents b79ec21747a1
children 6953a4e475b3 b626fefdb507
files NEWS OrthancServer/ServerContext.cpp OrthancServer/ServerContext.h Resources/Configuration.json
diffstat 4 files changed, 34 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Thu Jan 24 18:06:13 2019 +0100
+++ b/NEWS	Thu Jan 24 18:24:13 2019 +0100
@@ -1,6 +1,14 @@
 Pending changes in the mainline
 ===============================
 
+General
+-------
+
+* New configuration option: "SaveJobs" to specify whether jobs are stored in the database
+
+Maintenance
+-----------
+
 * Don't return tags whose group is below 0x0008 in C-FIND SCP answers
 * Fix compatibility with DICOMweb plugin (allow multipart answers over HTTP Keep-Alive)
 * Fix issue #90 (C-Find shall match missing tags to null/empty string)
--- a/OrthancServer/ServerContext.cpp	Thu Jan 24 18:06:13 2019 +0100
+++ b/OrthancServer/ServerContext.cpp	Thu Jan 24 18:24:13 2019 +0100
@@ -196,21 +196,24 @@
 
   void ServerContext::SaveJobsEngine()
   {
-    VLOG(1) << "Serializing the content of the jobs engine";
+    if (saveJobs_)
+    {
+      VLOG(1) << "Serializing the content of the jobs engine";
     
-    try
-    {
-      Json::Value value;
-      jobsEngine_.GetRegistry().Serialize(value);
+      try
+      {
+        Json::Value value;
+        jobsEngine_.GetRegistry().Serialize(value);
 
-      Json::FastWriter writer;
-      std::string serialized = writer.write(value);
+        Json::FastWriter writer;
+        std::string serialized = writer.write(value);
 
-      index_.SetGlobalProperty(GlobalProperty_JobsRegistry, serialized);
-    }
-    catch (OrthancException& e)
-    {
-      LOG(ERROR) << "Cannot serialize the jobs engine: " << e.What();
+        index_.SetGlobalProperty(GlobalProperty_JobsRegistry, serialized);
+      }
+      catch (OrthancException& e)
+      {
+        LOG(ERROR) << "Cannot serialize the jobs engine: " << e.What();
+      }
     }
   }
 
@@ -245,6 +248,7 @@
         new SharedArchive(lock.GetConfiguration().GetUnsignedIntegerParameter("MediaArchiveSize", 1)));
       defaultLocalAet_ = lock.GetConfiguration().GetStringParameter("DicomAet", "ORTHANC");
       jobsEngine_.SetWorkersCount(lock.GetConfiguration().GetUnsignedIntegerParameter("ConcurrentJobs", 2));
+      saveJobs_ = lock.GetConfiguration().GetBooleanParameter("SaveJobs", true);
     }
 
     jobsEngine_.SetThreadSleep(unitTesting ? 20 : 200);
--- a/OrthancServer/ServerContext.h	Thu Jan 24 18:06:13 2019 +0100
+++ b/OrthancServer/ServerContext.h	Thu Jan 24 18:24:13 2019 +0100
@@ -216,6 +216,7 @@
     std::auto_ptr<SharedArchive>  queryRetrieveArchive_;
     std::string defaultLocalAet_;
     OrthancHttpHandler  httpHandler_;
+    bool saveJobs_;
 
   public:
     class DicomCacheLocker : public boost::noncopyable
--- a/Resources/Configuration.json	Thu Jan 24 18:06:13 2019 +0100
+++ b/Resources/Configuration.json	Thu Jan 24 18:24:13 2019 +0100
@@ -443,6 +443,15 @@
   // REST API) and should be avoided for non-developers.
   "JobsHistorySize" : 10,
 
+  // Whether to save the jobs into the Orthanc database. If this
+  // option is set to "true", the pending/running/completed jobs are
+  // automatically reloaded from the database if Orthanc is stopped
+  // then restarted (except if the "--no-jobs" command-line argument
+  // is specified). This option should be set to "false" if multiple
+  // Orthanc servers are using the same database (e.g. if PostgreSQL
+  // or MariaDB/MySQL is used).
+  "SaveJobs" : true,
+
   // Specifies how Orthanc reacts when it receives a DICOM instance
   // whose SOPInstanceUID is already stored. If set to "true", the new
   // instance replaces the old one. If set to "false", the new