diff --git a/src/conf/proc.rs b/src/conf/proc.rs index 29e066a..33ebbc6 100644 --- a/src/conf/proc.rs +++ b/src/conf/proc.rs @@ -36,7 +36,7 @@ use types::{AccessibleDirectory, AutoRestart, ExecutableFile, HealthCheck, StopS /// Rust representation of the `taskmaster` config. All its types implement /// the `Deserializer` trait. #[allow(unused)] -#[derive(Clone, Debug, Deserialize)] +#[derive(Clone, Debug, Deserialize, PartialEq)] #[serde(deny_unknown_fields)] pub struct ProcessConfig { /// User to spawn the process as. diff --git a/src/conf/proc/types/autorestart.rs b/src/conf/proc/types/autorestart.rs index 4469478..2f2c4ae 100644 --- a/src/conf/proc/types/autorestart.rs +++ b/src/conf/proc/types/autorestart.rs @@ -5,7 +5,7 @@ use serde::{Deserialize, Deserializer}; /// /// Implements the `serde::Deserializer` trait for the `autorestart` field of the configuration. #[allow(unused)] -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq)] pub struct AutoRestart { pub mode: String, pub max_retries: Option, diff --git a/src/conf/proc/types/healthcheck.rs b/src/conf/proc/types/healthcheck.rs index 91e06bb..4d07e5d 100644 --- a/src/conf/proc/types/healthcheck.rs +++ b/src/conf/proc/types/healthcheck.rs @@ -12,14 +12,14 @@ fn dflt_retries() -> usize { 5 } -#[derive(Deserialize, Debug, Clone)] +#[derive(Deserialize, Debug, Clone, PartialEq)] #[serde(untagged)] pub enum HealthCheckType { Command(CommandHealthCheck), Uptime(UptimeHealthCheck), } -#[derive(Deserialize, Debug, Clone)] +#[derive(Deserialize, Debug, Clone, PartialEq)] #[serde(deny_unknown_fields)] pub struct CommandHealthCheck { /// Command to run as a healthcheck. @@ -56,7 +56,7 @@ pub struct CommandHealthCheck { pub timeout: usize, } -#[derive(Deserialize, Debug, Clone)] +#[derive(Deserialize, Debug, Clone, PartialEq)] #[serde(deny_unknown_fields)] pub struct UptimeHealthCheck { /// Time (in seconds) after which the process will be deemed healthy. @@ -68,7 +68,7 @@ pub struct UptimeHealthCheck { } #[allow(unused)] -#[derive(Deserialize, Debug, Clone)] +#[derive(Deserialize, Debug, Clone, PartialEq)] pub struct HealthCheck { /// Inferred from the configured fields. /// diff --git a/src/conf/proc/types/path.rs b/src/conf/proc/types/path.rs index c436e08..1cd3348 100644 --- a/src/conf/proc/types/path.rs +++ b/src/conf/proc/types/path.rs @@ -82,7 +82,7 @@ impl<'de> Deserialize<'de> for AccessibleDirectory { /// /// Implements the `serde::Deserializer` trait for the `cmd` field of the configuration. #[allow(unused)] -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq)] pub struct ExecutableFile { path: String, } @@ -138,7 +138,7 @@ impl<'de> Deserialize<'de> for ExecutableFile { /// /// Implements the `serde::Deserializer` trait for the `stdout` and `stderr` fields of the configuration. #[allow(unused)] -#[derive(Debug, Clone, Default)] +#[derive(Debug, Clone, Default, PartialEq)] pub struct WritableFile { path: String, } diff --git a/src/run/daemon.rs b/src/run/daemon.rs index 3ed2c26..27f5b8d 100644 --- a/src/run/daemon.rs +++ b/src/run/daemon.rs @@ -166,6 +166,9 @@ impl Daemon { for (process_name_new, process_new) in daemon_new.processes_mut().drain() { match self.processes_mut().get_mut(&process_name_new.to_owned()) { Some(process_old) => { + if process_old.config() != process_new.config() { + process_old.push_desired_state(ProcessState::Stopped); + } *process_old.config_mut() = process_new.config().clone(); match process_old.config().autostart() {