systemd Service Notification
This is a Calian fork of Garrett's Asyncio version (https://github.com/seatsnob/sdnotify-asyncio) of the systemd sd_notify package written by bb4242 (Brett Bethke), available at https://github.com/bb4242/sdnotify
This is a pure Python implementation of the
systemd
sd_notify
protocol. This protocol can be used to inform systemd about service start-up
completion, watchdog events, and other service status changes. Thus, this
package can be used to write system services in Python that play nicely with
systemd. async-sdnotify is compatible with Python 3.
Normally the SystemdNotifier.notify method silently ignores exceptions (for example, if the
systemd notification socket is not available) to allow applications to
function on non-systemd based systems. However, setting debug=True will
cause this method to raise any exceptions generated to the caller, to
aid in debugging.
Installation
pip install async-sdnotify
Example Usage
This is an example of a simple Python service that informs systemd when its
startup sequence is complete. It also sends periodic status updates to systemd,
which can be viewed with systemctl status test.
test.py
import aiosdnotify
import asyncio
async def main():
print("Test starting up...")
# In a real service, this is where you'd do real startup tasks
# like opening listening sockets, connecting to a database, etc...
await asyncio.sleep(2)
print("Test startup finished")
# Inform systemd that we've finished our startup sequence...
async with aiosdnotify.SystemdNotifier() as n:
n.ready()
count = 1
while True:
print("Running... {}".format(count))
n.status("Count is {}".format(count))
count += 1
await asyncio.sleep(2)
test.service
[Unit]
Description=A test service written in Python
[Service]
# Note: setting PYTHONUNBUFFERED is necessary to see the output of this service in the journal
# See https://docs.python.org/2/using/cmdline.html#envvar-PYTHONUNBUFFERED
Environment=PYTHONUNBUFFERED=true
# Adjust this line to the correct path to test.py
ExecStart=/usr/bin/python /path/to/test.py
# Note that we use Type=notify here since test.py will send "READY=1"
# when it's finished starting up
Type=notify
[Install]
WantedBy=multi-user.target
Metadata
Release files for async-sdnotify 0.1.0.post2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| async_sdnotify-0.1.0.post2.tar.gz | 4.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| async_sdnotify-0.1.0.post2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.3 kB
Release files / async_sdnotify-0.1.0.post2.tar.gz
| Download URL | async_sdnotify-0.1.0.post2.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b81241d0b7ba3a01adef08110f9c6187e7caf0fd0cb9f9e6cfeae0f420341ce1
|
|
BLAKE2b-256 checksum How to use checksums |
75f609b1a075295e56526e3983f35d24c2e2712b6722cc547cb11e77d2bb826a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.1 CPython/3.12.5 Linux/5.14.0-362.8.1.el9_3.x86_64
|
Release files / async_sdnotify-0.1.0.post2-py3-none-any.whl
| Download URL | async_sdnotify-0.1.0.post2-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0065d42932d1b02e87d72c50800220860969668a8fa39fecf82f769ffe32b4e5
|
|
BLAKE2b-256 checksum How to use checksums |
7dd564b64f93bc283fb37336befa2d695369fd8b03783f8db35f8df2febb8592
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.1 CPython/3.12.5 Linux/5.14.0-362.8.1.el9_3.x86_64
|
Security for async-sdnotify 0.1.0.post2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.