Python Linux Service Manager (plsm)
介绍
Python Linux Service Manager (plsm):专注于Linux系统服务管理的Python库,提供完整的服务配置管理、状态监控和操作功能。
项目统计
- 最新版本: v0.1.0
- PyPI 下载量: 查看统计
- 支持Python版本: 3.8+
- 许可证: MIT
软件架构
plsm采用模块化设计,将功能拆分为三个核心模块:
- 配置管理模块 (
ServiceConfigManager): 负责服务的配置文件读取、解析和管理 - 状态管理模块 (
ServiceStatusManager): 负责服务的状态监控、查询和管理 - 主服务管理模块 (
ServiceManager): 整合配置和状态管理,提供完整的服务管理功能
特性
🚀 分离架构: 配置管理和状态管理分离,职责清晰
🔍 自动检测: 自动识别系统服务状态和配置信息
💻 Python 3.8+ 兼容: 支持现代Python版本
📦 完整功能: 支持服务的启动、停止、重启、重载等操作
🛡️ 错误处理: 完善的错误处理和异常管理
🧪 完整测试: 全面的单元测试覆盖
安装教程
- 从源码安装
git clone https://gitee.com/liumou_site/plsm.git
cd plsm
pip install .
- 从PyPI安装 (待发布)
pip install plsm
快速开始
from plsm import ServiceManager, ServiceConfig
# 创建服务管理器
manager = ServiceManager(sudo=True)
# 列出所有服务
services = manager.list_all_services()
for service in services[:5]:
print(f"{service.name}: {service.status.value}")
# 检查特定服务状态
nginx_info = manager.get_service_info("nginx")
if nginx_info:
print(f"nginx状态: {nginx_info.status.value}")
# 创建自定义服务
config = ServiceConfig(
name="my-service",
description="My Custom Service",
exec_start="/usr/bin/python3 -m http.server 8080",
working_directory="/tmp"
)
# 创建并启动服务
manager.create_service(config, start_after_create=True)
API 参考
ServiceConfigManager 类
list_services()- 列出所有服务service_exists(name)- 检查服务是否存在read_config(name)- 读取服务配置create_config(config)- 创建服务配置remove_config(name)- 删除服务配置
ServiceStatusManager 类
get_status(name)- 获取服务状态is_running(name)- 检查服务是否运行is_active(name)- 检查服务是否激活list_services()- 列出所有服务状态
ServiceManager 类
start_service(name)- 启动服务stop_service(name)- 停止服务restart_service(name)- 重启服务enable_service(name)- 启用服务create_service(config)- 创建服务validate_service(name)- 验证服务状态
参与贡献
- Fork 本仓库
- 新建 Feat_xxx 分支
- 提交代码
- 新建 Pull Request
许可证
本项目采用 MIT 许可证 - 查看 LICENSE 文件了解详情
Metadata
Release files for plsm 1.0.1
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 |
|---|---|---|---|---|
| plsm-1.0.1.tar.gz | 14.9 kB | Without provenance | Details for plsm-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| plsm-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for plsm-1.0.1-py3-none-any.whl |
Total release size: 30.1 kB
Release files / plsm-1.0.1.tar.gz
| Download URL | plsm-1.0.1.tar.gz |
|---|---|
| Size | 14.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8ef0b52d504310b15717c75c302a5d79038468a84e710f2640b10a6350734ed0
|
|
BLAKE2b-256 checksum How to use checksums |
15eb6e045df68b5df991bec735d38492d637768e9e51c817f481dddf661172da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.2
|
Release files / plsm-1.0.1-py3-none-any.whl
| Download URL | plsm-1.0.1-py3-none-any.whl |
|---|---|
| Size | 15.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
16bedb9f13284901c7fd6d866e7bb29590beb36c435bbf3640413c510211999f
|
|
BLAKE2b-256 checksum How to use checksums |
790ec20af664d5cd534dcc0af95c4e8d3d9c44b33c81074c979c381b2845d7b2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.2
|
Security for plsm 1.0.1
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.