Skip to content

A container runs in Swarm cluster as a service, manages scheduled/delayed/cron based jobs for you.

License

Notifications You must be signed in to change notification settings

betarabbit/swarm-job-scheduler

Repository files navigation

Docker Swarm Job Scheduler

License

Introduction

A container runs in Swarm cluster as a service, manages scheduled/delayed/cron based jobs for you.

How it works

This service relies on bull to manage jobs, add job queue and job information in redis, and registers job prossoror as an one-time container.

Features

  • Cron scheduled job in container
  • Swarm master/worker separation
  • Support private image repository
  • Swarm network attachable
  • Send job execution status to Graphite

Usage

Add job configuration in config/default.json.

{
    "name": "Ping Redis",
    "image": "private/busybox",
    "registry": {
    "username": "REGISTRY_USERNAME",
    "password": "REGISTRY_PASSWORD",
    "serveraddress": "REGISTRY_SERVER"
    },
    "cmd": [ "ping", "redis", "-c", "1" ],
    "networkName": "NETWORK_NAME",
    "location": "manager",
    "repeat": {
    "cron": "* * * * *"
    }
}

Add this service as a global service in Swarm stack, bind /var/run/docker.sock and /var/lib/docker/containers as volumes.

scheduler:
    image: scheduler:latest
    networks:
      - attachable_net
    volumes:
      - type: bind
        source: /var/run/docker.sock
        target: /var/run/docker.sock
      - type: bind
        source: /var/lib/docker/containers
        target: /var/lib/docker/containers
    environment:
      NODE_ENV: production
      REDIS: "redis://redis:6379"
      NETWORK_NAME: "test_attachable_net"
      REGISTRY_USERNAME: "PALCEHOLDER_REGISTRY_USERNAME"
      REGISTRY_PASSWORD: "PALCEHOLDER_REGISTRY_PASSWORD"
      REGISTRY_SERVER: "PALCEHOLDER_REGISTRY_SERVER"
      GRAPHITE: "plaintext://graphite:2003/"
    configs:
      - source: task_config
        target: /opt/scheduler/config/default.json
    logging:
      driver: "json-file"
      options:
        max-size: "50m"
        max-file: "10"
    deploy:
      mode: global
      update_config:
        parallelism: 2
        delay: 10s
      restart_policy:
        condition: on-failure

About

A container runs in Swarm cluster as a service, manages scheduled/delayed/cron based jobs for you.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published