Skip to content

Add systemd readiness and stopping notifications - #151

Merged
benthecarman merged 1 commit into
lightningdevkit:mainfrom
benthecarman:systemd
Mar 17, 2026
Merged

benthecarman merged 1 commit into
lightningdevkit:mainfrom
benthecarman:systemd

Conversation

@benthecarman

@benthecarman benthecarman commented Mar 15, 2026 •

Copy link
Copy Markdown
Collaborator

If NOTIFY_SOCKET is set, send READY=1 and STOPPING=1 to systemd. This enables proper dependency ordering and faster startup detection when running as a Type=notify service unit.

Noticed this when deploying my own mainnet ldk-server on my server

@ldk-reviews-bot

ldk-reviews-bot commented Mar 15, 2026 •

Copy link
Copy Markdown

👋 Thanks for assigning @joostjager as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

Comment thread ldk-server/src/util/systemd.rs Outdated
// systemd sets NOTIFY_SOCKET to either a filesystem path (e.g. /run/systemd/notify)
// or an abstract socket prefixed with '@'. Abstract sockets require special addressing.
let result = if let Some(abstract_name) = socket_path.strip_prefix('@') {
use std::os::linux::net::SocketAddrExt;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Top of file uses?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still a fully qualified name below, but I guess in the claude-era we don't care as much anymore...

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally i would care but since all the logic is gated behind the linux flag, it gets pretty ugly having to gate all the imports as well

},
};

// systemd sets NOTIFY_SOCKET to either a filesystem path (e.g. /run/systemd/notify)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you manually test both socket types?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

If NOTIFY_SOCKET is set, send READY=1 and STOPPING=1 to systemd.
This enables proper dependency ordering and faster startup
detection when running as a Type=notify service unit.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@benthecarman
benthecarman merged commit cea6cfb into lightningdevkit:main Mar 17, 2026
7 checks passed
@benthecarman
benthecarman deleted the systemd branch March 17, 2026 16:04
@benthecarman benthecarman self-assigned this Mar 19, 2026
rsafier pushed a commit to rsafier/ldk-server that referenced this pull request Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants