Skip to content

Commit dadb3ff

Browse files
akessonclaude
andauthored
Add pid parameter to on_startup callback (#11)
* Add pid parameter to on_startup callback Exposes the daemon's process ID to the on_startup callback, allowing users to log or register the PID when the daemon starts. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Bump version to 0.10.0 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Fix changelog year to 2026 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent bbd905a commit dadb3ff

4 files changed

Lines changed: 11 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.10.0] - 2026-01-10
9+
10+
### Changed (BREAKING)
11+
12+
- `CommandHandler::on_startup()` now receives `pid: u32` as second parameter
13+
814
## [0.9.0] - 2025-12-29
915

1016
### Changed (BREAKING)

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "daemon-cli"
3-
version = "0.9.0"
3+
version = "0.10.0"
44
edition = "2024"
55

66
[dependencies]

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,10 +421,10 @@ where
421421

422422
/// Called once when the daemon starts, before accepting connections.
423423
///
424-
/// Override this method to log the startup reason or perform
424+
/// Override this method to log the startup reason and PID, or perform
425425
/// initialization that depends on whether this is a fresh start
426426
/// or a restart.
427427
///
428428
/// The default implementation does nothing.
429-
fn on_startup(&self, _reason: StartupReason) {}
429+
fn on_startup(&self, _reason: StartupReason, _pid: u32) {}
430430
}

src/server.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ where
228228
"Daemon started and listening"
229229
);
230230

231-
// Notify handler of startup reason
232-
self.handler.on_startup(self.startup_reason);
231+
// Notify handler of startup reason and PID
232+
self.handler.on_startup(self.startup_reason, pid);
233233

234234
loop {
235235
// Select between accepting connection and shutdown signal

0 commit comments

Comments
 (0)