Added an optional timeout_seconds parameter to stopContainer
Some checks failed
Build & Upload tux-dock / build (push) Has been cancelled

This commit is contained in:
mrkmntal 2026-08-28 22:46:44 -04:00
commit 442ad330ae
4 changed files with 37 additions and 10 deletions

View file

@ -157,8 +157,12 @@ bool DockerManager::deleteImage(const std::string& id, std::string& message) con
return true;
}
bool DockerManager::stopContainer(const std::string& id, std::string& message) const {
const auto stop_request = [this, &id] { return engine_.request("POST", "/containers/" + id + "/stop"); };
bool DockerManager::stopContainer(const std::string& id,
std::string& message,
int timeout_seconds) const {
const auto stop_request = [this, &id, timeout_seconds] {
return engine_.request("POST", "/containers/" + id + "/stop?t=" + std::to_string(timeout_seconds));
};
const auto acceptable = [](const EngineResponse& response) {
return response.status_code == 204 || response.status_code == 304 || response.status_code == 404 || response.ok();
};

View file

@ -38,7 +38,9 @@ public:
std::string& message) const;
bool startDetached(const std::string& containerId, std::string& message) const;
bool deleteImage(const std::string& imageId, std::string& message) const;
bool stopContainer(const std::string& containerId, std::string& message) const;
bool stopContainer(const std::string& containerId,
std::string& message,
int timeout_seconds = 10) const;
bool removeContainer(const std::string& containerId, std::string& message) const;
bool execShell(const std::string& containerId, std::string& message) const;
bool execDetachedCommand(const std::string& containerId,