Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ryotarai/redis-queue-worker
https://github.com/ryotarai/redis-queue-worker
Last synced: 9 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/ryotarai/redis-queue-worker
- Owner: ryotarai
- Created: 2020-01-08T00:44:45.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-01-08T08:27:32.000Z (almost 5 years ago)
- Last Synced: 2023-03-15T22:35:25.756Z (almost 2 years ago)
- Language: Go
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# redis-queue-worker
## Usage
Put jobs into a queue:
```
$ redis-cli lpush examplequeue foo
(integer) 1
$ redis-cli lpush examplequeue bar
(integer) 2
$ redis-cli lpush examplequeue baz
(integer) 3
```The job string will be passed to a worker command via stdin.
Start a worker:
```
$ mkdir /tmp/redis-queue-worker-example
$ redis-queue-worker start --redis-addr localhost:6379 --redis-queue-key examplequeue -- sh -c 'input=$(cat); touch /tmp/redis-queue-worker-example/$input'
2020-01-08T09:57:59+09:00 INF Starting redis-queue-worker... redisAddr=localhost:6379 redisDB=0 redisQueueKey=examplequeue
2020-01-08T09:57:59+09:00 INF Executing a command command=["sh","-c","input=$(cat); touch /tmp/$input"] job=foo
2020-01-08T09:57:59+09:00 INF Succeeded to run a job job=foo
2020-01-08T09:57:59+09:00 INF Executing a command command=["sh","-c","input=$(cat); touch /tmp/$input"] job=bar
2020-01-08T09:57:59+09:00 INF Succeeded to run a job job=bar
2020-01-08T09:57:59+09:00 INF Executing a command command=["sh","-c","input=$(cat); touch /tmp/$input"] job=baz
2020-01-08T09:57:59+09:00 INF Succeeded to run a job job=baz
2020-01-08T09:57:59+09:00 INF Exiting as no job is in queue
``````
$ ls /tmp/redis-queue-worker-example
foo bar baz
```## Build
```
make build
```