mirror of
https://github.com/containers/youki
synced 2024-09-28 07:00:13 +02:00
adds post start hooks
This commit is contained in:
parent
df360ef5c1
commit
ad663d7791
@ -2,11 +2,12 @@
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use anyhow::{bail, Result};
|
||||
use anyhow::{bail, Context, Result};
|
||||
use clap::Clap;
|
||||
use nix::unistd;
|
||||
|
||||
use crate::container::{Container, ContainerStatus};
|
||||
use crate::hooks;
|
||||
use crate::notify_socket::{NotifySocket, NOTIFY_FILE};
|
||||
|
||||
#[derive(Clap, Debug)]
|
||||
@ -39,8 +40,17 @@ impl Start {
|
||||
|
||||
let mut notify_socket = NotifySocket::new(&container.root.join(NOTIFY_FILE));
|
||||
notify_socket.notify_container_start()?;
|
||||
|
||||
container.update_status(ContainerStatus::Running).save()?;
|
||||
|
||||
// Run post start hooks. It runs after the container process is started.
|
||||
// It is called in the Runtime Namespace.
|
||||
let spec_path = container.root.join("config.json");
|
||||
let spec = oci_spec::Spec::load(spec_path).context("failed to load spec")?;
|
||||
if let Some(hooks) = spec.hooks.as_ref() {
|
||||
hooks::run_hooks(hooks.poststart.as_ref(), Some(&container))
|
||||
.with_context(|| "Failed to run post start hooks")?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user