Use match in execute_hooks
@@ -1005,9 +1005,11 @@ impl Service {
template_update: &TemplateUpdate)
-> bool {
let up = self.check_process();
- if !self.state.initialized() {
- // If the service is not initialized and the process is still running, the Supervisor
- // was restarted and we just have to reattach to the process.
+ match self.state {
+ ServiceState::Uninitialized => {
+ // If the service is not initialized and the process is still running, the
+ // Supervisor was restarted and we just have to reattach to the
+ // process.
if up {
self.reattach(executor);
return false;
@@ -1017,13 +1019,15 @@ impl Service {
self.start(launcher, executor);
self.post_run(executor);
}
- } else {
+ }
+ ServiceState::Initialized => {
// If the service is initialized and the process is not running, the process
// unexpectedly died and needs to be restarted.
if !up || template_update.needs_restart() {
- // TODO (DM): This flag is a hack. We have the `TaskExecutor` here. We could just
- // schedule the `stop` future, but the `Manager` wraps the `stop` future with
- // additional functionality. Can we refactor to make this flag unnecessary?
+ // TODO (DM): This flag is a hack. We have the `TaskExecutor` here. We could
+ // just schedule the `stop` future, but the `Manager` wraps
+ // the `stop` future with additional functionality. Can we
+ // refactor to make this flag unnecessary?
self.needs_restart = true;
return true;
} else if template_update.needs_reconfigure() {
@@ -1032,6 +1036,7 @@ impl Service {
return true;
}
}
+ };
false
}
