All Projects → bb4242 → sdnotify

bb4242 / sdnotify

Licence: MIT License
A pure Python implementation of systemd's service notification protocol (sd_notify)

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to sdnotify

ucp
UCP protocol in Go
Stars: ✭ 40 (-45.95%)
Mutual labels:  protocol
port-numbers
Get information on network port numbers and services, based on IANA's public listing
Stars: ✭ 22 (-70.27%)
Mutual labels:  protocol
lwow
Lightweight onewire protocol library optimized for UART hardware on embedded systems
Stars: ✭ 98 (+32.43%)
Mutual labels:  protocol
gemini
Gemini protocol server & client.
Stars: ✭ 39 (-47.3%)
Mutual labels:  protocol
gree-remote
Simple remote control utility for Gree Smart air conditioners
Stars: ✭ 150 (+102.7%)
Mutual labels:  protocol
lips
📘 Lisk improvement proposals
Stars: ✭ 61 (-17.57%)
Mutual labels:  protocol
librelp
OFFICIAL librelp repository on github
Stars: ✭ 25 (-66.22%)
Mutual labels:  protocol
CollectionAndTableViewCompatible
A set of Swift protocols and Xcode snippets that will make it easy to do clean UITableView code
Stars: ✭ 34 (-54.05%)
Mutual labels:  protocol
powerauth-crypto
PowerAuth - Open-source solution for authentication, secure data storage and transport security in mobile banking.
Stars: ✭ 48 (-35.14%)
Mutual labels:  protocol
rmnp
Realtime Multiplayer Networking Protocol
Stars: ✭ 41 (-44.59%)
Mutual labels:  protocol
fix
FIX library for crystal
Stars: ✭ 12 (-83.78%)
Mutual labels:  protocol
protocol
Package protocol implements Language Server Protocol specification in Go
Stars: ✭ 41 (-44.59%)
Mutual labels:  protocol
cproto
Chrome Debugging client for Python
Stars: ✭ 29 (-60.81%)
Mutual labels:  protocol
gopher
A simple server for the Gopher protocol written in Go.
Stars: ✭ 17 (-77.03%)
Mutual labels:  protocol
penetration testing
🎩 [penetration testing Book], Kali Magic, Cryptography, Hash Crack, Botnet, Rootkit, Malware, Spyware, Python, Go, C|EH.
Stars: ✭ 57 (-22.97%)
Mutual labels:  protocol
elvisp
Virtual ISP / IP tunnel daemon for cjdns.
Stars: ✭ 19 (-74.32%)
Mutual labels:  protocol
rfc
Modular p2p messaging stack, with a focus on secure messaging.
Stars: ✭ 81 (+9.46%)
Mutual labels:  protocol
node-sctp
SCTP userspace sockets for Node.js
Stars: ✭ 47 (-36.49%)
Mutual labels:  protocol
spring-boot-protocol
springboot功能扩充-netty动态协议,可以支持各种网络协议的动态切换(单端口支持多个网络协议).支持mmap,sendfile零拷贝,http请求批量聚合
Stars: ✭ 68 (-8.11%)
Mutual labels:  protocol
wotop
Web on top of any protocol
Stars: ✭ 118 (+59.46%)
Mutual labels:  protocol

systemd Service Notification

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. sdnotify is compatible with both Python 2 and 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 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 sdnotify
import time

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...
time.sleep(10)
print("Test startup finished")

# Inform systemd that we've finished our startup sequence...
n = sdnotify.SystemdNotifier()
n.notify("READY=1")

count = 1
while True:
	print("Running... {}".format(count))
	n.notify("STATUS=Count is {}".format(count))
	count += 1
	time.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
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].