{"id":34087139,"url":"https://github.com/albertosantagostino/systemd-servicehandler","last_synced_at":"2026-04-07T07:02:13.330Z","repository":{"id":57465896,"uuid":"245110266","full_name":"albertosantagostino/systemd-servicehandler","owner":"albertosantagostino","description":"Python package to handle and orchestrate systemd services ","archived":false,"fork":false,"pushed_at":"2020-06-27T10:28:11.000Z","size":27,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-27T09:26:36.974Z","etag":null,"topics":["linux","python","python-library","service","systemd","systemd-service"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/servicehandler/","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/albertosantagostino.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}},"created_at":"2020-03-05T08:41:01.000Z","updated_at":"2020-06-27T10:29:41.000Z","dependencies_parsed_at":"2022-09-15T01:20:40.436Z","dependency_job_id":null,"html_url":"https://github.com/albertosantagostino/systemd-servicehandler","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/albertosantagostino/systemd-servicehandler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albertosantagostino%2Fsystemd-servicehandler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albertosantagostino%2Fsystemd-servicehandler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albertosantagostino%2Fsystemd-servicehandler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albertosantagostino%2Fsystemd-servicehandler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/albertosantagostino","download_url":"https://codeload.github.com/albertosantagostino/systemd-servicehandler/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albertosantagostino%2Fsystemd-servicehandler/sbom","scorecard":{"id":178074,"data":{"date":"2025-08-11","repo":{"name":"github.com/albertosantagostino/systemd-servicehandler","commit":"ca02ed02e588a50b110023422e7974a6dbd90d47"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.7,"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":"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":"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":"Code-Review","score":0,"reason":"Found 0/8 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":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"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":"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":"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":"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":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"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":0,"reason":"Project has not signed or included provenance with any releases.","details":["Warn: release artifact v0.9 not signed: https://api.github.com/repos/albertosantagostino/systemd-servicehandler/releases/27965029","Warn: release artifact v0.9 does not have provenance: https://api.github.com/repos/albertosantagostino/systemd-servicehandler/releases/27965029"],"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"}}]},"last_synced_at":"2025-08-16T18:12:16.421Z","repository_id":57465896,"created_at":"2025-08-16T18:12:16.422Z","updated_at":"2025-08-16T18:12:16.422Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31503394,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T03:10:19.677Z","status":"ssl_error","status_checked_at":"2026-04-07T03:10:13.982Z","response_time":105,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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","python","python-library","service","systemd","systemd-service"],"created_at":"2025-12-14T13:37:24.447Z","updated_at":"2026-04-07T07:02:13.325Z","avatar_url":"https://github.com/albertosantagostino.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ca href=\"https://pypi.org/project/servicehandler/\" target=\"\\_parent\"\u003e\u003cimg alt=\"#PyPI\" src=\"https://img.shields.io/pypi/v/servicehandler?color=blue\"\u003e\u003c/a\u003e \u003ca href=\"https://github.com/albertosantagostino/systemd-servicehandler/blob/master/LICENSE\" target=\"\\_parent\"\u003e\u003cimg alt=\"GitHub - License\" src=\"https://img.shields.io/github/license/albertosantagostino/systemd-servicehandler\"\u003e\u003c/a\u003e\n\n\u003cp align=\"center\"\u003e\u003cimg src=\"docs/img/banner.svg\" /\u003e\u003c/p\u003e\n\n`servicehandler` is an orchestrator for systemd services, distributed as a Python package. It provides abstraction for services and implements helper methods, wrapping the `systemctl` command\n\nUsing the package does **not** require root permissions, as the user service manager is used (with unit files in `/usr/lib/systemd/user/`)\n\n## Description\n\nA service (aka *daemon*) is defined by its **unit file** (e.g. `/usr/lib/systemd/user/my-service.service`):\n\n```ini\n[Unit]\nDescription=My service\n\n[Service]\nExecStart=/usr/bin/python3 /home/user/service_script/main.py\nEnvironment=PATH=/bin:/usr/bin:/usr/local/bin\nWorkingDirectory=/home/user/service_script/\n\n[Install]\nWantedBy=multi-user.target\n```\n\n### Usage\n\n**Create a ServiceHandler object**\n\n```python\nimport servicehandler as sh\n\nmy_service = sh.ServiceHandler('MyService','my-service.service')\n```\n\n**Control the state of a service**\n\n```python\n# Check current state\nmy_service.state()\n\u003cServiceState.STOPPED: 2\u003e\n\n# Start the service\n\u003e my_service.start()\nMyService changed state to ServiceState.RUNNING\n\u003cResponse.OK: 1\u003e\n\n# Try to start again the service\n\u003e my_service.start()\n\u003cResponse.ALREADY: 2\u003e\n\n# Terminate the service\n\u003e my_service.stop()\nMyService changed state to ServiceState.STOPPED\n\u003cResponse.OK: 1\u003e\n\n# Kill the service\n# In this specific case, the unit file was configured with restart=on-failure (automatic restart)\n\u003e my_service.kill()\n\u003cResponse.OK: 1\u003e\n```\n\n**Control the enablement_state of a service (whether it automatically starts on system startup)**\n\n```python\n# Check current enablement_state\n\u003e my_service.enablement_state()\n\u003cServiceEnablementState.DISABLED: 2\u003e\n\n# Enable the service\n\u003e my_service.enable()\nCreated symlink /home/user/.config/systemd/user/multi-user.target.wants/my_service.service → /usr/lib/systemd/user/my_service.service.\nMyService changed enablement state to ServiceEnablementState.ENABLED\n\u003cResponse.OK: 1\u003e\n\n# Disable the service\n\u003e my_service.disable()\nRemoved /home/user/.config/systemd/user/multi-user.target.wants/my_service.service.\nMyService changed enablement state to ServiceEnablementState.DISABLED\n\u003cResponse.OK: 1\u003e\n```\n\n**Iterate over different services and perform batch operations**\n\n```python\nimport servicehandler as sh\n\nservice_A = sh.ServiceHandler('ServiceA','A-config-file.service')\nservice_B = sh.ServiceHandler('ServiceB','B-config-file.service')\nservice_C = sh.ServiceHandler('ServiceC','C-config-file.service')\n\nservices = [ServiceA, ServiceB, ServiceC]\n\n# Iterate over the services easily\nfor srv in services:\n    if srv.state() == sh.ServiceStatus.STOPPED:\n        srv.restart()\n    print(srv.state())\n```\n\n## Installation\n\n### Install using pip\n\n`servicehandler` is available on [PyPI](https://pypi.org/project/servicehandler/) and it can be installed using **pip**:\n\n```\npip install servicehandler\n```\n\n### Build from source\n\nAs an alternative, it's possible to build and install the package from source:\n\n```\ngit clone https://github.com/albertosantagostino/systemd-servicehandler\ncd systemd-servicehandler\npython3 setup.py install\n```\n\n## Development history and use cases\n\n### Manage multiple services from a single entry-point\n\nThis package was developed while working on a Telegram bot ~~overlord~~ manager, created to handle other bots (and services) running on the same platform, providing a single point of access to the user\n\nIn the scenario multiple bots run on a headless Raspberry Pi Zero. In order to start them when needed, check their logs and interact with them without opening an SSH session every time, a brand new all-powerful Telegram bot was created, weaponized with this newly created package\n\n## License\n\nThe package is distributed under the [MIT License](https://opensource.org/licenses/MIT)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falbertosantagostino%2Fsystemd-servicehandler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falbertosantagostino%2Fsystemd-servicehandler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falbertosantagostino%2Fsystemd-servicehandler/lists"}