Giter VIP home page Giter VIP logo

cronenberg's Introduction

cronenberg

Build Status Go Report Card Documentation

It's like cron, but kinda twisted.

Installation

You can either download the appropriate release from the releases page or install via go get:

go get -u github.com/ess/cronenberg/cmd/cronenberg

Basics

Cronenberg works similarly to the standard cron that you already know and love, but with a few differences:

  • It is not meant to be run as a system service
  • It does not use a traditional crontab
  • Jobs for a given cronenberg instance are loaded from a YAML file
  • It supports locking jobs (jobs that can only ever have one running instance)
  • It logs to STDOUT
  • It supports both incoming (from the system) and job-scoped environment variables

In short, this is the cron implementation that you run along side your 12-factor application.

Jobs File

There is not a hard-coded location for your jobs file. Instead, you pass the jobs file as the first argument to the cronenberg command like so:

cronenberg /path/to/my/jobs/file.yml

This is just a YAML file containing an array of Job objects. Here's an example jobs file:

# Job objects require a name, a command, and a schedule (when). You can also
# specify a description, whether or not the job locks, and a hash of environment
# variables for the job.

# This is just a normal job that runs every minute
- name: what-am-i
  command: echo "I am a command"
  when: "* * * * *"

# This is a locking job that is scheduled to run every minute so long as there
# is not already an instance of the job in progress.
- name: picky-picky
  command: 'echo "I am a picky command" ; sleep 70'
  when: "* * * * *"
  lock: true

# This is a job that runs every five minutes and specifies an environment
# variable. If this variable is also set in cronenberg's executing shell, the
# value configured here takes precedence.
- name: know-your-environment
  command: echo $flibberty
  when: "*/5 * * * *"
  env:
    flibberty: gibbets

History

  • v1.0.0 - Initial Release

cronenberg's People

Contributors

ess avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cronenberg's Issues

Running jobs

Provided a valid job in a jobs file, when I pass that job file to cronenberg, the job in question should be loaded and executed on the proper schedule.

Running locking jobs

Provided a valid locking job in a jobs file, when I pass that job file to cronenberg, the job in question should be loaded and executed on the proper schedule, but only one instance of the job should be allowed to run at any given time. Attempts to run a locking job while another instance of the job already exists result in a message that the job is already running and/or is locked.

Specifying a log file

Cronenberg always logs to STDOUT. We should also be able to specify a file to which logs should be written (in addition to STDOUT).

The directory tree (dirname) for the file must exist and must be writable by the user that executes cronenberg.

Using incoming environment variables

Standard cron implementations nuke any environment variables that are set within their running shell. We want to do the opposite. If FOO=bar is set in the shell that launches cronenberg, we want jobs to receive FOO=bar.

Using job-scoped environment variables

Given a valid job with env vars specified in a jobs file, when I pass that jobs file to cronenberg, the job should be run on its schedule, and the env vars configured for the job should be present. Also, job-scoped env vars take precedence over those specified in the calling environment.

Consider the following job:

- name: env-test
  command: echo $FOO
  when: "* * * * *"
  env:
    FOO: bar-job

Whether or not the shell from which cronenberg is launched has a FOO variable set, the output of this job should be "bar-job"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.