supervice 0.1.0__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.
- supervice-0.1.0/LICENSE +201 -0
- supervice-0.1.0/PKG-INFO +300 -0
- supervice-0.1.0/README.md +257 -0
- supervice-0.1.0/pyproject.toml +88 -0
- supervice-0.1.0/setup.cfg +4 -0
- supervice-0.1.0/supervice/__init__.py +3 -0
- supervice-0.1.0/supervice/client.py +250 -0
- supervice-0.1.0/supervice/config.py +333 -0
- supervice-0.1.0/supervice/core.py +227 -0
- supervice-0.1.0/supervice/events.py +92 -0
- supervice-0.1.0/supervice/health.py +122 -0
- supervice-0.1.0/supervice/logger.py +63 -0
- supervice-0.1.0/supervice/main.py +83 -0
- supervice-0.1.0/supervice/models.py +56 -0
- supervice-0.1.0/supervice/process.py +488 -0
- supervice-0.1.0/supervice/py.typed +0 -0
- supervice-0.1.0/supervice/rpc.py +223 -0
- supervice-0.1.0/supervice.egg-info/PKG-INFO +300 -0
- supervice-0.1.0/supervice.egg-info/SOURCES.txt +29 -0
- supervice-0.1.0/supervice.egg-info/dependency_links.txt +1 -0
- supervice-0.1.0/supervice.egg-info/entry_points.txt +3 -0
- supervice-0.1.0/supervice.egg-info/requires.txt +12 -0
- supervice-0.1.0/supervice.egg-info/top_level.txt +1 -0
- supervice-0.1.0/tests/test_config.py +103 -0
- supervice-0.1.0/tests/test_core.py +115 -0
- supervice-0.1.0/tests/test_health.py +200 -0
- supervice-0.1.0/tests/test_logger.py +43 -0
- supervice-0.1.0/tests/test_process.py +320 -0
- supervice-0.1.0/tests/test_rpc_protocol.py +123 -0
- supervice-0.1.0/tests/test_security.py +115 -0
- supervice-0.1.0/tests/test_validation.py +204 -0
supervice-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2025 Farshid Ashouri
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
supervice-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: supervice
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A modern, async process supervisor for Unix-like systems. Zero dependencies.
|
|
5
|
+
Author: Farshid Ashouri
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Documentation, https://supervice.readthedocs.io
|
|
8
|
+
Project-URL: Repository, https://github.com/rodmena-limited/supervice
|
|
9
|
+
Project-URL: Issues, https://github.com/rodmena-limited/supervice/issues
|
|
10
|
+
Project-URL: Changelog, https://supervice.readthedocs.io/en/latest/changelog.html
|
|
11
|
+
Keywords: supervisor,process-manager,daemon,asyncio,process-control
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Environment :: No Input/Output (Daemon)
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: System Administrators
|
|
16
|
+
Classifier: Operating System :: POSIX
|
|
17
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
18
|
+
Classifier: Operating System :: MacOS
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
25
|
+
Classifier: Topic :: System :: Boot
|
|
26
|
+
Classifier: Topic :: System :: Monitoring
|
|
27
|
+
Classifier: Topic :: System :: Systems Administration
|
|
28
|
+
Classifier: Typing :: Typed
|
|
29
|
+
Requires-Python: >=3.10
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
License-File: LICENSE
|
|
32
|
+
Provides-Extra: docs
|
|
33
|
+
Requires-Dist: sphinx>=7.0; extra == "docs"
|
|
34
|
+
Requires-Dist: furo>=2024.0; extra == "docs"
|
|
35
|
+
Requires-Dist: myst-parser>=3.0; extra == "docs"
|
|
36
|
+
Requires-Dist: sphinx-copybutton>=0.5; extra == "docs"
|
|
37
|
+
Provides-Extra: dev
|
|
38
|
+
Requires-Dist: mypy>=1.0; extra == "dev"
|
|
39
|
+
Requires-Dist: ruff>=0.4; extra == "dev"
|
|
40
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
41
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
|
|
42
|
+
Dynamic: license-file
|
|
43
|
+
|
|
44
|
+
# Supervice
|
|
45
|
+
|
|
46
|
+
[](LICENSE)
|
|
47
|
+
[](https://www.python.org/downloads/)
|
|
48
|
+
[](https://github.com/astral-sh/ruff)
|
|
49
|
+
[](https://mypy-lang.org/)
|
|
50
|
+
[](https://supervice.readthedocs.io)
|
|
51
|
+
|
|
52
|
+
A modern, lightweight, and fully async process supervisor for Unix-like systems.
|
|
53
|
+
**Zero dependencies. Pure Python. Production-ready.**
|
|
54
|
+
|
|
55
|
+
Supervice manages long-running processes with automatic restart, health checking,
|
|
56
|
+
process grouping, hot config reload, and a Unix socket RPC interface — all built
|
|
57
|
+
on Python's `asyncio` with no external packages.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Features
|
|
62
|
+
|
|
63
|
+
- **Async-first** — Built entirely on `asyncio` for efficient I/O multiplexing
|
|
64
|
+
- **Zero dependencies** — Pure Python stdlib; nothing to install beyond Python 3.10+
|
|
65
|
+
- **Process groups** — Organize related processes and control them as a unit
|
|
66
|
+
- **Health checks** — TCP connectivity and script-based health monitoring with auto-restart
|
|
67
|
+
- **Hot reload** — Add/remove programs without restarting the daemon (`supervicectl reload`)
|
|
68
|
+
- **Daemon mode** — Proper double-fork daemonization with PID file locking
|
|
69
|
+
- **Graceful shutdown** — SIGTERM/SIGINT triggers orderly stop of all child processes
|
|
70
|
+
- **Process group kill** — Stops entire process trees, not just the main PID
|
|
71
|
+
- **Log rotation** — Built-in `RotatingFileHandler` with configurable size and backup count
|
|
72
|
+
- **Uptime tracking** — Per-process wall-clock uptime displayed in status output
|
|
73
|
+
- **Retry with backoff** — Configurable start retries with automatic FATAL state on exhaustion
|
|
74
|
+
- **User switching** — Run processes as a specific user (requires root)
|
|
75
|
+
- **Type-safe** — Fully type-hinted, passes `mypy --strict`
|
|
76
|
+
|
|
77
|
+
## Installation
|
|
78
|
+
|
|
79
|
+
**Requirements:** Python 3.10+ on a Unix-like OS (Linux, macOS).
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# From source
|
|
83
|
+
git clone https://github.com/yourusername/supervice.git
|
|
84
|
+
cd supervice
|
|
85
|
+
pip install .
|
|
86
|
+
|
|
87
|
+
# Development install (includes docs dependencies)
|
|
88
|
+
pip install -e ".[docs]"
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Quick Start
|
|
92
|
+
|
|
93
|
+
### 1. Create a configuration file
|
|
94
|
+
|
|
95
|
+
```ini
|
|
96
|
+
# supervisord.conf
|
|
97
|
+
[supervice]
|
|
98
|
+
loglevel = INFO
|
|
99
|
+
logfile = supervice.log
|
|
100
|
+
pidfile = supervice.pid
|
|
101
|
+
|
|
102
|
+
[program:webapp]
|
|
103
|
+
command = python3 -u app.py
|
|
104
|
+
autostart = true
|
|
105
|
+
autorestart = true
|
|
106
|
+
stdout_logfile = webapp.log
|
|
107
|
+
stderr_logfile = webapp_err.log
|
|
108
|
+
|
|
109
|
+
[program:worker]
|
|
110
|
+
command = python3 -u worker.py
|
|
111
|
+
numprocs = 4
|
|
112
|
+
autostart = true
|
|
113
|
+
autorestart = true
|
|
114
|
+
stdout_logfile = worker_%(process_num)s.log
|
|
115
|
+
stderr_logfile = worker_err_%(process_num)s.log
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### 2. Start the daemon
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# Foreground (development)
|
|
122
|
+
supervice -c supervisord.conf -n
|
|
123
|
+
|
|
124
|
+
# Background (production — default)
|
|
125
|
+
supervice -c supervisord.conf
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### 3. Control processes
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
# Check status
|
|
132
|
+
supervicectl status
|
|
133
|
+
|
|
134
|
+
# Output:
|
|
135
|
+
# NAME STATE PID UPTIME
|
|
136
|
+
# --------------------------------------------------------
|
|
137
|
+
# webapp RUNNING 12345 1:23:45
|
|
138
|
+
# worker:00 RUNNING 12346 1:23:44
|
|
139
|
+
# worker:01 RUNNING 12347 1:23:44
|
|
140
|
+
# worker:02 RUNNING 12348 1:23:44
|
|
141
|
+
# worker:03 RUNNING 12349 1:23:44
|
|
142
|
+
|
|
143
|
+
# Start / stop / restart individual processes
|
|
144
|
+
supervicectl stop worker:00
|
|
145
|
+
supervicectl start worker:00
|
|
146
|
+
supervicectl restart worker:00
|
|
147
|
+
supervicectl restart worker:00 --force # SIGKILL instead of graceful
|
|
148
|
+
|
|
149
|
+
# Group operations
|
|
150
|
+
supervicectl stopgroup workers
|
|
151
|
+
supervicectl startgroup workers
|
|
152
|
+
|
|
153
|
+
# Hot reload (add/remove programs without restart)
|
|
154
|
+
supervicectl reload
|
|
155
|
+
|
|
156
|
+
# Use a custom socket path
|
|
157
|
+
supervicectl -s /var/run/supervice.sock status
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Configuration Reference
|
|
161
|
+
|
|
162
|
+
### `[supervice]` — Global settings
|
|
163
|
+
|
|
164
|
+
| Option | Default | Description |
|
|
165
|
+
|--------|---------|-------------|
|
|
166
|
+
| `logfile` | `supervice.log` | Path to the daemon log file |
|
|
167
|
+
| `loglevel` | `INFO` | Log level: `DEBUG`, `INFO`, `WARNING`, `ERROR`, `CRITICAL` |
|
|
168
|
+
| `pidfile` | `supervice.pid` | Path to the PID/lock file |
|
|
169
|
+
| `socket` | `/tmp/supervice.sock` | Unix socket path for RPC |
|
|
170
|
+
| `shutdown_timeout` | `30` | Seconds to wait for graceful shutdown |
|
|
171
|
+
| `log_maxbytes` | `52428800` | Max log file size before rotation (bytes, 0 = no rotation) |
|
|
172
|
+
| `log_backups` | `10` | Number of rotated log backup files to keep |
|
|
173
|
+
|
|
174
|
+
### `[program:NAME]` — Process definitions
|
|
175
|
+
|
|
176
|
+
| Option | Default | Description |
|
|
177
|
+
|--------|---------|-------------|
|
|
178
|
+
| `command` | *(required)* | Command to execute (supports shell-style quoting) |
|
|
179
|
+
| `numprocs` | `1` | Number of instances to run (creates `NAME:00`, `NAME:01`, ...) |
|
|
180
|
+
| `autostart` | `true` | Start automatically when daemon starts |
|
|
181
|
+
| `autorestart` | `true` | Restart automatically when process exits |
|
|
182
|
+
| `startsecs` | `1` | Seconds a process must run to be considered successfully started |
|
|
183
|
+
| `startretries` | `3` | Max consecutive start attempts before entering FATAL state |
|
|
184
|
+
| `stopsignal` | `TERM` | Signal to send when stopping (`TERM`, `INT`, `QUIT`, `KILL`, etc.) |
|
|
185
|
+
| `stopwaitsecs` | `10` | Seconds to wait after stop signal before sending SIGKILL |
|
|
186
|
+
| `stdout_logfile` | *(none)* | File for stdout (supports `%(process_num)s` substitution) |
|
|
187
|
+
| `stderr_logfile` | *(none)* | File for stderr (supports `%(process_num)s` substitution) |
|
|
188
|
+
| `environment` | *(none)* | Environment variables: `KEY=VAL,KEY2="val with,comma"` |
|
|
189
|
+
| `directory` | *(none)* | Working directory for the process |
|
|
190
|
+
| `user` | *(none)* | Run as this user (requires root privileges) |
|
|
191
|
+
|
|
192
|
+
### `[group:NAME]` — Process groups
|
|
193
|
+
|
|
194
|
+
| Option | Default | Description |
|
|
195
|
+
|--------|---------|-------------|
|
|
196
|
+
| `programs` | *(required)* | Comma-separated list of program names |
|
|
197
|
+
|
|
198
|
+
### Health check options (per program)
|
|
199
|
+
|
|
200
|
+
| Option | Default | Description |
|
|
201
|
+
|--------|---------|-------------|
|
|
202
|
+
| `healthcheck_type` | `none` | Health check type: `none`, `tcp`, `script` |
|
|
203
|
+
| `healthcheck_interval` | `30` | Seconds between health checks |
|
|
204
|
+
| `healthcheck_timeout` | `10` | Seconds to wait for health check response |
|
|
205
|
+
| `healthcheck_retries` | `3` | Consecutive failures before marking unhealthy |
|
|
206
|
+
| `healthcheck_start_period` | `10` | Seconds to wait before starting health checks |
|
|
207
|
+
| `healthcheck_port` | *(none)* | TCP port to check (required for `tcp` type) |
|
|
208
|
+
| `healthcheck_host` | `127.0.0.1` | TCP host to check |
|
|
209
|
+
| `healthcheck_command` | *(none)* | Script to run (required for `script` type) |
|
|
210
|
+
|
|
211
|
+
**Example with health checks:**
|
|
212
|
+
|
|
213
|
+
```ini
|
|
214
|
+
[program:api]
|
|
215
|
+
command = python3 -u api_server.py
|
|
216
|
+
autostart = true
|
|
217
|
+
autorestart = true
|
|
218
|
+
healthcheck_type = tcp
|
|
219
|
+
healthcheck_port = 8080
|
|
220
|
+
healthcheck_interval = 15
|
|
221
|
+
healthcheck_retries = 3
|
|
222
|
+
healthcheck_start_period = 5
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## Process States
|
|
226
|
+
|
|
227
|
+
```
|
|
228
|
+
STOPPED ──┐
|
|
229
|
+
EXITED ──┼──> STARTING ──> RUNNING ──> STOPPING ──> STOPPED
|
|
230
|
+
FATAL ──┤ │ │
|
|
231
|
+
BACKOFF ──┘ │ EXITED
|
|
232
|
+
▼
|
|
233
|
+
UNHEALTHY (health check failures)
|
|
234
|
+
│
|
|
235
|
+
▼
|
|
236
|
+
auto-restart (if autorestart=true)
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
| State | Description |
|
|
240
|
+
|-------|-------------|
|
|
241
|
+
| `STOPPED` | Process is not running (initial or manually stopped) |
|
|
242
|
+
| `STARTING` | Process has been spawned, waiting for confirmation |
|
|
243
|
+
| `RUNNING` | Process is running and healthy |
|
|
244
|
+
| `BACKOFF` | Process exited too quickly, waiting before retry |
|
|
245
|
+
| `STOPPING` | Stop signal sent, waiting for process to exit |
|
|
246
|
+
| `EXITED` | Process has exited (normally or abnormally) |
|
|
247
|
+
| `FATAL` | Process failed to start after exhausting retries |
|
|
248
|
+
| `UNHEALTHY` | Process is running but health checks are failing |
|
|
249
|
+
|
|
250
|
+
## Architecture
|
|
251
|
+
|
|
252
|
+
```
|
|
253
|
+
┌─────────────────────────────────────────────────┐
|
|
254
|
+
│ supervice │
|
|
255
|
+
│ │
|
|
256
|
+
│ ┌──────────┐ ┌───────────┐ ┌──────────┐ │
|
|
257
|
+
│ │ Config │───▶│ Supervisor │───▶│ Process │ │
|
|
258
|
+
│ │ Parser │ │ (core) │ │ Manager │ │
|
|
259
|
+
│ └──────────┘ └─────┬─────┘ └────┬─────┘ │
|
|
260
|
+
│ │ │ │
|
|
261
|
+
│ ┌────▼────┐ ┌─────▼─────┐ │
|
|
262
|
+
│ │ RPC │ │ EventBus │ │
|
|
263
|
+
│ │ Server │ │ (pub/sub) │ │
|
|
264
|
+
│ └────┬────┘ └───────────┘ │
|
|
265
|
+
│ │ │
|
|
266
|
+
└────────────────────────┼─────────────────────────┘
|
|
267
|
+
│ Unix Socket
|
|
268
|
+
┌────▼────┐
|
|
269
|
+
│supervice│
|
|
270
|
+
│ ctl │
|
|
271
|
+
└─────────┘
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
## Documentation
|
|
275
|
+
|
|
276
|
+
Full documentation is available at [supervice.readthedocs.io](https://supervice.readthedocs.io).
|
|
277
|
+
|
|
278
|
+
## Development
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
# Run tests
|
|
282
|
+
python3 -m pytest tests/ -v
|
|
283
|
+
|
|
284
|
+
# Type checking (strict mode)
|
|
285
|
+
mypy --strict supervice/
|
|
286
|
+
|
|
287
|
+
# Linting
|
|
288
|
+
ruff check supervice/
|
|
289
|
+
|
|
290
|
+
# Formatting
|
|
291
|
+
ruff format supervice/
|
|
292
|
+
|
|
293
|
+
# Build documentation locally
|
|
294
|
+
pip install -e ".[docs]"
|
|
295
|
+
cd docs && make html
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
## License
|
|
299
|
+
|
|
300
|
+
Apache License 2.0 — see [LICENSE](LICENSE) for details.
|