{"id":25009323,"url":"https://github.com/tarantool-php/jobserver","last_synced_at":"2025-04-12T19:09:17.337Z","repository":{"id":57065176,"uuid":"109598971","full_name":"tarantool-php/jobserver","owner":"tarantool-php","description":"A skeleton application for creating and processing background jobs.","archived":false,"fork":false,"pushed_at":"2021-07-15T18:56:28.000Z","size":185,"stargazers_count":15,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-12T19:09:10.130Z","etag":null,"topics":["background-jobs","jobserver","skeleton","tarantool","worker"],"latest_commit_sha":null,"homepage":"","language":"PHP","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/tarantool-php.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["rybakit"]}},"created_at":"2017-11-05T17:07:16.000Z","updated_at":"2024-11-05T11:32:41.000Z","dependencies_parsed_at":"2022-08-24T07:50:12.621Z","dependency_job_id":null,"html_url":"https://github.com/tarantool-php/jobserver","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/tarantool-php%2Fjobserver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarantool-php%2Fjobserver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarantool-php%2Fjobserver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarantool-php%2Fjobserver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tarantool-php","download_url":"https://codeload.github.com/tarantool-php/jobserver/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248618277,"owners_count":21134200,"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":["background-jobs","jobserver","skeleton","tarantool","worker"],"created_at":"2025-02-05T04:39:23.323Z","updated_at":"2025-04-12T19:09:17.307Z","avatar_url":"https://github.com/tarantool-php.png","language":"PHP","funding_links":["https://github.com/sponsors/rybakit"],"categories":[],"sub_categories":[],"readme":"# JobServer\n\nJobServer is a skeleton repository used for creating and processing background jobs \nbacked by [Tarantool](http://tarantool.org/). It contains configuration files and folders \nyou will need for quick start from scratch.\n\n\n## Installation\n\nThe recommended way to create a new application is through [Composer](http://getcomposer.org):\n\n```sh\ncomposer create-project tarantool/jobserver -s dev\n```\n\n\n## Quick start\n\nFirst, create your own `docker-compose.override.yml` file by copying \n[docker-compose.override.yml.dist](docker-compose.override.yml.dist) (or \n[docker-compose.override.yml.full.dist](docker-compose.override.yml.full.dist) if you want to test the full setup \nincluding a Tarantool cluster with automatic failover and monitoring tools) and customize to your needs. \nDo the same for [.env.dist](.env.dist) and all `*.dist` files located in [app/config](app/config) and [res](res).\n\nThen, browse to the project directory and execute this command:\n\n```sh\ndocker-compose up -d\n```\n\nAfter the command has completed successfully, you'll have a running server ready to execute jobs.\nIf you open a log file in follow mode (`tail -f var/log/workers.log`), you'll see something like the following:\n\n```sh\n[2017-11-19 00:00:23] default:worker.DEBUG: Idling... [] []\n[2017-11-19 00:00:24] default:worker.DEBUG: Idling... [] []\n[2017-11-19 00:00:25] default:worker.DEBUG: Idling... [] []\n```\n\nLet's now try to add a task to the queue. This repository comes with a [demo job](src/UseCase/Greet/GreetHandler.php)\nthat writes a greeting to the log. By running the following command: \n\n\n```sh\ndocker-compose exec worker ./jobserver queue:put default -H tarantool \\\n    '{\"payload\": {\"service\": \"greet\", \"args\": {\"name\": \"foobar\"}}}'\n```\n\nwe add a task to the `default` queue with a job payload, \nwhere `greet` is a job name and `foobar` is an argument passing to a job callable. \n\nNow in the log you will see that the job is executed:\n\n```sh\n[2017-11-19 00:00:32] jobserver.INFO: HELLO FOOBAR [] []\n[2017-11-19 00:00:33] default:worker.DEBUG: Idling... [] []\n[2017-11-19 00:00:34] default:worker.INFO: Task #0 was successfully processed. {\"payload\":{\"args\":{\"name\":\"foobar\"},\"service\":\"greet\"}} []\n``` \n\nAlso, you can run the job directly in the console, bypassing the queue:\n\n```sh\ndocker-compose exec worker ./jobserver -vvv handler:greet foobar\n```\n\nTo be able to run a job from the console, you need to write an adapter for the symfony command \nand register it in [app/config/commands.php](app/config/commands.php). This is how the adapter \nlooks like for GreetHandler: [GreetCommand](src/UseCase/Greet/GreetCommand.php).\n\nTo see a list of all registered commands, run:\n\n```sh\ndocker-compose exec worker ./jobserver\n```\n\n\n## Tarantool\n\nTo use a web interface for Tarantool, open your browser and access \nthe [http://localhost:8001](http://localhost:8001/) address (make sure that \nDocker containers are running).\n\nTo get into Tarantool console as admin on a running Docker container, execute:\n\n```sh\ndocker-compose exec tarantool tarantoolctl connect /var/run/tarantool/tarantool.sock\n```\n\nOn a server:\n\n```sh\nsudo tarantoolctl enter jobserver_instance\n```\n\nOn the server as a job queue user:\n\n```sh\nsudo tarantoolctl connect $TNT_JOBQUEUE_USER:$TNT_JOBQUEUE_PASSWORD@$TNT_JOBQUEUE_HOST:3301\n```\n\n\n## Monitoring\n\nOpen your browser and access:\n\n * [Prometheus](http://localhost:9090/) \n * [Alert manager](http://localhost:9093/)\n * [Grafana](http://localhost:3000/) \n\n![Grafana](/res/grafana/screenshot.png)\n\n\u003e *Make sure to use a copy of [docker-compose.override.yml.full.dist](docker-compose.override.yml.full.dist) \n\u003e to have all monitoring containers running.*\n\n\n## Testing\n\n```sh\ndocker-compose exec worker vendor/bin/phpunit\n```\n\n\n## Debugging\n\nTo debug a job runner, first, stop the worker container\n\n```sh\ndocker-compose stop worker\n``` \n\nThen, start listening for php debug connections and then execute:\n\n```sh\nLOCAL_IP=\u003cyour-local-ip\u003e docker-compose run --rm worker bash -c ' \\\n    TNT_JOBQUEUE_PASSWORD=jobserver \\\n    vendor/bin/jobqueue run default \\\n    --config app/config/jobqueue.php \\\n    --executors-config app/config/executors.php \\\n    --user jobserver \\\n    --host tarantool \\\n'\n```\n\n\u003e *Check [this manual](https://confluence.jetbrains.com/display/PhpStorm/Simultaneous+debugging+sessions+with+PhpStorm) \n\u003e to learn how to debug multiple processes (for example, the runner and background jobs) \n\u003e simultaneously in PhpStorm.*\n\n\n## License\n\nThe library is released under the MIT License. See the bundled [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftarantool-php%2Fjobserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftarantool-php%2Fjobserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftarantool-php%2Fjobserver/lists"}