sd-notify-cli
v1.1.3
Published
A cross-platform command-line utility for systemd service notification
Readme
sd-notify-cli
This project provides a minimal implementation of the sd_notify mechanism, allowing processes to send notifications to systemd or compatible service managers via Unix sockets. It is designed to be simple, portable, and dependency-free, making it suitable for use in containers, custom init systems, or environments where the full libsystemd is not available.
The binary is built as a universal executable using ape/libcosmopolitan and will run on Linux, macOS, Windows, and more, making it highly cross-platform. The binary is bundled with the project so there is no need to install additional libraries or dependencies.
Features
- Sends messages to the socket specified by the
NOTIFY_SOCKETenvironment variable. - Supports both filesystem and abstract Unix domain sockets (as used by systemd).
Installation
Install from npm:
npm install sd-notify-cliExample
To notify systemd that your service is ready:
sd-notify-cli "READY=1"To send a custom message:
sd-notify-cli "STATUS=Starting up..."Usage from JavaScript
You can also use this package directly from JavaScript:
import notify from 'sd-notify-cli'
// Notify systemd that your service is ready
await notify('READY=1')
// Send a custom message
await notify('STATUS=Starting up...')Notes
- This is not a full replacement for
sd_notify()fromlibsystemd. It only sends a single message to the specified socket. - The tool does not support file descriptor passing or advanced features of the full
sd_notifyAPI. - The socket path must fit within the limits of
struct sockaddr_un.
License
See LICENSE for details.
