DaemonCrafter 0.1.0b0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: DaemonCrafter
|
|
3
|
+
Version: 0.1.0b0
|
|
4
|
+
Summary: todo
|
|
5
|
+
Keywords: daemon,system,service,manager,systemd,scm,nssm,winsw,automation,install,logs,Linux,Windows,cross-platform,python,script,exe,program,application,app,fastapi,api,flask,deploy,deployment
|
|
6
|
+
Author-Email: Cody M Sommer <bassmastacod@gmail.com>
|
|
7
|
+
License: MIT
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
17
|
+
Classifier: Typing :: Typed
|
|
18
|
+
Project-URL: Repository, https://github.com/BassMastaCod/DaemonCrafter.git
|
|
19
|
+
Project-URL: Issues, https://github.com/BassMastaCod/DaemonCrafter/issues
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Requires-Dist: str-case-util
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+

|
|
25
|
+
|
|
26
|
+
A cross-platform Python library for managing system services and daemons with a unified interface.
|
|
27
|
+
|
|
28
|
+
## Overview
|
|
29
|
+
|
|
30
|
+
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:
|
|
31
|
+
|
|
32
|
+
- **Linux**: systemd
|
|
33
|
+
- **Windows**: Service Control Manager (SCM)
|
|
34
|
+
|
|
35
|
+
## Features
|
|
36
|
+
|
|
37
|
+
- 🔄 **Cross-platform compatibility** - Works seamlessly on Linux and Windows
|
|
38
|
+
- 🚀 **Easy service installation** - Install any Python script or executable as a system service
|
|
39
|
+
- 🎛️ **Complete lifecycle management** - Install, uninstall, start, stop, enable, disable services
|
|
40
|
+
- 📊 **Log management** - Retrieve and monitor service logs
|
|
41
|
+
- 🔧 **Automatic backend selection** - No need to worry about platform-specific implementations
|
|
42
|
+
- 🐍 **Python 3.8+ support** - Compatible with modern Python versions
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pip install DaemonCrafter
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Quick Start
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
from pathlib import Path
|
|
54
|
+
from daemon_crafter import DaemonCrafter
|
|
55
|
+
|
|
56
|
+
# Create a daemon manager for your application
|
|
57
|
+
daemon = DaemonCrafter(
|
|
58
|
+
name="my-app-service",
|
|
59
|
+
executable=Path("/path/to/your/application")
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
# Install the service
|
|
63
|
+
daemon.install()
|
|
64
|
+
|
|
65
|
+
# Enable auto-start at boot
|
|
66
|
+
daemon.enable()
|
|
67
|
+
|
|
68
|
+
# Start the service
|
|
69
|
+
daemon.start()
|
|
70
|
+
|
|
71
|
+
# Check if it's running
|
|
72
|
+
if daemon.is_running():
|
|
73
|
+
print("Service is running!")
|
|
74
|
+
|
|
75
|
+
# View recent logs
|
|
76
|
+
logs = daemon.get_logs(lines=20)
|
|
77
|
+
for log_line in logs:
|
|
78
|
+
print(log_line)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## API Reference
|
|
82
|
+
|
|
83
|
+
### DaemonCrafter Class
|
|
84
|
+
|
|
85
|
+
#### Constructor
|
|
86
|
+
```python
|
|
87
|
+
DaemonCrafter(name: str, executable: Path, backend: Optional[type[DaemonProvider]] = None)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
- `name`: The name of the service
|
|
91
|
+
- `executable`: Path to the executable or script
|
|
92
|
+
- `backend`: Optional custom backend provider (auto-detected if not specified)
|
|
93
|
+
|
|
94
|
+
#### Methods
|
|
95
|
+
|
|
96
|
+
| Method | Description |
|
|
97
|
+
|--------|-------------|
|
|
98
|
+
| `install()` | Install the application as a system service |
|
|
99
|
+
| `uninstall()` | Remove the service (keeps application files) |
|
|
100
|
+
| `start()` | Start the service |
|
|
101
|
+
| `stop()` | Stop the service |
|
|
102
|
+
| `restart()` | Restart the service |
|
|
103
|
+
| `enable()` | Enable auto-start at boot |
|
|
104
|
+
| `disable()` | Disable auto-start at boot |
|
|
105
|
+
| `is_installed()` | Check if service is installed |
|
|
106
|
+
| `is_running()` | Check if service is currently running |
|
|
107
|
+
| `is_enabled()` | Check if service is enabled for auto-start |
|
|
108
|
+
| `get_logs(lines, since, until)` | Retrieve service logs |
|
|
109
|
+
|
|
110
|
+
## Advanced Usage
|
|
111
|
+
|
|
112
|
+
### Custom Backend
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
from daemon_crafter import DaemonCrafter
|
|
116
|
+
from daemon_crafter.linux import SystemdProvider
|
|
117
|
+
|
|
118
|
+
# Force use of systemd even on other platforms
|
|
119
|
+
daemon = DaemonCrafter(
|
|
120
|
+
name="my-service",
|
|
121
|
+
executable=Path("/usr/local/bin/myapp"),
|
|
122
|
+
backend=SystemdProvider
|
|
123
|
+
)
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Log Management
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
# Get last 100 lines
|
|
130
|
+
logs = daemon.get_logs(lines=100)
|
|
131
|
+
|
|
132
|
+
# Get logs from specific time period
|
|
133
|
+
logs = daemon.get_logs(since="2024-01-01", until="2024-01-02")
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Platform Support
|
|
137
|
+
|
|
138
|
+
### Linux
|
|
139
|
+
- Uses systemd for service management
|
|
140
|
+
- Requires systemd-enabled distribution
|
|
141
|
+
- Services installed in `/etc/systemd/system/`
|
|
142
|
+
|
|
143
|
+
### Windows
|
|
144
|
+
- Uses Windows Service Control Manager (SCM)
|
|
145
|
+
- Includes winsw.exe for service wrapper functionality
|
|
146
|
+
- Services registered in Windows Services
|
|
147
|
+
|
|
148
|
+
### Mac
|
|
149
|
+
- Not yet supported (PRs welcome!)
|
|
150
|
+
|
|
151
|
+
## Requirements
|
|
152
|
+
|
|
153
|
+
- Python 3.8 or higher
|
|
154
|
+
- `str-case-util` dependency
|
|
155
|
+
- Platform-specific requirements:
|
|
156
|
+
- Linux: systemd
|
|
157
|
+
- Windows: Administrative privileges for service installation
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
A cross-platform Python library for managing system services and daemons with a unified interface.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
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:
|
|
8
|
+
|
|
9
|
+
- **Linux**: systemd
|
|
10
|
+
- **Windows**: Service Control Manager (SCM)
|
|
11
|
+
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
- 🔄 **Cross-platform compatibility** - Works seamlessly on Linux and Windows
|
|
15
|
+
- 🚀 **Easy service installation** - Install any Python script or executable as a system service
|
|
16
|
+
- 🎛️ **Complete lifecycle management** - Install, uninstall, start, stop, enable, disable services
|
|
17
|
+
- 📊 **Log management** - Retrieve and monitor service logs
|
|
18
|
+
- 🔧 **Automatic backend selection** - No need to worry about platform-specific implementations
|
|
19
|
+
- 🐍 **Python 3.8+ support** - Compatible with modern Python versions
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pip install DaemonCrafter
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Quick Start
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
from pathlib import Path
|
|
31
|
+
from daemon_crafter import DaemonCrafter
|
|
32
|
+
|
|
33
|
+
# Create a daemon manager for your application
|
|
34
|
+
daemon = DaemonCrafter(
|
|
35
|
+
name="my-app-service",
|
|
36
|
+
executable=Path("/path/to/your/application")
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
# Install the service
|
|
40
|
+
daemon.install()
|
|
41
|
+
|
|
42
|
+
# Enable auto-start at boot
|
|
43
|
+
daemon.enable()
|
|
44
|
+
|
|
45
|
+
# Start the service
|
|
46
|
+
daemon.start()
|
|
47
|
+
|
|
48
|
+
# Check if it's running
|
|
49
|
+
if daemon.is_running():
|
|
50
|
+
print("Service is running!")
|
|
51
|
+
|
|
52
|
+
# View recent logs
|
|
53
|
+
logs = daemon.get_logs(lines=20)
|
|
54
|
+
for log_line in logs:
|
|
55
|
+
print(log_line)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## API Reference
|
|
59
|
+
|
|
60
|
+
### DaemonCrafter Class
|
|
61
|
+
|
|
62
|
+
#### Constructor
|
|
63
|
+
```python
|
|
64
|
+
DaemonCrafter(name: str, executable: Path, backend: Optional[type[DaemonProvider]] = None)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
- `name`: The name of the service
|
|
68
|
+
- `executable`: Path to the executable or script
|
|
69
|
+
- `backend`: Optional custom backend provider (auto-detected if not specified)
|
|
70
|
+
|
|
71
|
+
#### Methods
|
|
72
|
+
|
|
73
|
+
| Method | Description |
|
|
74
|
+
|--------|-------------|
|
|
75
|
+
| `install()` | Install the application as a system service |
|
|
76
|
+
| `uninstall()` | Remove the service (keeps application files) |
|
|
77
|
+
| `start()` | Start the service |
|
|
78
|
+
| `stop()` | Stop the service |
|
|
79
|
+
| `restart()` | Restart the service |
|
|
80
|
+
| `enable()` | Enable auto-start at boot |
|
|
81
|
+
| `disable()` | Disable auto-start at boot |
|
|
82
|
+
| `is_installed()` | Check if service is installed |
|
|
83
|
+
| `is_running()` | Check if service is currently running |
|
|
84
|
+
| `is_enabled()` | Check if service is enabled for auto-start |
|
|
85
|
+
| `get_logs(lines, since, until)` | Retrieve service logs |
|
|
86
|
+
|
|
87
|
+
## Advanced Usage
|
|
88
|
+
|
|
89
|
+
### Custom Backend
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
from daemon_crafter import DaemonCrafter
|
|
93
|
+
from daemon_crafter.linux import SystemdProvider
|
|
94
|
+
|
|
95
|
+
# Force use of systemd even on other platforms
|
|
96
|
+
daemon = DaemonCrafter(
|
|
97
|
+
name="my-service",
|
|
98
|
+
executable=Path("/usr/local/bin/myapp"),
|
|
99
|
+
backend=SystemdProvider
|
|
100
|
+
)
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Log Management
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
# Get last 100 lines
|
|
107
|
+
logs = daemon.get_logs(lines=100)
|
|
108
|
+
|
|
109
|
+
# Get logs from specific time period
|
|
110
|
+
logs = daemon.get_logs(since="2024-01-01", until="2024-01-02")
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Platform Support
|
|
114
|
+
|
|
115
|
+
### Linux
|
|
116
|
+
- Uses systemd for service management
|
|
117
|
+
- Requires systemd-enabled distribution
|
|
118
|
+
- Services installed in `/etc/systemd/system/`
|
|
119
|
+
|
|
120
|
+
### Windows
|
|
121
|
+
- Uses Windows Service Control Manager (SCM)
|
|
122
|
+
- Includes winsw.exe for service wrapper functionality
|
|
123
|
+
- Services registered in Windows Services
|
|
124
|
+
|
|
125
|
+
### Mac
|
|
126
|
+
- Not yet supported (PRs welcome!)
|
|
127
|
+
|
|
128
|
+
## Requirements
|
|
129
|
+
|
|
130
|
+
- Python 3.8 or higher
|
|
131
|
+
- `str-case-util` dependency
|
|
132
|
+
- Platform-specific requirements:
|
|
133
|
+
- Linux: systemd
|
|
134
|
+
- Windows: Administrative privileges for service installation
|
|
Binary file
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = [
|
|
3
|
+
"pdm-backend",
|
|
4
|
+
]
|
|
5
|
+
build-backend = "pdm.backend"
|
|
6
|
+
|
|
7
|
+
[project]
|
|
8
|
+
name = "DaemonCrafter"
|
|
9
|
+
dynamic = []
|
|
10
|
+
authors = [
|
|
11
|
+
{ name = "Cody M Sommer", email = "bassmastacod@gmail.com" },
|
|
12
|
+
]
|
|
13
|
+
description = "todo"
|
|
14
|
+
keywords = [
|
|
15
|
+
"daemon",
|
|
16
|
+
"system",
|
|
17
|
+
"service",
|
|
18
|
+
"manager",
|
|
19
|
+
"systemd",
|
|
20
|
+
"scm",
|
|
21
|
+
"nssm",
|
|
22
|
+
"winsw",
|
|
23
|
+
"automation",
|
|
24
|
+
"install",
|
|
25
|
+
"logs",
|
|
26
|
+
"Linux",
|
|
27
|
+
"Windows",
|
|
28
|
+
"cross-platform",
|
|
29
|
+
"python",
|
|
30
|
+
"script",
|
|
31
|
+
"exe",
|
|
32
|
+
"program",
|
|
33
|
+
"application",
|
|
34
|
+
"app",
|
|
35
|
+
"fastapi",
|
|
36
|
+
"api",
|
|
37
|
+
"flask",
|
|
38
|
+
"deploy",
|
|
39
|
+
"deployment",
|
|
40
|
+
]
|
|
41
|
+
readme = "README.md"
|
|
42
|
+
requires-python = ">=3.10"
|
|
43
|
+
dependencies = [
|
|
44
|
+
"str-case-util",
|
|
45
|
+
]
|
|
46
|
+
classifiers = [
|
|
47
|
+
"License :: OSI Approved :: MIT License",
|
|
48
|
+
"Programming Language :: Python :: 3.10",
|
|
49
|
+
"Programming Language :: Python :: 3.11",
|
|
50
|
+
"Programming Language :: Python :: 3.12",
|
|
51
|
+
"Programming Language :: Python :: 3.13",
|
|
52
|
+
"Programming Language :: Python :: 3.14",
|
|
53
|
+
"Development Status :: 4 - Beta",
|
|
54
|
+
"Intended Audience :: Developers",
|
|
55
|
+
"Topic :: Software Development :: Libraries",
|
|
56
|
+
"Typing :: Typed",
|
|
57
|
+
]
|
|
58
|
+
version = "0.1.0b0"
|
|
59
|
+
|
|
60
|
+
[project.license]
|
|
61
|
+
text = "MIT"
|
|
62
|
+
|
|
63
|
+
[project.urls]
|
|
64
|
+
Repository = "https://github.com/BassMastaCod/DaemonCrafter.git"
|
|
65
|
+
Issues = "https://github.com/BassMastaCod/DaemonCrafter/issues"
|
|
66
|
+
|
|
67
|
+
[tool.pdm.version]
|
|
68
|
+
source = "scm"
|
|
69
|
+
|
|
70
|
+
[tool.pdm.build]
|
|
71
|
+
includes = [
|
|
72
|
+
"daemon_crafter/bin/*",
|
|
73
|
+
]
|