This release is a pre-release and may not be stable for production use.
A cross-platform Python library for managing system services and daemons with a unified interface.
Overview
DaemonCrafter simplifies the process of creating, managing, and controlling system services across different operating systems. It automatically detects your platform and uses the appropriate service management backend:
- Linux: systemd
- Windows: Service Control Manager (SCM)
Features
- 🔄 Cross-platform compatibility - Works seamlessly on Linux and Windows
- 🚀 Easy service installation - Install any Python script or executable as a system service
- 🎛️ Complete lifecycle management - Install, uninstall, start, stop, enable, disable services
- 📊 Log management - Retrieve and monitor service logs
- 🔧 Automatic backend selection - No need to worry about platform-specific implementations
- 🐍 Python 3.8+ support - Compatible with modern Python versions
Installation
pip install DaemonCrafter
Quick Start
from pathlib import Path
from daemoncrafter import DaemonCrafter
# Create a daemon manager for your application
daemon = DaemonCrafter(
name="my-app-service",
executable=Path("/path/to/your/application")
)
# Install the service
daemon.install()
# Enable auto-start at boot
daemon.enable()
# Start the service
daemon.start()
# Check if it's running
if daemon.is_running():
print("Service is running!")
# View recent logs
logs = daemon.get_logs(lines=20)
for log_line in logs:
print(log_line)
API Reference
DaemonCrafter Class
Constructor
DaemonCrafter(name: str, executable: Path, backend: Optional[type[DaemonProvider]] = None)
name: The name of the serviceexecutable: Path to the executable or scriptbackend: Optional custom backend provider (auto-detected if not specified)
Methods
| Method | Description |
|---|---|
install() |
Install the application as a system service |
uninstall() |
Remove the service (keeps application files) |
start() |
Start the service |
stop() |
Stop the service |
restart() |
Restart the service |
enable() |
Enable auto-start at boot |
disable() |
Disable auto-start at boot |
is_installed() |
Check if service is installed |
is_running() |
Check if service is currently running |
is_enabled() |
Check if service is enabled for auto-start |
get_logs(lines, since, until) |
Retrieve service logs |
Advanced Usage
Custom Backend
from daemoncrafter import DaemonCrafter
from daemoncrafter.linux import SystemdProvider
# Force use of systemd even on other platforms
daemon = DaemonCrafter(
name="my-service",
executable=Path("/usr/local/bin/myapp"),
backend=SystemdProvider
)
Log Management
# Get last 100 lines
logs = daemon.get_logs(lines=100)
# Get logs from specific time period
logs = daemon.get_logs(since="2024-01-01", until="2024-01-02")
Platform Support
Linux
- Uses systemd for service management
- Requires systemd-enabled distribution
- Services installed in
/etc/systemd/system/
Windows
- Uses Windows Service Control Manager (SCM)
- Includes winsw.exe for service wrapper functionality
- Services registered in Windows Services
Mac
- Not yet supported (PRs welcome!)
Requirements
- Python 3.8 or higher
str-case-utildependency- Platform-specific requirements:
- Linux: systemd
- Windows: Administrative privileges for service installation
Metadata
Release files for DaemonCrafter 0.2.0b0
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 | Actions |
|---|---|---|---|---|
| daemoncrafter-0.2.0b0.tar.gz | 7.7 MB | Without provenance | Details for daemoncrafter-0.2.0b0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| daemoncrafter-0.2.0b0-py3-none-any.whl | Python 3 | none | any | Details for daemoncrafter-0.2.0b0-py3-none-any.whl |
Total release size: 15.5 MB
Release files / daemoncrafter-0.2.0b0.tar.gz
| Download URL | daemoncrafter-0.2.0b0.tar.gz |
|---|---|
| Size | 7.7 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ded1428c6e2eeaf37512062d9816e5beb78671546da62868857483a149a051ff
|
|
BLAKE2b-256 checksum How to use checksums |
d84defca88e15281d41ab839c9ac618c6a8557aeec2d2051b913623f523421c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.26.7 CPython/3.14.3 Linux/6.17.0-1008-azure
|
Release files / daemoncrafter-0.2.0b0-py3-none-any.whl
| Download URL | daemoncrafter-0.2.0b0-py3-none-any.whl |
|---|---|
| Size | 7.8 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a4af56c1bed333b859c35f986fa36a083a725facef6ef9d360f3b26f3d9e40f6
|
|
BLAKE2b-256 checksum How to use checksums |
6ca7a2a8abc4abcfadb7335f0c1260f20d52783dc650a714b862a73c9c3e3b22
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.26.7 CPython/3.14.3 Linux/6.17.0-1008-azure
|
Security for DaemonCrafter 0.2.0b0
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.