Skip to content

Commit

Permalink
fix: debugging logs
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Dec 12, 2024
1 parent 227dc88 commit f01a243
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docs/cli/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,9 @@
"subcommand_required": true,
"help": "Start, stop, and check the status of the pitchfork supervisor daemon",
"name": "supervisor",
"aliases": [],
"aliases": [
"sup"
],
"hidden_aliases": [],
"examples": []
},
Expand Down
1 change: 1 addition & 0 deletions docs/cli/supervisor.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# `pitchfork supervisor`

- **Usage**: `pitchfork supervisor <SUBCOMMAND>`
- **Aliases**: `sup`

Start, stop, and check the status of the pitchfork supervisor daemon

Expand Down
1 change: 1 addition & 0 deletions pitchfork.usage.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ cmd "stop" help="Sends a stop signal to a daemon" {
arg "[ID]..." help="The name of the daemon to stop" var=true
}
cmd "supervisor" subcommand_required=true help="Start, stop, and check the status of the pitchfork supervisor daemon" {
alias "sup"
cmd "run" help="Runs the internal pitchfork daemon in the foreground" {
flag "-f --force" help="kill existing daemon"
}
Expand Down
1 change: 1 addition & 0 deletions src/cli/supervisor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ mod stop;

/// Start, stop, and check the status of the pitchfork supervisor daemon
#[derive(Debug, clap::Args)]
#[clap(visible_alias = "sup", verbatim_doc_comment)]
pub struct Supervisor {
#[clap(subcommand)]
command: Commands,
Expand Down
1 change: 1 addition & 0 deletions src/procs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ impl Procs {
.unwrap()
.process(sysinfo::Pid::from_u32(pid))
{
debug!("killing process {}", pid);
#[cfg(windows)]
process.kill();
#[cfg(unix)]
Expand Down
8 changes: 8 additions & 0 deletions src/supervisor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,9 @@ impl Supervisor {
async fn stop(&self, id: &str) -> Result<IpcResponse> {
info!("stopping daemon: {id}");
if let Some(daemon) = self.get_daemon(id).await {
trace!("daemon to stop: {daemon}");
if let Some(pid) = daemon.pid {
trace!("killing pid: {pid}");
PROCS.refresh_processes();
if PROCS.is_running(pid) {
self.upsert_daemon(UpsertDaemonOpts {
Expand All @@ -267,9 +269,15 @@ impl Supervisor {
})
.await?;
PROCS.kill_async(pid).await?;
} else {
debug!("pid {pid} not running");
}
return Ok(IpcResponse::Ok);
} else {
debug!("daemon {id} not running");
}
} else {
debug!("daemon {id} not found");
}
Ok(IpcResponse::DaemonAlreadyStopped)
}
Expand Down

0 comments on commit f01a243

Please sign in to comment.