From 1668a4e8715f1bd277af7bd59f787eb7d6345bf9 Mon Sep 17 00:00:00 2001 From: andryyy Date: Thu, 23 Feb 2017 20:15:27 +0100 Subject: [PATCH] Restart SOGo services with delay and not as group --- data/Dockerfiles/sogo/supervisord.conf | 4 --- data/web/call_sogo_ctrl.php | 36 +++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/data/Dockerfiles/sogo/supervisord.conf b/data/Dockerfiles/sogo/supervisord.conf index 197b240c..a2d32e76 100644 --- a/data/Dockerfiles/sogo/supervisord.conf +++ b/data/Dockerfiles/sogo/supervisord.conf @@ -7,9 +7,6 @@ redirect_stderr=true autostart=true stdout_syslog=true -[group:sogo-group] -programs=reconf-domains,sogo - [program:sogo] command=/usr/sbin/sogod user=sogo @@ -19,7 +16,6 @@ priority=20 [program:reconf-domains] command=/reconf-domains.sh autorestart=true -startsecs=5 priority=10 [program:sogo-syslog] diff --git a/data/web/call_sogo_ctrl.php b/data/web/call_sogo_ctrl.php index c548bd56..4d6dc952 100644 --- a/data/web/call_sogo_ctrl.php +++ b/data/web/call_sogo_ctrl.php @@ -6,7 +6,7 @@ if (!isset($_SESSION['mailcow_cc_role']) OR !in_array($_SESSION['mailcow_cc_role exit(); } if ($_GET['ACTION'] == "start") { - $request = xmlrpc_encode_request("supervisor.startProcessGroup", 'sogo-group', array('encoding'=>'utf-8')); + $request = xmlrpc_encode_request("supervisor.startProcess", 'reconf-domains', array('encoding'=>'utf-8')); $context = stream_context_create(array('http' => array( 'method' => "POST", 'header' => "Content-Length: " . strlen($request), @@ -18,11 +18,25 @@ if ($_GET['ACTION'] == "start") { echo '' . $response['faultString'] . ''; } else { - echo 'OK'; + sleep(4); + $request = xmlrpc_encode_request("supervisor.startProcess", 'sogo', array('encoding'=>'utf-8')); + $context = stream_context_create(array('http' => array( + 'method' => "POST", + 'header' => "Content-Length: " . strlen($request), + 'content' => $request + ))); + $file = @file_get_contents("http://sogo:9191/RPC2", false, $context) or die("Cannot connect to $remote_server:$listener_port"); + $response = xmlrpc_decode($file); + if (isset($response['faultString'])) { + echo '' . $response['faultString'] . ''; + } + else { + echo 'OK'; + } } } elseif ($_GET['ACTION'] == "stop") { - $request = xmlrpc_encode_request("supervisor.stopProcessGroup", 'sogo-group', array('encoding'=>'utf-8')); + $request = xmlrpc_encode_request("supervisor.stopProcess", 'sogo', array('encoding'=>'utf-8')); $context = stream_context_create(array('http' => array( 'method' => "POST", 'header' => "Content-Length: " . strlen($request), @@ -34,7 +48,21 @@ elseif ($_GET['ACTION'] == "stop") { echo '' . $response['faultString'] . ''; } else { - echo 'OK'; + sleep(1); + $request = xmlrpc_encode_request("supervisor.stopProcess", 'reconf-domains', array('encoding'=>'utf-8')); + $context = stream_context_create(array('http' => array( + 'method' => "POST", + 'header' => "Content-Length: " . strlen($request), + 'content' => $request + ))); + $file = @file_get_contents("http://sogo:9191/RPC2", false, $context) or die("Cannot connect to $remote_server:$listener_port"); + $response = xmlrpc_decode($file); + if (isset($response['faultString'])) { + echo '' . $response['faultString'] . ''; + } + else { + echo 'OK'; + } } } ?> \ No newline at end of file