{"id":20729440,"url":"https://github.com/kopf/cpr","last_synced_at":"2025-07-21T18:37:19.797Z","repository":{"id":185685869,"uuid":"658798932","full_name":"kopf/cpr","owner":"kopf","description":"cpr monitors the health of your docker containers and restarts them when necessary. ","archived":false,"fork":false,"pushed_at":"2023-08-02T19:26:38.000Z","size":191,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-09T06:11:21.452Z","etag":null,"topics":["containerization","docker","health-check","healthcheck","python"],"latest_commit_sha":null,"homepage":"","language":"Python","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/kopf.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}},"created_at":"2023-06-26T14:08:29.000Z","updated_at":"2023-08-10T00:31:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"5db41492-fee6-4019-9492-972fe55a37a7","html_url":"https://github.com/kopf/cpr","commit_stats":null,"previous_names":["kopf/cpr"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kopf/cpr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kopf%2Fcpr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kopf%2Fcpr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kopf%2Fcpr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kopf%2Fcpr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kopf","download_url":"https://codeload.github.com/kopf/cpr/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kopf%2Fcpr/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266353205,"owners_count":23915913,"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-07-21T11:47:31.412Z","response_time":64,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"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":["containerization","docker","health-check","healthcheck","python"],"created_at":"2024-11-17T04:42:49.968Z","updated_at":"2025-07-21T18:37:19.779Z","avatar_url":"https://github.com/kopf.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cpr\ncpr monitors the health of your docker containers and restarts them when necessary. \n\n## Motivation\n\nWhy was `cpr` created, when there are plenty of other alternatives on the market, such as [docker-autoheal](https://github.com/willfarrell/docker-autoheal)? \nWell, unfortunately the alternatives all require forking a process for each healthcheck. This is quite costly,\nespecially on smaller cloud instances. \n\nFor example, here we see the difference in CPU utilization between `docker-autoheal` and `cpr` on \nan AWS EC2 `t3a.small` instance:\n\n![cpu_utilization_screenshot](cpu_utilization_screenshot.png)\n\nWe can see the CPU usage drop from ~13% to ~5% after having switched to `cpr` just before 08:00. \n\nFor reference, this was a `t3a.small` instance with healthchecks enabled for 3 containers, each of which had\na default interval of 2 seconds. The instance was essentially idling, with no traffic from outside. (The spikes\nwe see early in the morning are cronjobs running.)\n\n## Example usage\n\nRunning `cpr` using docker-compose: \n\n```\nversion: '3.0'\nservices:\n  cpr:\n    container_name: cpr\n    image: kopf/cpr:latest\n    restart: \"unless-stopped\"\n    volumes:\n      - /var/run/docker.sock:/var/run/docker.sock\n```\n\nOnce `cpr` is running, you need to mark containers with labels in order to let it know what healthchecks to perform. For example:\n\n```\nversion: '3.0'\nservices:\n  nginx:\n    image: nginx\n    container_name: nginx\n    volumes:\n      ...\n    ports:\n      ...\n    labels:\n      cpr.enabled: \"true\" # required\n      cpr.url: \"http://nginx/_nginxhealthcheck/\" # required; url to be probed\n      cpr.headers: '{\"Host\":\"www.mywebsite.com\",\"X-Forwarded-Proto\":\"https\"}' # optional; additional headers to send in healthcheck\n      cpr.start_period: 10 # optional; number of seconds to wait before checking\n      cpr.retries: 3 # optional; number of retries to make\n      cpr.timeout: 2.5 # optional; number of seconds before timing out\n```\n\n## Configuring cpr defaults\n\n`cpr`'s defaults can be configured by setting environment variables on the `cpr` container itself. Here is an overview:\n\n* `CPR_DEFAULT_START_PERIOD` (default: `8`) - The length of time (in seconds) to wait before probing a container.\n* `CPR_DEFAULT_INTERVAL` (default: `3`) - The length of time (in seconds) to wait between probes.\n* `CPR_DEFAULT_RETRIES` (default: `2`) - The number of retries before marking a container as unhealthy and restarting it.\n* `CPR_DEFAULT_TIMEOUT` (default: `1`) - The default HTTP timeout (in seconds) to use when probing a container.\n* `CPR_REFRESH_TIME` (default: `60`) - The default amount of time (in seconds) to wait before scanning for new `cpr`-enabled containers to probe.  \n* `CPR_LOGLEVEL` (default: `INFO`) - The default log level. Set to `DEBUG` for more verbose logging. \n\n## Known limitations\n\n* `cpr` won't detect changes to your containers' logs after they've been scanned. In order to ensure cpr respects changes after the fact, be sure to restart `cpr` once you've redeployed your services with new labels. ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkopf%2Fcpr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkopf%2Fcpr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkopf%2Fcpr/lists"}