{"id":20678552,"url":"https://github.com/codecentric/coolock","last_synced_at":"2026-04-20T12:31:37.467Z","repository":{"id":144964823,"uuid":"96396760","full_name":"codecentric/coolock","owner":"codecentric","description":"A coordinated locking wrapper script for distributed tasks.","archived":false,"fork":false,"pushed_at":"2020-09-11T01:22:14.000Z","size":23,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-01-17T15:16:35.472Z","etag":null,"topics":["coordination","cron","cron-jobs","distributed-systems","lock","locking","wrapper"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codecentric.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}},"created_at":"2017-07-06T06:35:29.000Z","updated_at":"2023-12-13T17:04:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"275e5af7-36bf-42af-b4d8-d87f162e0752","html_url":"https://github.com/codecentric/coolock","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codecentric%2Fcoolock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codecentric%2Fcoolock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codecentric%2Fcoolock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codecentric%2Fcoolock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codecentric","download_url":"https://codeload.github.com/codecentric/coolock/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242911156,"owners_count":20205442,"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":["coordination","cron","cron-jobs","distributed-systems","lock","locking","wrapper"],"created_at":"2024-11-16T21:20:48.708Z","updated_at":"2026-04-20T12:31:37.429Z","avatar_url":"https://github.com/codecentric.png","language":"Python","readme":"# coolock - A coordinated locking wrapper script for distributed tasks\n`coolock` is based on the [Tooz](https://github.com/openstack/tooz) Python\nlibrary. For a list of supported coordination backends see\n[here](https://docs.openstack.org/developer/tooz/compatibility.html#locking).\n\nThe Tooz library is just an abstraction layer for different coordination\nbackends. Depending on the used backend you may need to install additional\npython libraries. At the time of writing the following lock backends can be\nused:\n\n|Backend|Required Python PyPi Package(s)|\n|:---    |:---                            |\n|Consul|python-consul|\n|etcd|(no additional packages required)|\n|etcd3|etcd3|\n|Memcached|pymemcache|\n|MySQL|pymysql|\n|Postgres|psycopg2|\n|Redis|redis|\n|Zookeeper|kazoo|\n|File|(no additional packages required)|\n\nIn volatile distributed systems a common problem is to execute a certain\njob just once for a number of nodes. Examples are backup cronjobs, sending\nmails on a regular basis or reporting tasks. You want to execute those tasks\njust once, no matter how many nodes your autoscaling mechanism has started at\nthe given point in time. Most distributed systems already depend on a\ncoordination backend like Apache ZooKeeper, Redis or Consul.\n`coolock` offers an easy to use wrapper for those coordination backends,\nthat you can easily use for your tasksr, keeping the complexity of\ncoordination and even dealing with a coordination backend outside of\nyour scripts and crojobs.\n\n*NOTE: This requires synced clocks to work as expected*\n\n## Installation\n`coolock` is available in the PyPI repository. Use pip to install it:\n```\npip install coolock\n```\n\n## Usage\n```\n# Basic usage:\ncoolock --backend redis://localhost:6379 echo \"Hello World\"\n\n# Running two instances on the same host. One will return immediately.\ncoolock --backend redis://localhost:6379 --node 1 echo \"instance 1\" \u0026\ncoolock --backend redis://localhost:6379 --node 2 echo \"instance 2\" \u0026\n```\n\n## Configuration file\nYou may also configure some or all parameters in a configuration file.\n`coolock` looks for config files at `/etc/coolock` and `$HOME/coolock`.\n\nExample configuration file:\n```\n# Coordination backend URI\ncoordination-backend: kazoo://localhost:2181\n\n# Name of the lock to acquire\nlock: coolock\n\n# Wait at least guard-time (in seconds) to block other executions of the same job.\n# If the execution of the command takes longer then the guard-time execution stops\n# right after the command finishes.\nguard-time: 30\n\n# This nodes name. Default is the hostname.\n# node: myhost\n\n# Wait at least wait-timeout (in seconds) to acquire the lock\nwait-timeout: 0\n\n# Log file destination\nlog-file: /var/log/coolock.log\n\n# Log level:\n# Possible values are: debug, info, warning, error, critical\nlog-level: info\n\n# Log file maximum size\nlog-max-size: 20971520 # 20 MB\n\n# Number of rotated log copies to keep\nrotate-log-copies: 5\n```\n\n## Similar Software\nThere are already some wrapper scripts that focus on a specific\ncoordination backend (that you might just not have in your setup):\n* [cronsul](https://github.com/EvanKrall/cronsul): A simple bash script\n  coordinator using HashiCorps Consul.\n* [distributed-cron](https://github.com/whitehats/distributed-cron):\n  Python script that is using a memcache client.\n* [cron-lock](https://github.com/kvz/cronlock): A bash script that uses\n  Redis for coordination.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodecentric%2Fcoolock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodecentric%2Fcoolock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodecentric%2Fcoolock/lists"}