pschlan / cron-job.org

cron-job.org Open Source project
GNU General Public License v2.0
1.4k stars 250 forks source link

cron-job.org

Build Status Build Status Build Status Build Status

Structure

chronos

Concept

chronos checks the MySQL database every minute to collect all jobs to execute. For every minute, a thread is spawned which processes all the jobs. Actual HTTP fetching is done using the excellent curl multi library with libev as library used to provide the event loop. Together with the c-ares resolver this allows for thousands of parallel HTTP requests.

cron-job.org supports storing the job results for the user's convenience. This can quickly lead to I/O bottlenecks when storing the result data in a MySQL database. (Which also has the downside that cleaning up old entries is extremely expensive.) To solve this issue, chronos stores the results in per-user per-day SQLite databases. Cleaning up old entries is as easy as deleting the corresponding day's databases.

The whole software is optimized on performance rather than on data integrity, i.e. when your server crashes or you have a power outage / hardware defect, the job history is most likely lost. Since this is volatile data anyway, it's not considered a big issue.

chronos can now run on multiple nodes. Each node requires an own MySQL server/database and stores its own jobs. The host running the web interface also manages the user database and an association between job and node. The web interface can create, delete, update and fetch jobs and job logs from the particular node via a Thrift-based protocol defined in the protocol folder.

Prerequisites

In order to build chronos, you need development files of:

To build, you need a C++14 compiler and cmake.

Building

  1. Create and enter a build folder: mkdir build && cd build
  2. Run cmake: cmake -DCMAKE_BUILD_TYPE=Release ..
  3. Build the project: make

Running

  1. Ensure you've imported the DB scheme from the database folder
  2. Customize chronos.cfg according to your system (especially add your MySQL login)
  3. Execute ./chronos /path/to/chronos.cfg

API

The API is written in PHP and needs to be hosted on a webserver (cron-job.org uses nginx with php-fpm). It is used by the console and the status page UI.

Prerequisites

Getting started

Notes

Frontend

The frontend is written in JavaScript using React and material-ui. You need npm to build it.

Prerequisites

Getting started

Status Page Frontend

The status page frontend is written in JavaScript using React and material-ui. You need npm to build it.

Prerequisites

Getting started

Example Environment (using Docker Compose)

To quickly start an example environment of most of the cron-job.org system, you can use docker-compose:

Important: The Docker environment contained in this repo is intended as an example / development environment and is not tailored for production usage, especially with regard to security.

The following containers will be started:

General notes