{"id":15779602,"url":"https://github.com/aldaviva/powercycler","last_synced_at":"2025-03-31T15:54:00.982Z","repository":{"id":70211928,"uuid":"565430950","full_name":"Aldaviva/PowerCycler","owner":"Aldaviva","description":"🔛 Have you tried turning it off and back on again?","archived":false,"fork":false,"pushed_at":"2023-11-20T16:09:04.000Z","size":57,"stargazers_count":3,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T07:08:33.393Z","etag":null,"topics":["health-check","reboot","reset","restart","stonith"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Aldaviva.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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},"funding":{"custom":["https://paypal.me/aldaviva"]}},"created_at":"2022-11-13T11:49:13.000Z","updated_at":"2024-11-25T17:00:47.000Z","dependencies_parsed_at":"2024-10-04T18:20:42.686Z","dependency_job_id":null,"html_url":"https://github.com/Aldaviva/PowerCycler","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aldaviva%2FPowerCycler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aldaviva%2FPowerCycler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aldaviva%2FPowerCycler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aldaviva%2FPowerCycler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Aldaviva","download_url":"https://codeload.github.com/Aldaviva/PowerCycler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246492158,"owners_count":20786319,"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","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":["health-check","reboot","reset","restart","stonith"],"created_at":"2024-10-04T18:20:36.727Z","updated_at":"2025-03-31T15:54:00.960Z","avatar_url":"https://github.com/Aldaviva.png","language":"C#","funding_links":["https://paypal.me/aldaviva"],"categories":[],"sub_categories":[],"readme":"PowerCycler\n===\n\n[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/Aldaviva/PowerCycler/.NET?logo=github)](https://github.com/Aldaviva/PowerCycler/actions/workflows/main.yml)\n\nAutomatically turn a power outlet off and on again when a health check fails.\n\n## Prerequisites\n- [.NET 7 runtime](https://dotnet.microsoft.com/en-us/download/dotnet/7.0) or later\n- [Kasa smart outlet](https://www.kasasmart.com/us/products/smart-plugs), such as the [EP10](https://www.kasasmart.com/us/products/smart-plugs/kasa-smart-plug-mini-ep10) or [KP125](https://www.kasasmart.com/us/products/smart-plugs/kasa-smart-plug-slim-energy-monitoring-kp125)\n\n## Installation\n\nPre-built executables are provided for Windows (x64) and Linux (x64 and ARM).\n\n### Linux\n\nTested on a Raspberry Pi 2 Model B running Raspbian 11 Bullseye.\n\n1. Download the Linux ARM build from the [latest release](https://github.com/Aldaviva/PowerCycler/releases/latest).\n1. Unzip and move the executable.\n    ```sh\n    unzip PowerCycler-linux-arm.zip\n    sudo mv PowerCycler /usr/local/bin/\n    sudo chmod +x /usr/local/bin/PowerCycler\n    ```\n1. Move the configuration file.\n    ```sh\n    sudo mv powercycler.json /usr/local/etc/\n    ```\n1. Install the systemd service unit file.\n    ```sh\n    sudo mv powercycler.service /etc/systemd/system/\n    sudo systemctl daemon-reload\n    sudo systemctl enable powercycler.service\n    ```\n\n### Windows\n\n1. Download the Windows build from the [latest release](https://github.com/Aldaviva/PowerCycler/releases/latest).\n1. Unzip it to a folder such as `C:\\Program Files\\PowerCycler\\`.\n1. Open PowerShell elevated and run\n    ```ps1\n    New-Service -Name \"PowerCycler\" -DisplayName \"PowerCycler\" -Description \"Turn it off and on again.\" -BinaryPathName \"C:\\Program Files\\PowerCycler\\PowerCycler.exe\" -DependsOn Tcpip\n    ```\n\n## Configuration\n\nEdit the `powercycler.json` configuration file.\n\nAll fields are required.\n\n|Field|Example value|Description|\n|---|---|---|\n|`healthCheckUrl`|`https://aldaviva.com`\u003cbr\u003eor \u003cbr\u003e`tcp://aldaviva.com:22`|The URL of the process being monitored to check and see if it's healthy.\u003cbr\u003eFor **`http`** and **`https`** schemes, it sends a GET request and requires a status code in [200, 300). Redirections are not followed.\u003cbr\u003eFor the **`tcp`** scheme, it opens a socket connection to the URL's hostname and port.|\n|`healthCheckTimeoutSec`|`5`|How long, in seconds, the process being monitored has to send a health check response before that check fails. Should be shorter than `healthCheckFrequencySec`.|\n|`healthCheckFrequencySec`|`60`|How often, in seconds, to send health check requests.|\n|`outletHostname`|`bragi.outlets.aldaviva.com`\u003cbr\u003eor\u003cbr\u003e`192.168.1.100`|The FQDN or IP address of a Kasa smart outlet to turn off and on when the process is deemed to be offline and must be restarted.|\n|`minOfflineDurationBeforeRestartSec`|`600`|How long, in seconds, to go without any successful health check responses before the outlet is power cycled. Should be longer than `healthCheckFrequencySec`.|\n|`resumeHealthCheckAfterRestartSec`|`300`|How long, in seconds, to wait after power cycling before checking health again. Should be longer than it takes your process to become healthy after a reboot.|\n|`Logging.LogLevel.Default`|`Information`|Minimum severity of log events to emit. Values are `Trace`, `Debug`, `Information`, `Warning`, `Error`, `Critical`, and `None`.\u003cbr\u003eView logs using `sudo journalctl -u powercycler` on Linux or Event Viewer on Windows.|\n\nWith the above example values, this service will send an HTTP GET request to `https://aldaviva.com` every 60 seconds.\n- If it has returned at least one 200 OK response in the last 600 seconds, this service will do nothing.\n- Otherwise, if it has done nothing in the past 600 seconds but return errors (such as 400, 500, or 503) or take more than 5 seconds to respond, then this service will turn off the outlet at 192.168.1.100, wait 2 seconds, and then turn the outlet back on again. This service will then wait 300 seconds before finally starting the health check loop again.\n\n## Running\n\n### Linux\n\n```sh\nsudo systemctl start powercycler.service\n```\n\n### Windows\n\n```ps1\nStart-Service PowerCycler\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faldaviva%2Fpowercycler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faldaviva%2Fpowercycler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faldaviva%2Fpowercycler/lists"}