Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mikesparr/redis-docker-taskrunner
Simple task runner that executes pending tasks in Redis on container startup
https://github.com/mikesparr/redis-docker-taskrunner
docker events jobs redis scheduler task-runner typescript
Last synced: about 6 hours ago
JSON representation
Simple task runner that executes pending tasks in Redis on container startup
- Host: GitHub
- URL: https://github.com/mikesparr/redis-docker-taskrunner
- Owner: mikesparr
- License: mit
- Created: 2018-05-22T18:17:29.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-11-29T21:56:10.000Z (about 6 years ago)
- Last Synced: 2024-12-21T19:02:31.516Z (20 days ago)
- Topics: docker, events, jobs, redis, scheduler, task-runner, typescript
- Language: TypeScript
- Size: 99.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Redis Docker Task Runner
This app is designed to be run via a Kubernetes `CronJob` but could be run independently,
or as a standalone Docker app. It connects to defined Redis database, and checks for pending
tasks on defined `channel`, and performing defined task.By default, this will re-publish the task to a Redis `PubSub` channel, but can be extended
to do anything desired.# Requirements
You need Redis to be running.# Usage
## Kubernetes (CronJob)
This is the quick and dirty test, but you'll likely want to clone and change manifest and `ENV`
variables.```bash
kubectl apply -f https://raw.githubusercontent.com/mikesparr/redis-docker-taskrunner/master/deploy/cronjob.yml
```## Publishing jobs
See the tests for data format to publish to Redis. However a convenience npm module exists called `redis-task-scheduler`
that you can use. Simply `npm install redis-task-scheduler` (or `yarn add redis-task-scheduler`) and follow it's instructions.
Both these components were designed to work as optional handler for `Delayed` actions in npm module `redis-workflow`. The
default action for tasks is to republish the context object to Redis PubSub when scheduled time arrives for workflow to process
it.## Customizing
This app can be run locally, on any server (likely Linux environment using cron but also Windows with scheduler).
It is designed to run in Kubernetes using `CronJob`, but you could deploy it anywhere and create your own cron
to `*/1 * * * * /usr/local/bin/node /path/to/app/index.js` for example.### Clone repo and install dependencies locally
```bash
git clone [email protected]:mikesparr/redis-docker-taskrunner.git
cd redis-docker-taskrunner
npm install
```### Edit files to your liking
1. Create a `.env` file and customize:
```bash
# default env vars for scheduler app
export SCHEDULER_NAME="Default"
export SCHEDULER_CHANNEL="scheduler"
export SCHEDULER_DB_HOST="localhost"
export SCHEDULER_DB_PORT="6379"
#export SCHEDULER_DB_NAME=
#export SCHEDULER_DB_PASS=
```2. Create your own Docker image and publish to container registry
```bash
docker build -t yourrepo/redis-docker-taskrunner:latest .
docker push yourrepo/redis-docker-taskrunner:latest # assume you logged into your account
```3. Edit the params in `/deploy/cronjob.yml` for your Kubernetes environment
* edit the `image` to point to `yourrepo/redis-docker-taskrunner:latest`
* edit the `env` params to point to your instance of Redis4. Deploy cronjob to Kubernetes
```bash
kubectl delete -f deploy/cronjob.yml # if you had prior version running
kubectl apply -f deploy/cronjob.yml
```# Testing
```bash
git clone [email protected]:mikesparr/redis-docker-taskrunner.git
cd redis-docker-taskrunner
npm install
npm test
npm run coverage # optional
```# Contributing
I haven't thought that far ahead yet. I needed this for a project I'm working on.# License
MIT