From 41ae3910a8622c91607b6ba60eb0fb3393b6f560 Mon Sep 17 00:00:00 2001 From: Kaypee Date: Thu, 12 Oct 2023 00:12:29 +0000 Subject: [PATCH] Update readme to include how to run examples with docker compose (#73) * Add black to pre commit hooks * Update readme to include how to run examples with docker compose --- .pre-commit-config.yaml | 4 ++++ README.md | 52 +++++++++++++++++++++++++++++++++++++---- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 09a60bf..2ecd589 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,3 +25,7 @@ repos: hooks: - id: pyupgrade args: [--py36-plus] + - repo: https://github.com/ambv/black + rev: 22.6.0 + hooks: + - id: black \ No newline at end of file diff --git a/README.md b/README.md index 4905670..0db4d91 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ Brokerless task queue for python based on 0Mq ======================== * Configuring Environment Variables: - - WORKER_HOST= - - WORKER_PORT= + - WORKER_HOST         # The IP address to expose running workers on + - WORKER_PORT               # The port number workers should listen on -- `If not set defaults to localhost:5690` @@ -52,7 +52,51 @@ long_running_task.run(param="dowork") - Fast - Open source -### Using a container orchestration technology: + +### Running Zebrok examples with docker compose +* First clone the repository using the command `git clone git@github.com:kaypee90/zebrok.git` +* Change directory into the zebrok directory and run `docker compose up` command to start the worker and publisher containers. +* Access the shell for the **worker** container and run the command `python examples/start.py` to start the workers. +* From a different terminal window, access the shell for the running **publisher** container and run the command `python examples/client.py` to queue 2 jobs to be processed. +* Once these commands are executed you should see 2 tasks processed successfully in the publisher terminal. + + +**Sample output:** +``` +** 2 ZEBROK TASKS DISCOVERED! +===================================================== + * long_running_task_one + * long_running_task_two +===================================================== +2023-10-11 23:45:14,227 zebrok.discovery INFO:** 2 ZEBROK TASKS DISCOVERED! +===================================================== + * long_running_task_one + * long_running_task_two +===================================================== +starting worker on: tcp://172.21.0.3:5691 +2023-10-11 23:45:14,236 zebrok.worker INFO:starting worker on: tcp://172.21.0.3:5691 +starting worker on: tcp://172.21.0.3:5692 +2023-10-11 23:45:14,237 zebrok.worker INFO:starting worker on: tcp://172.21.0.3:5692 +starting worker on: tcp://172.21.0.3:5693 +starting worker on: tcp://172.21.0.3:5690 +2023-10-11 23:45:14,238 zebrok.worker INFO:starting worker on: tcp://172.21.0.3:5693 +2023-10-11 23:45:14,238 zebrok.worker INFO:starting worker on: tcp://172.21.0.3:5690 +sending task to slave worker +2023-10-11 23:48:07,297 zebrok.worker INFO:sending task to slave worker +sending task to slave worker +received task: long_running_task_one +2023-10-11 23:48:07,299 zebrok.worker INFO:sending task to slave worker +2023-10-11 23:48:07,299 zebrok.worker INFO:received task: long_running_task_one +received task: long_running_task_two +2023-10-11 23:48:07,300 zebrok.worker INFO:received task: long_running_task_two +Sent mail to, samplemail@mail.com +Hello, Kay Pee +DONE!!! +DONE!!! +``` + + +### Using a container orchestration technology (like Kubernetes): - `number_of_slaves` must always be set to 0, then you can spin a number of replicas for the workers. -- `WORKER_HOST`Environment variable for a worker must always be `*` +- `WORKER_HOST` Environment variable for a worker must always be `*`