{"id":25368416,"url":"https://github.com/discoverygarden/gearman-init","last_synced_at":"2025-10-30T04:30:39.424Z","repository":{"id":34731293,"uuid":"38709334","full_name":"discoverygarden/gearman-init","owner":"discoverygarden","description":"Upstart script(s) for Gearman workers.","archived":false,"fork":false,"pushed_at":"2023-01-31T17:53:03.000Z","size":61,"stargazers_count":3,"open_issues_count":1,"forks_count":7,"subscribers_count":18,"default_branch":"master","last_synced_at":"2024-04-15T03:05:53.298Z","etag":null,"topics":["gearman","init","systemd","sysvinit","tool"],"latest_commit_sha":null,"homepage":null,"language":"Shell","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/discoverygarden.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}},"created_at":"2015-07-07T19:15:33.000Z","updated_at":"2023-02-02T09:56:45.000Z","dependencies_parsed_at":"2023-02-16T21:45:58.327Z","dependency_job_id":null,"html_url":"https://github.com/discoverygarden/gearman-init","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discoverygarden%2Fgearman-init","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discoverygarden%2Fgearman-init/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discoverygarden%2Fgearman-init/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discoverygarden%2Fgearman-init/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/discoverygarden","download_url":"https://codeload.github.com/discoverygarden/gearman-init/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238930064,"owners_count":19554122,"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":["gearman","init","systemd","sysvinit","tool"],"created_at":"2025-02-15T00:37:53.187Z","updated_at":"2025-10-30T04:30:37.787Z","avatar_url":"https://github.com/discoverygarden.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Upstart: Gearman Worker Scripts\n\n## Introduction\n\nUpstart scripts/configuration to start Gearman workers.\n\n## Requirements\n\nThis module requires the following modules/libraries:\n\n* [Islandora Job](https://github.com/discoverygarden/islandora_job)\n* Gearman CLI Script (Ubuntu: \"gearman\" package)\n\n## Installation\n\nClone/unzip into `/opt` such that we have:\n* `/opt/gearman-init/gearman-defaults.sh` and\n* `/opt/gearman-init/gearman-worker.sh`\n\nProvide any configuration necessary in `/etc/default/gearman-workers`:\n\n| Variable | Default | Description |\n| -------- | ------- | ----------- |\n| `DRUPAL_ROOT` | `/var/www/drupal7` | Path to Drupal's root installation directory, so we can call Drush in the correct context. |\n| `DRUSH` | The result of `which drush`. | Path of the `drush` executable. |\n| `CPU_COUNT` | The number of CPU cores present on the system. | Something of a misnomer? The number of worker processes to create. |\n| `GEARMAN_HOST` | The configured value from the \"default\" Drupal site. | The host/IP of the Gearman server. |\n| `GEARMAN_PORT` | The configured value from the \"default\" Drupal site. | The port to connect to on the Gearman server host. |\n| `GEARMAN_BIN` | The result of `which gearman`. | Path of the `gearman` CLI executable. |\n| `GEARMAN_USER` | `www-data` | The user as which to run Gearman workers. |\n| `ROUTER` | The Drush command `islandora-job-router`, as user 1 and at `DRUPAL_ROOT`. | The routing command workers should send the Gearman payload to for processing. |\n| `SITE_URI_LIST` | The \"Site URI\" portion of each entry in `drush @sites status` | A space-separated list of sites to get worker functions for. |\n| `CUSTOM_WORKER_FUCTIONS` | String of functions for a custom worker | formated as such: \"-f function1 -f function2\". Defaults to \"-f default\"   |\n\n## upstart\n\nCopy the `upstart/gearman-workers.conf` and `upstart/gearman-worker.conf` files into `/etc/init`.\n\nThe workers should start and stop automatically at boot/shutdown (currently following/preceding `mysql` of startup/shutdown; may be desirable to make into configuration at some point?).\n\nTo start the workers immediately:\n```bash\nstart gearman-workers\n```\n\n## sysvinit\n\nCopy the `sysvinit/gearman-workers` and `sysvinit/gearman-worker` files into `/etc/init.d`.\n\nEnsure permissions are 755\n\nIf gearmand processes has a different name, the gearman-worker and gearman-workers files will need to be updated at `# Required-Start:`\n\nTo have the gearman workers start on system boot, run the following:\n```bash\n# UBUNTU:\n/usr/sbin/update-rc.d gearman-workers defaults 99 20\n# REDHAT:\nchkconfig --add gearman-workers\n```\n\nTo start the workers immediately:\n```bash\n/etc/init.d/gearman-workers start\n```\n## systemd\n\nCopy `systemd/*` files into /etc/systemd/system you may have to modify the `After=` in `gearmand.service` depending on how split out the stack is. \n\n### Mysql on a different server\n\nThe portopen@.service file can be used to wait for mysql to be started on a different server before gearmand is started, copy the file to /etc/systemd/system and run `systemctl enable portopen@localhost.service` replace localhost with the hostname of your mysql server.\n\nUpdate the gearmand service file After= Requires= PartOf= to be the same as `portopen@localhost.service` that was enabled.\n\n### Enable on boot\nwhere `n` is the total number of `Requires=` added to the `gearman-workers.target`\n\n```\nsystemctl enable gearman-worker@{1..n}.service\n```\n\n### Status/start/stop\n```\nsystemctl status gearman-workers.target\nsystemctl start gearman-workers.target\nsystemctl stop gearman-workers.target\n```\n\nMost options in the /etc/default/gearman-workers file has to be set, specially the path to binary ones as these are not available to the system at boot time.\n\n## Custom Worker\n(optional)\n\n### Add custom function\n\nAdd your custom working functions to `/etc/default/gearman-workers` in the following format:\n```\nCUSTOM_WORKER_FUCTIONS=\"-f function1 -f function2 -f function3\"\n```\n\nEnsure total number of workers does not exceed total number of CPU cores. May have to configure the `CPU_COUNT` var as well.\n\n### systemd\n\nStop workers as we are going to edit the gearman-workers.target file.\n\n```\nsystemctl stop gearm-workers.target\n```\n\nCreate custom workers service file.\n\n```\ncat \u003c\u003cEOT \u003e/etc/systemd/system/gearman-custom-worker@.service\n#gearman-worker jobs process, requires gearmand - DGI\n[Unit]\nDescription=Gearman Custom Worker %i\nRequires=gearman-job-server.service\nPartOf=gearman-workers.target\n\n[Service]\nEnvironment=OMP_THREAD_LIMIT=1\nWorkingDirectory=/opt/gearman-init\nUser=www-data\nExecStart=/opt/gearman-init/gearman-custom-worker.sh %i\nKillMode=process\n\n[Install]\nWantedBy=multi-user.target\nEOT\n```\n\nEdit `/etc/systemd/system/gearman-workers.target` to reflect that you now need to start custom workers.\neg.\n\n```\n[Unit]\nDescription=Gearman Workers\nRequires=gearman-worker@1.service\nRequires=gearman-custom-worker@1.service\nRequires=gearman-custom-worker@2.service\n```\n\n#### Enable on boot\n\nJust like the standard workers above, we have to enable or disable what we want to start with systemctl\n\n```\nsystemctl enable gearman-custom-worker@{1..2}.service\n```\n\nStart your workers\n\n```\nsystemctl start gearman-workers.taget\n```\n\n### Upstart\n\nCopy `upstart/gearman-custom-worker.conf` files into `/etc/init`.\n\n```\nstop gearman-workers\nstart gearman-workers\n```\n\nYour Custom worker should start with all the others.\n\n\n## Check workers\n\nCheck that the workers are configured as you like with `gearadmin --status`\n\n```\nroot@ingest:~# gearadmin --st\nis3b-ro\t0\t0\t1\nijj-d\t0\t0\t3\nis3b-do\t0\t0\t1\nis3b-rc\t0\t0\t1\nis3b-bc\t0\t0\t1\nis3b-bo\t0\t0\t1\nis3b-dc\t0\t0\t1\n.\n```\n\n## Note\n\nThere is a bug in gearman that may cause issue if the listening host/IP doesn't match the worker connection host/IP, ensure these are the same. \n\n## Troubleshooting/Issues\n\nHaving problems or solved a problem? Contact [discoverygarden](http://support.discoverygarden.ca).\n\n## Maintainers/Sponsors\n\nCurrent maintainers:\n\n* [discoverygarden Inc.](http://www.discoverygarden.ca)\n\n## Development\n\nIf you would like to contribute to this module, please check out our helpful\n[Documentation for Developers](https://github.com/Islandora/islandora/wiki#wiki-documentation-for-developers)\ninfo, [Developers](http://islandora.ca/developers) section on Islandora.ca and\ncontact [discoverygarden](http://support.discoverygarden.ca).\n\n## License\n\n[GPLv3](http://www.gnu.org/licenses/gpl-3.0.txt)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiscoverygarden%2Fgearman-init","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiscoverygarden%2Fgearman-init","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiscoverygarden%2Fgearman-init/lists"}