Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to allow postrun to only run after a successful HealthCheck #5330

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion components/sup/src/manager/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ pub struct Service {
pub pkg: Pkg,
pub sys: Arc<Sys>,
pub initialized: bool,
pub postrun: bool,
pub user_config_updated: bool,

#[serde(skip_serializing)]
Expand Down Expand Up @@ -186,6 +187,7 @@ impl Service {
fs::svc_hooks_path(&service_group.service()),
),
initialized: false,
postrun: false,
last_election_status: ElectionStatus::None,
needs_reload: false,
needs_reconfiguration: false,
Expand Down Expand Up @@ -259,6 +261,7 @@ impl Service {
} else {
self.needs_reload = false;
self.needs_reconfiguration = false;
self.postrun = false;
}
}

Expand Down Expand Up @@ -680,7 +683,12 @@ impl Service {
}

fn post_run(&mut self) {
if self.postrun {
return;
}
self.postrun = true;
if let Some(ref hook) = self.hooks.post_run {
outputln!(preamble self.service_group, "Execute Postrun hook");
hook.run(
&self.service_group,
&self.pkg,
Expand Down Expand Up @@ -812,9 +820,11 @@ impl Service {
self.initialize();
if self.initialized {
self.start(launcher);
self.post_run();
}
} else {
if !self.postrun && self.health_check == HealthCheck::Ok {
self.post_run();
}
self.check_process();
match self.last_health_check {
Some(last_check) => {
Expand Down Expand Up @@ -902,6 +912,7 @@ impl Service {
}
};
self.last_health_check = Some(Instant::now());
self.health_check=check_result;
self.cache_health_check(check_result);
}

Expand Down