python-trio / python-trio/trio
Write a helper library for services/daemons
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.3k
- Forks
- 431
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 6
Description
A very common use case for a library like trio is writing long-running server processes. We should make it easy to get this right. This should probably be as a new package on top of trio. Some brainstorming:
Integrating with platform-specific service management systems:
-
Windows services
-
Launchd integration, in particular socket activation. This is done by calling
launch_activate_socket("lookup-key", ...), which returns an array of fds. (Could be multiple e.g. one for IPv4 and one for IPv6). -
Systemd integration: socket activation (depends on #251), watchdog support,
sd_notify, maybesd_pid_notify_with_fds, ... (see sd-daemon.h). These can be done via a binding to libsystemd or through our own implementation (they're all pretty trivially defined in terms of environment variable manipulation etc.), and either way there's a choice whether to write our own or use an existing one.
It might also make sense to support classic double-fork daemonization, though that's fallen out of popularity these days.
Generic services:
-
abstracting away the differences between different socket activation styles (a bit tricky, since launchd always uses names but we can't really introspect the returned sockets – again see #251 – while systemd prefers to use introspection and only supports names as a fallback.)
-
graceful shutdown -- SIGTERM, however windows services do it
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the proposed entry points: launch_activate_socket, the systemd sd-daemon.h interface, and dependency issue #251. Done would require defining a package scope that covers the relevant service-management integrations, socket activation differences, and graceful shutdown behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- infrastructure, operating-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100