mirror of
https://github.com/watchexec/watchexec.git
synced 2024-09-29 22:51:33 +02:00
Simplify on_update code further
This commit is contained in:
parent
d25c374d7f
commit
e08f1934ec
15
src/run.rs
15
src/run.rs
@ -229,33 +229,34 @@ impl Handler for ExecHandler {
|
|||||||
|
|
||||||
// Only returns Err() on lock poisoning.
|
// Only returns Err() on lock poisoning.
|
||||||
fn on_update(&self, ops: &[PathOp]) -> Result<bool> {
|
fn on_update(&self, ops: &[PathOp]) -> Result<bool> {
|
||||||
|
let signal = self.signal.unwrap_or(Signal::SIGTERM);
|
||||||
|
|
||||||
match (
|
match (
|
||||||
self.has_running_process(),
|
self.has_running_process(),
|
||||||
self.args.on_busy_update,
|
self.args.on_busy_update,
|
||||||
self.signal,
|
|
||||||
) {
|
) {
|
||||||
// If nothing is running, start the command
|
// If nothing is running, start the command
|
||||||
(false, _, _) => {
|
(false, _) => {
|
||||||
self.spawn(ops)?;
|
self.spawn(ops)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Just send a signal to the command, do nothing more
|
// Just send a signal to the command, do nothing more
|
||||||
(true, OnBusyUpdate::Signal, signal) => signal_process(&self.child_process, signal.unwrap_or(Signal::SIGTERM)),
|
(true, OnBusyUpdate::Signal) => signal_process(&self.child_process, signal),
|
||||||
|
|
||||||
// Send a signal to the command, wait for it to exit, then run the command again
|
// Send a signal to the command, wait for it to exit, then run the command again
|
||||||
(true, OnBusyUpdate::Restart, signal) => {
|
(true, OnBusyUpdate::Restart) => {
|
||||||
signal_process(&self.child_process, signal.unwrap_or(Signal::SIGTERM));
|
signal_process(&self.child_process, signal);
|
||||||
wait_on_process(&self.child_process);
|
wait_on_process(&self.child_process);
|
||||||
self.spawn(ops)?;
|
self.spawn(ops)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for the command to end, then run it again
|
// Wait for the command to end, then run it again
|
||||||
(true, OnBusyUpdate::Queue, _) => {
|
(true, OnBusyUpdate::Queue) => {
|
||||||
wait_on_process(&self.child_process);
|
wait_on_process(&self.child_process);
|
||||||
self.spawn(ops)?;
|
self.spawn(ops)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
(true, OnBusyUpdate::DoNothing, _) => {}
|
(true, OnBusyUpdate::DoNothing) => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle once option for integration testing
|
// Handle once option for integration testing
|
||||||
|
Loading…
Reference in New Issue
Block a user