{"id":30453299,"url":"https://github.com/geekcampchina/samplepythonprocessmanager","last_synced_at":"2025-10-15T11:17:09.366Z","repository":{"id":89761317,"uuid":"223099946","full_name":"geekcampchina/SamplePythonProcessManager","owner":"geekcampchina","description":"一个简化进程管理的 Python 库，丰富的命令行控制参数满足各种运行需求","archived":false,"fork":false,"pushed_at":"2024-01-25T19:57:55.000Z","size":124,"stargazers_count":6,"open_issues_count":0,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-23T19:25:33.692Z","etag":null,"topics":["linux","process-manager","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/geekcampchina.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-11-21T06:00:54.000Z","updated_at":"2023-08-14T09:38:29.000Z","dependencies_parsed_at":"2024-01-25T20:46:32.083Z","dependency_job_id":"43fdfd8d-6ee0-4835-8cb2-428ca43743ab","html_url":"https://github.com/geekcampchina/SamplePythonProcessManager","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/geekcampchina/SamplePythonProcessManager","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geekcampchina%2FSamplePythonProcessManager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geekcampchina%2FSamplePythonProcessManager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geekcampchina%2FSamplePythonProcessManager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geekcampchina%2FSamplePythonProcessManager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/geekcampchina","download_url":"https://codeload.github.com/geekcampchina/SamplePythonProcessManager/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geekcampchina%2FSamplePythonProcessManager/sbom","scorecard":{"id":421487,"data":{"date":"2025-08-11","repo":{"name":"github.com/geekcampchina/SamplePythonProcessManager","commit":"bcef604146099f26daf1f86d94d144751d9fdd29"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.9,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Code-Review","score":0,"reason":"Found 2/29 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":9,"reason":"1 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: PYSEC-2019-41 / GHSA-qfc5-mcwq-26q8"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 3 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-19T01:18:42.001Z","repository_id":89761317,"created_at":"2025-08-19T01:18:42.001Z","updated_at":"2025-08-19T01:18:42.001Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279076176,"owners_count":26098103,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-15T02:00:07.814Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["linux","process-manager","python"],"created_at":"2025-08-23T15:20:39.009Z","updated_at":"2025-10-15T11:17:09.338Z","avatar_url":"https://github.com/geekcampchina.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sample Python Process Manager\n\n一个简化进程管理的 `Python` 库，丰富的命令行控制参数满足各种运行需求\n\n***仅支持 Linux/Unix***\n\n## 使用场景\n- 需要不影响业务（一致性）的情况下管理进程，比如 stop/reload/restart\n- 需要 `nohup`、`screen` 等运行\n- 需要驻留后台\n\n## 特点\n极少代码侵入，即可达到优雅的停止、重载（重启），不需要 `kill -9` 强制杀死进程，不影响业务数据处理或写入，也可以直接使用sppm_cli将Shell命令封装成服务进程。__\n\n## 安装\n\n```bash\npip install sppm\n```\n\n## sppm_cli（sppm客户端）说明\n\n### 用法\n\n    usage: /usr/bin/sppm_cli --no-daemon -v -l --name progress_name [--start|--stop|--reload|--shutdown|--restart|--status] [shell]\n    \n    Sample Python Process Manager 客户端，直接将Shell命令转换为可管理的服务进程，方便管理。比如管理SpringBoot程序\n    \n    positional arguments:\n      shell                 执行的Shell命令，配合 --start 或 --restart 参数使用\n    \n    options:\n      -h, --help            show this help message and exit\n      --no-daemon           不使用进程管理模式\n      -l {0,1,2,3,4,5}, --log-level {0,1,2,3,4,5}\n                            日志级别，0（CRITICAL）、1（ERROR）、2（WARNING）、3（INFO）、4（DEBUG）、5（TRACE），默认等级3\n      --start               启动子进程\n      --stop                等待子进程正常退出\n      --reload              等待子进程正常退出，并启动新的子进程\n      --shutdown            强制杀掉子进程\n      --restart             强制杀掉子进程，并启动新的子进程\n      --status              显示子进程状态\n      -v, --version         显示版本信息\n      --name NAME           显示的进程名称，仅支持字母、数字和下划线组成的字符串\n      --user USER           指定运行Shell命令的用户，配合 --start 或 --restart 参数使用\n\n### 使用实例\n\n#### 启动服务进程\n\n`sppm_cli --name foo '/usr/bin/python -m http.server' --start --user $USER`\n\n#### 查看服务进程\n\n`sppm_cli --name foo --status`\n\n    pid                  : 237764\n    ppid                 : 237763\n    alive                : true\n    uptime               : 23 second(s)\n    human readable uptime: 23 second(s)\n    create time          : 2022-06-17 17:58:42.470000\n    active               : false\n    last active time     : 2022-06-17 17:58:43.300041\n\n\n#### 重启服务进程\n\n`sppm_cli --name foo '/usr/bin/python -m http.server' --restart --user $USER`\n\n#### 停止服务进程\n\n`sppm_cli --name foo --stop`\n\n## sppm代码库说明\n\n### 用法\n\n    usage: examples/example.py --no-daemon -v -l [--start|--stop|--reload|--shutdown|--restart|--status]\n\n    简化进程管理的命令行工具\n\n    optional arguments:\n    -h, --help            show this help message and exit\n    --no-daemon           不使用进程管理模式\n    -l {0,1,2,3,4,5}, --log-level {0,1,2,3,4,5}\n                    日志级别，0（CRITICAL）、1（ERROR）、2（WARNING）、3（INFO）、4（DEBUG）、5（TRACE），默认等级3\n    --start               启动子进程\n    --stop                等待子进程正常退出\n    --reload              等待子进程正常退出，并启动新的子进程\n    --shutdown            强制杀掉子进程\n    --restart             强制杀掉子进程，并启动新的子进程\n    --status              显示子进程状态\n    -v, --version         显示版本信息\n\n### 使用\n\n#### 代码\n\n```python\nimport sppm\n\nsppm.sppm_start(foo)\n```\n\n更多细节，请查看 `examples/example.py` 以及 `examples/example_working_lock.py`\n\n#### 管理\n\n更多使用方法，请执行 `python3 examples/example.py -h` 查看帮助信息。\n\n##### 启动\n```bash\npython3 examples/example.py --start\n```\n\n    2019-12-01 17:45:07 15048 [INFO] **** 按Ctrl+C可以终止运行 ****\n    2019-12-01 17:45:07 15049 [INFO] Run 0 time(s) task-\u003efoo.\n    2019-12-01 17:45:17 15049 [INFO] Run 1 time(s) task-\u003efoo.\n    2019-12-01 17:45:27 15049 [INFO] Run 2 time(s) task-\u003efoo.\n    2019-12-01 17:45:37 15049 [INFO] Run 3 time(s) task-\u003efoo.\n    ^C2019-12-01 17:45:47 15049 [INFO] Run 4 time(s) task-\u003efoo.\n    执行exit_callback函数\n\n\n指定日志等级：\n\n```bash\npython3 examples/example.py --start -l 5\n```\n\n##### 查看状态\n```bash\npython3 examples/example.py --status\n```\n\n    pid                  : 16728\n    ppid                 : 16727\n    alive                : true\n    uptime               : 152 second(s)\n    human readable uptime: 2 minute(s), 32 second(s)\n    create time          : 2019-12-01 18:32:30.300000\n    active               : false\n    last active time     : 2019-12-01 18:32:30.696024\n\n\n##### 停止\n```bash\npython3 examples/example.py --stop\n```\n\n#### 运行多个程序\n\n```bash\npython3 examples/example.py --start\n\nSPPM_ENV=examples/.sppm_env_working_lock python examples/example_working_lock.py --start\n```\n\n    $ python3 examples/example.py --status\n    pid                  : 17404\n    ppid                 : 17403\n    alive                : true\n    uptime               : 48 second(s)\n    human readable uptime: 48 second(s)\n    create time          : 2019-12-01 18:49:47.880000\n    active               : false\n    last active time     : 2019-12-01 18:49:48.273476\n\n\n    $ SPPM_ENV=examples/.sppm_env_working_lock python examples/example_working_lock.py --status\n    pid                  : 17397\n    ppid                 : 17396\n    alive                : true\n    uptime               : 40 second(s)\n    human readable uptime: 40 second(s)\n    create time          : 2019-12-01 18:49:25.690000\n    active               : true\n    last active time     : 2019-12-01 18:50:06.127305\n\n\n#### 配置文件\n\n默认情况下，程序自动从环境变量 `SPPM_ENV` 加载 `Python` 文件目录下的 `.sppm_env`。\n\n    $ cat examples/.sppm_env\n    pid=/tmp/example.pid\n    child_pid=/tmp/example_child.pid\n    lock=/tmp/example.lock\n    log=/tmp/example.log\n\n运行多个程序时，每个程序必须单独配置环境变量 `SPPM_ENV` 指向不同的配置文件。\n      --user USER           指定运行Shell命令的用户，配合 --start 和 --restart 参数使用","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeekcampchina%2Fsamplepythonprocessmanager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeekcampchina%2Fsamplepythonprocessmanager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeekcampchina%2Fsamplepythonprocessmanager/lists"}