Skip to content

Commit

Permalink
Try docker stop command, if the stop with DockerClient did not worked.
Browse files Browse the repository at this point in the history
  • Loading branch information
Commifreak committed Aug 15, 2023
1 parent af9f37b commit a257443
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/include/ABHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,14 @@ public static function stopContainer($container) {
$stopTimer = time();
$dockerStopCode = $dockerClient->stopContainer($container['Name']);
if ($dockerStopCode != 1) {
self::backupLog("Error while stopping container! Code: " . $dockerStopCode, self::LOGLEVEL_ERR, true, true);
self::backupLog("Error while stopping container! Code: " . $dockerStopCode . " - trying 'docker stop' method", self::LOGLEVEL_ERR, true, true);
$out = $code = null;
exec("docker stop " . escapeshellarg($container['Name']) . " -t 30", $out, $code);
if ($code == 0) {
self::backupLog("That _seemed_ to work.");
} else {
self::backupLog("docker stop variant was unsuccessful as well! Docker said: " . implode(', ', $out), self::LOGLEVEL_ERR);
}
} else {
self::backupLog("done! (took " . (time() - $stopTimer) . " seconds)", self::LOGLEVEL_INFO, true, true);
}
Expand Down

0 comments on commit a257443

Please sign in to comment.