{"id":23359776,"url":"https://github.com/firehed/workers","last_synced_at":"2026-06-13T21:33:31.286Z","repository":{"id":62504923,"uuid":"98123517","full_name":"Firehed/workers","owner":"Firehed","description":null,"archived":false,"fork":false,"pushed_at":"2017-07-23T21:10:15.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-09T15:07:30.656Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Firehed.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-23T20:28:40.000Z","updated_at":"2020-07-28T00:13:09.000Z","dependencies_parsed_at":"2022-11-02T10:15:44.306Z","dependency_job_id":null,"html_url":"https://github.com/Firehed/workers","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Firehed/workers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Firehed%2Fworkers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Firehed%2Fworkers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Firehed%2Fworkers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Firehed%2Fworkers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Firehed","download_url":"https://codeload.github.com/Firehed/workers/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Firehed%2Fworkers/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265080256,"owners_count":23708121,"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":[],"created_at":"2024-12-21T11:11:57.049Z","updated_at":"2026-06-13T21:33:31.249Z","avatar_url":"https://github.com/Firehed.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Workers\n\nA library to manage worker processes in a run loop.\n\n[![Build Status](https://travis-ci.org/Firehed/workers.svg?branch=master)](https://travis-ci.org/Firehed/workers)\n\n## Worker Manager\n\nAt the heart of any run loop is the Worker Manager.\nIt will track execution count, set up basic POSIX signal handling, and other basic infrastructure.\n\n\n## Worker Class\nThe actual tasks are performed by a Worker class - anything that implements `Firehed\\Workers\\Worker`.\n\n### `getName(): string`\nThis is an identifer for the type of worker.\n`return __CLASS__;` is a sensible implmentation, but may result in more work that desired when specifying the worker if running in the foreground.\n\n### `getNice(): int`\nThe `nice` level for the process, which controls the overall system priority.\nA number between -20 and 20.\n-20 is the highest priority (don't go this high, or you could make the system unresponsive); +20 is the lowest priority.\nReturn `Worker::NICE_DEFAULT` (0) to leave the priority unaffected.\n\n### `getProcessTitle(): string`\nIf this value is not empty, the manager will attempt to update the process title that's visible in utilities like `top`.\nDoes not work on all operating systems.\n\n### `getRunLimit(): int`\nExit the run loop after this many iterations.\nUseful to cleanly exit workers that may consume more memory than desirable.\nReturn `Worker::RUN_LIMIT_UNLIMITED` to not enforce a limit.\n\nNote that implementations should avoid relying this, although it's well understood that PHP code often leaves resources hanging when it was originally designed around the web's shared nothing \"work once and die\" model.\n\n### `work(): bool`\nPerform the actual work.\nThis should fetch a single job and perform it.\nImplementations may read a row out of a database, grab a job out of a work queue, etc.\n\nThe worker's `work()` method should only return `false` if no work was attempted (nothing in the queue, etc).\nIt should still return `true` if work was attempted and failed.\n\n## Using in Docker: Foreground Worker\n\nCall `WorkerManager-\u003erunInForeground($name)` to run a single worker in the foreground.\nThis is ideal for applications designed around containerization (Docker) where some higher-level process manager already exists.\n\nIt is highly recommended to create a single worker script and corresponding container, and control which worker to run with a CLI argument or environment variable.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffirehed%2Fworkers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffirehed%2Fworkers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffirehed%2Fworkers/lists"}