Chadburn is a scheduler alternative to cron, built on Go and designed for Docker environments.

Overview

Chadburn - a job schedulerGitHub version Testing Status

Chadburn is a modern and low footprint job scheduler for docker environments, written in Go. Chadburn aims to be a replacement for the old fashioned cron.

*** SPECIAL NOTE ***

Chadburn is a new project based on the previous and continuous work incorporated into Ofelia and a fork of Ofelia provided by @rdelcorro, of which Chadburn was forked from. This project was started as a result of needing a version of Ofelia that incorporated the following fixes:

  • Update tasks if docker containers are started, stopped, restarted, or changed
  • Do not require a dummy task on the Ofelia container just to use Chadburn.
  • Support INI and docker labels at the same time. The configs will simply be merged.
  • Do not require a restart in order to pick up new or remove tasks.

PremoWeb will be responsive to addressing issues raised in this project and will also be monitoring issues in the original Ofelia source code repository and applying changes that should be reflected in Chadburn.

Why Chadburn?

It has been a long time since cron was released, actually more than 28 years. The world has changed a lot and especially since the Docker revolution. Vixie's cron works great but it's not extensible and it's hard to debug when something goes wrong.

Many solutions are available: ready to go containerized crons, wrappers for your commands, etc. but in the end simple tasks become complex.

How?

The main feature of Chadburn is the ability to execute commands directly on Docker containers. Using Docker's API Chadburn emulates the behavior of exec, being able to run a command inside of a running container. Also you can run the command in a new container destroying it at the end of the execution.

Configuration

A wiki is being written to document how to use Chadburn. Caprover users can use a One Click App (coming soon) to deploy and implement scheduled jobs using Service Label Overrides.

For everyone else, here's the general approach to use Chadburn:

Jobs

Scheduling format is the same as the Go implementation of cron. E.g. @every 10s or 0 0 1 * * * (every night at 1 AM).

Note: the format starts with seconds, instead of minutes.

you can configure four different kind of jobs:

  • job-exec: this job is executed inside of a running container.
  • job-run: runs a command inside of a new container, using a specific image.
  • job-local: runs the command inside of the host running Chadburn.
  • job-service-run: runs the command inside a new "run-once" service, for running inside a swarm

See Jobs reference documentation for all available parameters.

INI-style config

Run with chadburn daemon --config=/path/to/config.ini

[job-exec "job-executed-on-running-container"]
schedule = @hourly
container = my-container
command = touch /tmp/example

[job-run "job-executed-on-new-container"]
schedule = @hourly
image = ubuntu:latest
command = touch /tmp/example

[job-local "job-executed-on-current-host"]
schedule = @hourly
command = touch /tmp/example


[job-service-run "service-executed-on-new-container"]
schedule = 0,20,40 * * * *
image = ubuntu
network = swarm_network
command =  touch /tmp/example

Docker labels configurations

In order to use this type of configurations, Chadburn need access to docker socket.

docker run -it --rm \
    -v /var/run/docker.sock:/var/run/docker.sock:ro \
        premoweb/chadburn:latest daemon --docker

