{"id":42724241,"url":"https://github.com/kmwenja/glock","last_synced_at":"2026-01-29T16:39:16.477Z","repository":{"id":64303970,"uuid":"154645397","full_name":"kmwenja/glock","owner":"kmwenja","description":"Flock-like utility in Go","archived":false,"fork":false,"pushed_at":"2018-10-26T13:30:09.000Z","size":5,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-20T04:22:10.253Z","etag":null,"topics":["flock","go","golang","unix-command"],"latest_commit_sha":null,"homepage":null,"language":"Go","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/kmwenja.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":"2018-10-25T09:34:28.000Z","updated_at":"2024-06-20T04:22:10.254Z","dependencies_parsed_at":"2023-01-15T10:00:55.240Z","dependency_job_id":null,"html_url":"https://github.com/kmwenja/glock","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/kmwenja/glock","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kmwenja%2Fglock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kmwenja%2Fglock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kmwenja%2Fglock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kmwenja%2Fglock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kmwenja","download_url":"https://codeload.github.com/kmwenja/glock/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kmwenja%2Fglock/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28880986,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-29T10:31:27.438Z","status":"ssl_error","status_checked_at":"2026-01-29T10:31:01.017Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["flock","go","golang","unix-command"],"created_at":"2026-01-29T16:39:14.559Z","updated_at":"2026-01-29T16:39:16.463Z","avatar_url":"https://github.com/kmwenja.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GLock\n\n*Project Status: ALPHA*\n\nRuns a command if an associated lockfile is not acquired by another command.\nSpiritual successor to `flock`.\n\nFlock is a unix utility that allows you to specify a lockfile before running a command\nso that only one instance of that command runs at a time.\n\nA typical invocation of flock:\n```sh\n# this acquires the lockfile and runs the script\nflock -xn /tmp/lockfile long_running_script.sh\n\n# this fails immediately because another script has acquired the lockfile\nflock -xn /tmp/lockfile long_running_script.sh\n```\n\nThis makes it very convenient for controlling cron scripts that may run longer than their schedule.\nFor instance, a cron script may be scheduled to run every 30 mins but it's run time may end up\nbeing 40 mins, longer than that 30 mins. This may be undesirable for scripts that require exclusive\naccess to some resource or scripts that when ran in parallel overutilize resources.\n\nThat being said, it is considered that engineering exclusive locks in the script itself\nwould be a better and more maintenable solution. However, there can be situations\nthat justify the use of `flock` and `glock` hopes to extend and improve the solutions.\nSpecifically, flock does not support the following uses cases:\n\n1. Specifying a timeout for a script. A script may fail in such a way that it does not exit e.g. deadlocks.\n   Flock doesn't allow you to specify that if the script doesn't exit in a specified amount of time, it is killed instead.\n   You could potentially do the same with the `timeout` utility i.e. `timeout 5 flock ....` but this\n   doesn't take the lockfile into consideration. For example in this case, once the script is killed,\n   the lockfile needs to be released (deleted). Glock attempts to support this usecase.\n\n2. Determining if a script owning a lockfile is dead. It is possible for flock to exit without\n   releasing the lockfile. This could possibly be due to a *hard* exit e.g. signal-kill or OOM.\n   In this scenario, because the lockfile was not removed, the next script will fail to start.\n   Glock attempts to solve this by writing the pid of the process owning the lockfile *into* the\n   lockfile. This allows the next invocation to query whether that pid is alive and if it's not,\n   remove the *stale* lockfile and attempt to re-acquire a new lockfile.\n\nGlock, however, does not currently support:\n\n1. Shared locks also known as multiple readers, single writer locks.\n2. Introspection tools to query the state of a running instance of glock (lockfile, its process).\n\n## Installing\n\n**Prebuilt binaries**:\n\n1. Download a tarball from [Releases](https://github.com/kmwenja/glock/releases).\n2. Extract the tarball: `tar -xvf glock-vX.Y.Z.tar.gz`. This will extract a directory called `glock`.\n3. Copy the binary at `glock/glock` to a suitable path or run `glock/glock` directly.\n\n**From Source**:\n`go get -u -v github.com/kmwenja/glock`\n\n## Usage\n\n```sh\n# help\nglock\n\n# run with defaults\nglock echo hello world\n\n# change the lockfile\nglock -lockfile /tmp/mylockfile\n\n# run with a specific timeout (10mins)\nglock -timeout 600 echo hello world\n\n# if another process has the lockfile,\n# wait for them to be done for some time (20s) before quitting\nglock -wait 20 echo hello world\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkmwenja%2Fglock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkmwenja%2Fglock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkmwenja%2Fglock/lists"}