Nocturnal Pumpkin Maelstrom

    redis-docker-taskrunner

    0.2.1 • Public • Published

    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.

    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

    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:
    # 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= 
    1. Create your own Docker image and publish to container registry
    docker build -t yourrepo/redis-docker-taskrunner:latest .
    docker push yourrepo/redis-docker-taskrunner:latest # assume you logged into your account 
    1. 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
    1. Deploy cronjob to Kubernetes
    kubectl delete -f deploy/cronjob.yml # if you had prior version running 
    kubectl apply -f deploy/cronjob.yml

    Testing

    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

    Install

    npm i redis-docker-taskrunner

    DownloadsWeekly Downloads

    2

    Version

    0.2.1

    License

    MIT

    Unpacked Size

    60.1 kB

    Total Files

    35

    Last publish

    Collaborators

    • mikesparr