Restart SOGo services with delay and not as group

master
andryyy 2017-02-23 20:15:27 +01:00
parent 3aae8375b4
commit 1668a4e871
2 changed files with 32 additions and 8 deletions

View File

@ -7,9 +7,6 @@ redirect_stderr=true
autostart=true autostart=true
stdout_syslog=true stdout_syslog=true
[group:sogo-group]
programs=reconf-domains,sogo
[program:sogo] [program:sogo]
command=/usr/sbin/sogod command=/usr/sbin/sogod
user=sogo user=sogo
@ -19,7 +16,6 @@ priority=20
[program:reconf-domains] [program:reconf-domains]
command=/reconf-domains.sh command=/reconf-domains.sh
autorestart=true autorestart=true
startsecs=5
priority=10 priority=10
[program:sogo-syslog] [program:sogo-syslog]

View File

@ -6,7 +6,7 @@ if (!isset($_SESSION['mailcow_cc_role']) OR !in_array($_SESSION['mailcow_cc_role
exit(); exit();
} }
if ($_GET['ACTION'] == "start") { 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( $context = stream_context_create(array('http' => array(
'method' => "POST", 'method' => "POST",
'header' => "Content-Length: " . strlen($request), 'header' => "Content-Length: " . strlen($request),
@ -18,11 +18,25 @@ if ($_GET['ACTION'] == "start") {
echo '<b><span class="pull-right text-warning">' . $response['faultString'] . '</span></b>'; echo '<b><span class="pull-right text-warning">' . $response['faultString'] . '</span></b>';
} }
else { else {
echo '<b><span class="pull-right text-success">OK</span></b>'; 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 '<b><span class="pull-right text-warning">' . $response['faultString'] . '</span></b>';
}
else {
echo '<b><span class="pull-right text-success">OK</span></b>';
}
} }
} }
elseif ($_GET['ACTION'] == "stop") { 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( $context = stream_context_create(array('http' => array(
'method' => "POST", 'method' => "POST",
'header' => "Content-Length: " . strlen($request), 'header' => "Content-Length: " . strlen($request),
@ -34,7 +48,21 @@ elseif ($_GET['ACTION'] == "stop") {
echo '<b><span class="pull-right text-warning">' . $response['faultString'] . '</span></b>'; echo '<b><span class="pull-right text-warning">' . $response['faultString'] . '</span></b>';
} }
else { else {
echo '<b><span class="pull-right text-success">OK</span></b>'; 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 '<b><span class="pull-right text-warning">' . $response['faultString'] . '</span></b>';
}
else {
echo '<b><span class="pull-right text-success">OK</span></b>';
}
} }
} }
?> ?>