Labels format: `chadburn.<JOB_TYPE>.<JOB_NAME>.<JOB_PARAMETER>=<PARAMETER_VALUE>. This type of configuration supports all the capabilities provided by INI files.

Also, it is possible to configure job-exec by setting labels configurations on the target container. To do that, additional label chadburn.enabled=true need to be present on the target container.

For example, we want chadburn to execute uname -a command in the existing container called my_nginx. To do that, we need to we need to start my_nginx container with next configurations:

docker run -it --rm \
    --label chadburn.enabled=true \
    --label chadburn.job-exec.test-exec-job.schedule="@every 5s" \
    --label chadburn.job-exec.test-exec-job.command="uname -a" \
        nginx

Now if we start chadburn container with the command provided above, it will execute the task:

  • Exec - uname -a

Or with docker-compose:

version: "3"
services:
  chadburn:
    image: premoweb/chadburn:latest
    depends_on:
      - nginx
    command: daemon --docker
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro

  nginx:
    image: nginx
    labels:
      chadburn.enabled: "true"
      chadburn.job-exec.datecron.schedule: "@every 5s"
      chadburn.job-exec.datecron.command: "uname -a"

Dynamic docker configuration

You can start Chadburn in its own container or on the host itself, and it will magically pick up any container that starts, stops or is modified on the fly. In order to achieve this, you simply have to use docker containers with the labels described above and let Chadburn take care of the rest.

Hybrid configuration (INI files + Docker)

You can specify part of the configuration on the INI files, such as globals for the middlewares or even declare tasks in there but also merge them with docker. The docker labels will be parsed, added and removed on the fly but also, the file config can be used to execute tasks that are not possible using just docker labels such as:

  • job-local
  • job-run

Use the INI file to:

  • Configure the slack or other middleware integration
  • Configure any global setting
  • Create a job-run so it executes on a new container each time
[global]
slack-webhook = https://myhook.com/auth

[job-run "job-executed-on-new-container"]
schedule = @hourly
image = ubuntu:latest
command = touch /tmp/example

Use docker to:

docker run -it --rm \
    --label chadburn.enabled=true \
    --label chadburn.job-exec.test-exec-job.schedule="@every 5s" \
    --label chadburn.job-exec.test-exec-job.command="uname -a" \
        nginx

Logging

Chadburn comes with three different logging drivers that can be configured in the [global] section:

  • mail to send mails
  • save to save structured execution reports to a directory
  • slack to send messages via a slack webhook

Options

  • smtp-host - address of the SMTP server.

  • smtp-port - port number of the SMTP server.

  • smtp-user - user name used to connect to the SMTP server.

  • smtp-password - password used to connect to the SMTP server.

  • email-to - mail address of the receiver of the mail.

  • email-from - mail address of the sender of the mail.

  • mail-only-on-error - only send a mail if the execution was not successful.

  • save-folder - directory in which the reports shall be written.

  • save-only-on-error - only save a report if the execution was not successful.

  • slack-webhook - URL of the slack webhook.

  • slack-only-on-error - only send a slack message if the execution was not successful.

Overlap

Chadburn can prevent that a job is run twice in parallel (e.g. if the first execution didn't complete before a second execution was scheduled. If a job has the option no-overlap set, it will not be run concurrently.

Installation

The easiest way to deploy Chadburn is using Docker. See examples above.

If don't want to run Chadburn using our Docker image you can download a binary from releases page.

Thank You to team Ofelia and it's contributors.

A special thanks to @rdelcorro for the work in fixing the issues referenced in this pull request https://github.com/mcuadros/ofelia/pull/137, despite this pull request having been ignored for 30 days. PremoWeb aims to ensure that open software is continously improve and will remain responsive to raised issues and pull requests.

Much thanks to the original work that went into Ofelia by it's author and contributors.

Issues
  • Job is always being deregistered

    Job is always being deregistered

    Hi, it seems that if I use a configuration file instead of the labels option in the docker-compose file my job is always deregistered for some reason:

    scheduler  | daemon.go:41 ▶ DEBUG Config file: /etc/chadburn.conf not found                                     │
    scheduler  | scheduler.go:45 ▶ NOTICE New job registered "users-tasks" - "uname -a" - "@every 20s" - ID: 1      │
    scheduler  | scheduler.go:56 ▶ DEBUG Starting scheduler                                                         │
    scheduler  | cron_utils.go:13 ▶ DEBUG start                                                                     │
    scheduler  | cron_utils.go:13 ▶ DEBUG schedule
    scheduler  | scheduler.go:50 ▶ NOTICE Job deregistered (will not fire again) "users-tasks" - "uname -a" - "@ever│
    y 20s" - ID: 1                                                                                                  │
    scheduler  | cron_utils.go:13 ▶ DEBUG removed
    

    My config.conf:

    [global]
    save-folder = /etc/logs
    
    [job-exec "users-tasks"]
    schedule = @every 20s
    container = api
    network = app-network
    command = uname -a
    

    My docker-compose.yml:

    api:
            image: some-cool-image
            labels:
                chadburn.enabled: "true"
    
    scheduler:
            image: premoweb/chadburn:latest
            container_name: scheduler
            restart: unless-stopped
            volumes:
                - /var/run/docker.sock:/var/run/docker.sock:ro
                - ./scheduler/config.conf:/etc/chadburn.conf
            depends_on:
                - api
            networks:
                - app-network
    

    But it works if I do this:

    api:
            image: some-cool-image
            labels:
                chadburn.enabled: "true"
                chadburn.job-exec.datecron.schedule: "@every 5s"
                chadburn.job-exec.datecron.command: "uname -a"
    
    scheduler:
            image: premoweb/chadburn:latest
            container_name: scheduler
            restart: unless-stopped
            volumes:
                - /var/run/docker.sock:/var/run/docker.sock:ro
            depends_on:
                - api
            networks:
                - app-network
    
    opened by theonelucas 15
  • ARM/v7 Support? (ready-to-use docker image)

    ARM/v7 Support? (ready-to-use docker image)

    This issue opened as a result of a question asked by @markfqs seeking an "off the shelf" solution for the arm/v7 architecture:

    See original comment raising the issue: https://github.com/mcuadros/ofelia/pull/137#issuecomment-934487429.

    I'm still new to Github's CI/CD tooling for automated Actions in Workflows but I'm pretty sure I can get you a usable product soon. While I do not currently have possession of any device with an ARM Cortex A9 chipset (ARM/v7), I do know that there hosting providers that do provide VPS accounts that use this architecture.

    In a quick search, I see that there are example Github workflows for building form ARM/v7. I'll try and see what I can do in the coming days to solve this for you.

    So, @markfqs, what kind of device using ARM/v7 version of the ARM Cortex A9 chipset you wish to see support for?

    opened by maietta 12
  • Email reporting: allow SMTP auth on unencrypted connections

    Email reporting: allow SMTP auth on unencrypted connections

    Copied from https://github.com/mcuadros/ofelia/issues/173 as Ofelia seems unmaintained:

    I want to use the email option together with gotify-smtp, which requires you to put the destination user that should receive the notifications in the authentication username field. However, Ofelia refuses to allow this:

    mail.go:57 ▶️ ERROR Mail error: "unencrypted connection"
    

    In general, I totally agree with this behaviour. But given I am only trying to communicate to another Docker container on the same network, there is no security issue that I can tell from using an unencrypted connection. It would be nice if there could be an option to allow authenticating over an unencrypted connection (disabled by default, of course). Thank you for considering :)

    opened by TheLastProject 7
  • Dockerhub Tags

    Dockerhub Tags

    Could you tag the docker images with version and hashes please?

    In reference to #9 since there is only a latest tag we can't pull the v1.0.0 release to get docker label detection working again.

    it also makes for following a practice of running containers are a specific version to avoid auto-upgrades.

    opened by mnestor 4
  • Detection of service label updates/changes (Broken / Re-write in progress)

    Detection of service label updates/changes (Broken / Re-write in progress)

    Today was really fced up.

    Tried to incorporate the changes from Ofelia, thinking they finally got around to accepting the pull request. I didn't verify this before bringing all the changes over. As a result, v1.0.1 fully breaks the ability to automatically see service label changes. You will need to pull v1.0.0 and build it yourself until this is fixed.

    We're back to operating in a world of restarting the scheduler.

    Hey @rdelcorro, when did you make your changes? I am trying to reverse engineer their changes and mix in your code changes to see if I can hammer out a quick repair.

    Spending my day tomorrow (Christmas day) working on this.

    opened by maietta 4
  • Known memory leak issue possible.

    Known memory leak issue possible.

    As maintainer of this Chadburn fork of Ofelia, I am concerned about the problem of memory leaks for at least some users.

    mcuadros/ofelia#107

    Thank you @helmut72 for raising this issue over at the Ofelia project. I'm tracking it here as well.

    A feature request to switch to Chadburn has been raised but another question was raised about the known memory leak issue. See:
    mailcow/mailcow-dockerized#4362

    I am creating this issue for others who may have come across this problem in Chadburn. Since this was raised with Ofelia project, the focus should remain there, however this issue will get updated when I or others discover relevant updates addressing the problem.

    opened by maietta 4
  • Reconsider name

    Reconsider name

    While Chronos is an amazing name, it's already in use by a well known cron repoacement: https://github.com/mesos/chronos

    TikTok eould also work but also taken 😅

    opened by Artanicus 3
  • Document Gotify notifications

    Document Gotify notifications

    I can confirm Gotify works great for me :)

    While the exact URL is documented on https://gotify.net/docs/pushmsg, it's not given when you add a new app to Gotify (just the token is), so I figured I'd document the exact URL format in the README too.

    opened by TheLastProject 1
  • Prometheus metrics

    Prometheus metrics

    At current it's a bit annoying to monitor chadburn to ensure that everything is working as intended. Even a basic health check is a bit hard to do since the service doesn't expose any TCP port (since there's no need), so there's no port to check for a response.

    A basic Prometheus metrics endpoint would solve for the basic "alive" check by providing an up metric and could be expanded to contain more useful metrics such as:

    • successful executions counter
    • failed executions counter
    • current registered services count
    • Execution time metrics
    opened by Artanicus 1
  • Config file cannot be loaded on startup

    Config file cannot be loaded on startup

    I'm not yet sure as to why this is happening, but my config file wont read at startup and thus I dont get logging right.

    I am using the latest docker container and I've tried mounting the config file via volume, copying it into /tmp in the container and even setting chmod to 777.

    I did also start chadburn a second time inside the container - with same results. Logging would be really great as I cannot get my jobs working. Surprisingly the config file gets loaded successfully for the jobs - even though they are not working.

    / # /usr/bin/chadburn daemon --config=/tmp/chadburn.conf 
    daemon.go:41 ▶ DEBUG Config file: /tmp/chadburn.conf not found
    scheduler.go:45 ▶ NOTICE New job registered "autoprint-test1" - "cd /app/autoprint/test1 && php -q index.php" - "@every 2m" - ID: 1
    scheduler.go:45 ▶ NOTICE New job registered "autoprint-test2" - "cd /app/autoprint/test2 && php -q index.php" - "@every 2m" - ID: 2
    scheduler.go:56 ▶ DEBUG Starting scheduler
    cron_utils.go:13 ▶ DEBUG start
    cron_utils.go:13 ▶ DEBUG schedule
    cron_utils.go:13 ▶ DEBUG schedule
    scheduler.go:50 ▶ NOTICE Job deregistered (will not fire again) "autoprint-test1" - "cd /app/autoprint/test1 && php -q index.php" - "@every 2m" - ID: 1
    scheduler.go:50 ▶ NOTICE Job deregistered (will not fire again) "autoprint-test2" - "cd /app/autoprint/test2 && php -q index.php" - "@every 2m" - ID: 2
    cron_utils.go:13 ▶ DEBUG removed
    cron_utils.go:13 ▶ DEBUG removed
    
    / # cat /tmp/chadburn.conf 
    [global]
    save-folder = /etc/logs
    
    [job-exec "autoprint-test1"]
    schedule = @every 2m
    container = autoprint
    network = mybridge
    command = cd /app/autoprint/test1 && php -q index.php
    
    [job-exec "autoprint-test2"]
    schedule = @every 2m
    container = autoprint
    network = mybridge
    command = cd /app/autoprint/test2 && php -q index.php
    
    / # ping autoprint
    PING autoprint (172.19.0.4): 56 data bytes
    64 bytes from 172.19.0.4: seq=0 ttl=64 time=0.112 ms
    64 bytes from 172.19.0.4: seq=1 ttl=64 time=0.075 ms
    ^C
    --- autoprint ping statistics ---
    2 packets transmitted, 2 packets received, 0% packet loss
    round-trip min/avg/max = 0.075/0.093/0.112 ms
    
    opened by boindil 4
  • Static only config without docker socket

    Static only config without docker socket

    Add support to run chadburn with static config and without docker socket

    Currently it breaks with:

    daemon.go:46 ▶ CRITICAL Can't start the app: Get "http://unix.sock/info": dial unix /var/run/docker.sock: connect: no such file or directory
    
    opened by olfway 4
  • Mail notifications fail with unknown certificate

    Mail notifications fail with unknown certificate

    We using custom CA on our SMTP server and we get following error. mail.go:57 ▶ ERROR Mail error: "x509: certificate signed by unknown authority"

    Any idea how to fix it?

    opened by rgomez-eng 3
  • Binary releases are missing

    Binary releases are missing

    https://github.com/PremoWeb/chadburn#installation says

    If don't want to run Chadburn using our Docker image you can download a binary from releases page.

    but the two releases 1.0.0 and 1.0.1 neither have binaries. only github automatic source tarballs:

    • https://github.com/PremoWeb/chadburn/releases/tag/v1.0.0
    • https://github.com/PremoWeb/chadburn/releases/tag/v1.0.1
    opened by glensc 1
  • git history and commits

    git history and commits

    What is the status of the fork? The old git commit history should be preserved and the new commits should have a meaningful name. In main should only have meaningful, ready and working commits. If you need help I can help you with pleasure!

    opened by jumoog 1
Releases(v1.0.3)
Statefulset-scheduler (aka sfs-scheduler)

statefulset-scheduler (aka sfs-scheduler) Installation I already upload docker i

Onur Yartaşı 2 Dec 19, 2021
Scheduler: the scheduler of distbuild written in Golang

scheduler Introduction scheduler is the scheduler of distbuild written in Go. Pr

distbuild 0 Feb 9, 2022
Scheduler - Scheduler package is a zero-dependency scheduling library for Go

Scheduler Scheduler package is a zero-dependency scheduling library for Go Insta

Javad Rajabzade 4 Jan 14, 2022
Linstor-scheduler-extender - LINSTOR scheduler extender plugin for Kubernetes

linstor-scheduler-extender LINSTOR scheduler extender plugin for Kubernetes whic

Andrei Kvapil 1 Feb 14, 2022
Crane scheduler is a Kubernetes scheduler which can schedule pod based on actual node load.

Crane-scheduler Overview Crane-scheduler is a collection of scheduler plugins based on scheduler framework, including: Dynamic scheuler: a load-aware

Crane 43 Jun 28, 2022
A simple Cron library for go that can execute closures or functions at varying intervals, from once a second to once a year on a specific date and time. Primarily for web applications and long running daemons.

Cron.go This is a simple library to handle scheduled tasks. Tasks can be run in a minimum delay of once a second--for which Cron isn't actually design

Robert K 210 May 4, 2022
Run Jobs on a schedule, supports fixed interval, timely, and cron-expression timers; Instrument your processes and expose metrics for each job.

A simple process manager that allows you to specify a Schedule that execute a Job based on a Timer. Schedule manage the state of this job allowing you to start/stop/restart in concurrent safe way. Schedule also instrument this Job and gather metrics and optionally expose them via uber-go/tally scope.

Sherif Abdel-Naby 57 Mar 28, 2022
Lightweight, fast and dependency-free Cron expression parser (due checker) for Golang (tested on v1.13 and above)

adhocore/gronx gronx is Golang cron expression parser ported from adhocore/cron-expr. Zero dependency. Very fast because it bails early in case a segm

Jitendra Adhikari 205 Jul 4, 2022
Easy and fluent Go cron scheduling

goCron: A Golang Job Scheduling Package. goCron is a Golang job scheduling package which lets you run Go functions periodically at pre-determined inte

Go Co Op 2k Jul 6, 2022
gron, Cron Jobs in Go.

gron Gron provides a clear syntax for writing and deploying cron jobs. Goals Minimalist APIs for scheduling jobs. Thread safety. Customizable Job Type

roylee0704 897 Jun 27, 2022
a cron library for go

cron Cron V3 has been released! To download the specific tagged release, run: go get github.com/robfig/cron/[email protected] Import it in your program as: im

Rob Figueiredo 9.9k Jul 4, 2022
分布式定时任务库 distributed-cron

dcron 分布式定时任务库 原理 基于redis同步节点数据,模拟服务注册。然后将任务名 根据一致性hash 选举出执行该任务的节点。 流程图 特性 负载均衡:根据任务数据和节点数据均衡分发任务。 无缝扩容:如果任务节点负载过大,直接启动新的服务器后部分任务会自动迁移至新服务实现无缝扩容。

libi 194 Jul 4, 2022
基于 Redis 和 Cron 的定时任务队列

RTask RTask 是 Golang 一款基于 Redis 和 Cron 的定时任务队列。 快速上手 您需要使用 Go Module 导入 RTask 工具包。 go get -u github.com/avtion/rtask 使用教程 package main import ( "con

Avtion 2 Oct 27, 2021
A cron-like strategy plugin for HashiCorp Nomad Autoscaler

Nomad Autoscaler Cron Strategy A cron-like strategy plugin, where task groups are scaled based on a predefined scheduled. job "webapp" { ... group

Johan Siebens 5 Feb 14, 2022
Go-based runner for Cron Control

Cron Control Runner A Go-based runner for processing WordPress cron events, via Cron Control interfaces. Installation & Usage Clone the repo, and cd i

Automattic 7 Jun 11, 2022
This package provides the way to get the previous timestamp or the next timestamp that satisfies the cron expression.

Cron expression parser Given a cron expression, you can get the previous timestamp or the next timestamp that satisfies the cron expression. I have us

gitploy.io 1 May 3, 2022
Graceful shutdown with repeating "cron" jobs (running at a regular interval) in Go

Graceful shutdown with repeating "cron" jobs (running at a regular interval) in Go Illustrates how to implement the following in Go: run functions ("j

Valentin Padurean (Ogg) 1 May 30, 2022
Zdpgo cron - 在golang中使用cron表达式并实现定时任务

zdpgo_cron 在golang中使用cron表达式并实现定时任务 项目地址:https://github.com/zhangdapeng520/zdpgo

张大鹏 1 Feb 16, 2022
Cloud-native, enterprise-level cron job platform for Kubernetes

Furiko Furiko is a cloud-native, enterprise-level cron and adhoc job platform for Kubernetes. The main website for documentation and updates is hosted

Furiko 148 Jul 2, 2022