mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 02:11:53 +00:00
add sigterm-timeout (#951)
This commit is contained in:
@@ -15,7 +15,7 @@ use tracing::instrument;
|
||||
use crate::context::RpcContext;
|
||||
use crate::id::{Id, ImageId};
|
||||
use crate::s9pk::manifest::{PackageId, SYSTEM_PACKAGE_ID};
|
||||
use crate::util::serde::IoFormat;
|
||||
use crate::util::serde::{Duration as SerdeDuration, IoFormat};
|
||||
use crate::util::Version;
|
||||
use crate::volume::{VolumeId, Volumes};
|
||||
use crate::{Error, ResultExt, HOST_IP};
|
||||
@@ -39,6 +39,8 @@ pub struct DockerAction {
|
||||
pub inject: bool,
|
||||
#[serde(default)]
|
||||
pub shm_size_mb: Option<usize>, // TODO: use postfix sizing? like 1k vs 1m vs 1g
|
||||
#[serde(default)]
|
||||
pub sigterm_timeout: Option<SerdeDuration>,
|
||||
}
|
||||
impl DockerAction {
|
||||
#[instrument(skip(ctx, input))]
|
||||
@@ -100,7 +102,12 @@ impl DockerAction {
|
||||
.with_kind(crate::ErrorKind::Docker)?;
|
||||
}
|
||||
|
||||
tokio::time::sleep(Duration::from_secs(30)).await;
|
||||
tokio::time::sleep(
|
||||
self.sigterm_timeout
|
||||
.map(|a| *a)
|
||||
.unwrap_or(Duration::from_secs(30)),
|
||||
)
|
||||
.await;
|
||||
|
||||
if let Some(id) = id {
|
||||
signal::kill(Pid::from_raw(id as i32), signal::SIGKILL)
|
||||
|
||||
@@ -19,7 +19,7 @@ use torut::onion::TorSecretKeyV3;
|
||||
use tracing::instrument;
|
||||
|
||||
use crate::action::docker::DockerAction;
|
||||
use crate::action::NoOutput;
|
||||
use crate::action::{ActionImplementation, NoOutput};
|
||||
use crate::context::RpcContext;
|
||||
use crate::manager::sync::synchronizer;
|
||||
use crate::net::interface::InterfaceId;
|
||||
@@ -384,7 +384,15 @@ impl Manager {
|
||||
.docker
|
||||
.stop_container(
|
||||
&self.shared.container_name,
|
||||
Some(StopContainerOptions { t: 30 }),
|
||||
Some(StopContainerOptions {
|
||||
t: match &self.shared.manifest.main {
|
||||
ActionImplementation::Docker(a) => a,
|
||||
}
|
||||
.sigterm_timeout
|
||||
.map(|a| *a)
|
||||
.unwrap_or(Duration::from_secs(30))
|
||||
.as_secs_f64() as i64,
|
||||
}),
|
||||
)
|
||||
.await
|
||||
{
|
||||
@@ -505,7 +513,18 @@ async fn stop(shared: &ManagerSharedState) -> Result<(), Error> {
|
||||
match shared
|
||||
.ctx
|
||||
.docker
|
||||
.stop_container(&shared.container_name, Some(StopContainerOptions { t: 30 }))
|
||||
.stop_container(
|
||||
&shared.container_name,
|
||||
Some(StopContainerOptions {
|
||||
t: match &shared.manifest.main {
|
||||
ActionImplementation::Docker(a) => a,
|
||||
}
|
||||
.sigterm_timeout
|
||||
.map(|a| *a)
|
||||
.unwrap_or(Duration::from_secs(30))
|
||||
.as_secs_f64() as i64,
|
||||
}),
|
||||
)
|
||||
.await
|
||||
{
|
||||
Err(bollard::errors::Error::DockerResponseNotFoundError { .. })
|
||||
|
||||
Reference in New Issue
Block a user