-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
161 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
# `pitchfork stop` | ||
|
||
- **Usage**: `pitchfork stop <ID>` | ||
- **Usage**: `pitchfork stop [ID]...` | ||
- **Aliases**: `kill` | ||
|
||
Sends a stop signal to a daemon | ||
|
||
## Arguments | ||
|
||
### `<ID>` | ||
### `[ID]...` | ||
|
||
The name of the daemon to stop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
[daemons] | ||
[daemons.docs] | ||
run = "mise run docs" | ||
auto = ["start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,33 @@ | ||
use crate::cli::supervisor::kill_or_stop; | ||
use crate::state_file::StateFile; | ||
use crate::Result; | ||
use miette::ensure; | ||
|
||
/// Sends a stop signal to a daemon | ||
#[derive(Debug, clap::Args)] | ||
#[clap(visible_alias = "kill", verbatim_doc_comment)] | ||
pub struct Stop { | ||
/// The name of the daemon to stop | ||
id: String, | ||
id: Vec<String>, | ||
} | ||
|
||
impl Stop { | ||
pub async fn run(&self) -> Result<()> { | ||
ensure!( | ||
!self.id.is_empty(), | ||
"You must provide at least one daemon to stop" | ||
); | ||
let pid_file = StateFile::get(); | ||
if let Some(d) = pid_file.daemons.get(&self.id) { | ||
if let Some(pid) = d.pid { | ||
info!("stopping {} with pid {}", self.id, pid); | ||
kill_or_stop(pid, true).await?; | ||
return Ok(()); | ||
for id in &self.id { | ||
if let Some(d) = pid_file.daemons.get(id) { | ||
if let Some(pid) = d.pid { | ||
info!("stopping {} with pid {}", id, pid); | ||
kill_or_stop(pid, true).await?; | ||
continue; | ||
} | ||
} | ||
warn!("{} is not running", id); | ||
} | ||
warn!("{} is not running", self.id); | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.