# redis-docker-taskrunner

> Simple task runner that runs pending tasks in Redis when Docker container starts

Latest version **0.2.1** (published 2018-11-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install redis-docker-taskrunner
pnpm add redis-docker-taskrunner
yarn add redis-docker-taskrunner
bun add redis-docker-taskrunner
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2018-11-29 |
| First published | 2018-05-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 58.7 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Mike Sparr |
| Maintainers | mikesparr |
| Keywords | task, runner, scheduler, jobs, docker, redis, kubernetes, cron |

## Links

- npm: https://www.npmjs.com/package/redis-docker-taskrunner
- Repository: https://github.com/mikesparr/redis-docker-taskrunner
- Homepage: https://github.com/mikesparr/redis-docker-taskrunner#readme
- Issues: https://github.com/mikesparr/redis-docker-taskrunner/issues
- npm.io page: https://npm.io/package/redis-docker-taskrunner

## Dependencies (3)

- [redis](https://npm.io/package/redis.md) ^2.8.0
- [@types/redis](https://npm.io/package/@types/redis.md) ^2.8.6
- [redis-task-scheduler](https://npm.io/package/redis-task-scheduler.md) ^0.2.0

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 0.2.1 (latest) — 2018-11-29
- 0.1.4 — 2018-05-26
- 0.1.3 — 2018-05-26

## 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 git@github.com: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 Redis

4. 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 git@github.com: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

---
_Source: https://npm.io/package/redis-docker-taskrunner · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
