# HG changeset patch # User Sebastien Jodogne # Date 1445416469 -7200 # Node ID bc34c69b594a6385ccf694f6cfb1542fffdff613 # Parent 9d8bb6bc28902f3f69ecc1aa19c62adec96acec7 New URI "/tools/shutdown" to stop Orthanc from the REST API diff -r 9d8bb6bc2890 -r bc34c69b594a NEWS --- a/NEWS Tue Oct 20 11:22:50 2015 +0200 +++ b/NEWS Wed Oct 21 10:34:29 2015 +0200 @@ -6,6 +6,7 @@ * "/tools/create-dicom": Support of hierarchical structures (creation of sequences) * "/modify" can insert/modify sequences * "/series/.../ordered-slices" to order the slices of a 2D+t or 3D image +* New URI "/tools/shutdown" to stop Orthanc from the REST API * New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed" Plugins diff -r 9d8bb6bc2890 -r bc34c69b594a OrthancServer/OrthancRestApi/OrthancRestApi.cpp --- a/OrthancServer/OrthancRestApi/OrthancRestApi.cpp Tue Oct 20 11:22:50 2015 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestApi.cpp Wed Oct 21 10:34:29 2015 +0200 @@ -59,11 +59,20 @@ void OrthancRestApi::ResetOrthanc(RestApiPostCall& call) { + OrthancRestApi::GetApi(call).leaveBarrier_ = true; OrthancRestApi::GetApi(call).resetRequestReceived_ = true; call.GetOutput().AnswerBuffer("{}", "application/json"); } + void OrthancRestApi::ShutdownOrthanc(RestApiPostCall& call) + { + OrthancRestApi::GetApi(call).leaveBarrier_ = true; + call.GetOutput().AnswerBuffer("{}", "application/json"); + LOG(WARNING) << "Shutdown request received"; + } + + @@ -99,6 +108,7 @@ OrthancRestApi::OrthancRestApi(ServerContext& context) : context_(context), + leaveBarrier_(false), resetRequestReceived_(false) { RegisterSystem(); @@ -114,6 +124,7 @@ // Auto-generated directories Register("/tools", RestApi::AutoListChildren); Register("/tools/reset", ResetOrthanc); + Register("/tools/shutdown", ShutdownOrthanc); Register("/instances/{id}/frames/{frame}", RestApi::AutoListChildren); } diff -r 9d8bb6bc2890 -r bc34c69b594a OrthancServer/OrthancRestApi/OrthancRestApi.h --- a/OrthancServer/OrthancRestApi/OrthancRestApi.h Tue Oct 20 11:22:50 2015 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestApi.h Wed Oct 21 10:34:29 2015 +0200 @@ -49,6 +49,7 @@ private: ServerContext& context_; + bool leaveBarrier_; bool resetRequestReceived_; void RegisterSystem(); @@ -65,10 +66,17 @@ static void ResetOrthanc(RestApiPostCall& call); + static void ShutdownOrthanc(RestApiPostCall& call); + public: OrthancRestApi(ServerContext& context); - const bool& ResetRequestReceivedFlag() const + const bool& LeaveBarrierFlag() const + { + return leaveBarrier_; + } + + bool IsResetRequestReceived() const { return resetRequestReceived_; } diff -r 9d8bb6bc2890 -r bc34c69b594a OrthancServer/main.cpp --- a/OrthancServer/main.cpp Tue Oct 20 11:22:50 2015 +0200 +++ b/OrthancServer/main.cpp Wed Oct 21 10:34:29 2015 +0200 @@ -476,8 +476,8 @@ context.GetLua().Execute("Initialize"); - Toolbox::ServerBarrier(restApi.ResetRequestReceivedFlag()); - bool restart = restApi.ResetRequestReceivedFlag(); + Toolbox::ServerBarrier(restApi.LeaveBarrierFlag()); + bool restart = restApi.IsResetRequestReceived(); context.GetLua().Execute("Finalize");