Remote cron service built using Node.js and MongoDB
JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
app Add minimal web GUI Jun 17, 2012
config Initial commit Jun 4, 2012
fixtures Initial commit Jun 4, 2012
lib Initial commit Jun 4, 2012
models Initial commit Jun 4, 2012
.gitignore Initial commit Jun 4, 2012
LICENSE Initial commit Jun 4, 2012
README.md Change API routes to be more RESTful Jun 17, 2012
app.js Add minimal web GUI Jun 17, 2012
package.json Add minimal web GUI Jun 17, 2012

README.md

cron-as-a-service

A simple remote cron service using Node.js and MongoDB.

Features

  • Each cron job polls a web resource via a GET request at regular intervals.
  • Familiar cron scheduling (e.g. '00 30 11 * * 2-6') (powered by node-cron).
  • Comprehensive RESTful API for creating, listing, updating and deleting cron jobs
  • Easy installation and zero administration

Installation

Clone the repository from GitHub and install dependencies using npm:

> git clone git://github.com/fzaninotto/cron-as-a-service.git
> npm install

Start the application with:

> node app

Head to the API root for a list of available resources:

http://localhost:8082/api/

Jobs CRUD

A job is composed of an expression and an url.

// to create a job, send a POST request to the /api/jobs route
curl -d 'expression=* * * * * *&url=http://localhost:8888' http://localhost:8082/api/jobs
// to list jobs, send a GET requst to the /api/jobs route
curl http://localhost:8082/api/job
// to update a job, send a PUT request to the /api/jobs/:id route
curl -X PUT -d 'expression=* * * * * *&url=http://localhost:8888' http://localhost:8082/api/jobs/4fcd284b87cf3b5a07000004
// to remove a job, send a DELETE request to the /api/jobs/:id route
curl -X DELETE http://localhost:8082/api/jobs/4fcd284b87cf3b5a07000004

The job expression follows the cron pattern syntax described here.

Tip: You can start the provided dummy target to test the job polling:

> node fixtures/dummyTarget.js

Customization

Uptime uses node-config to allow YAML configuration and environment support. Here is the default configuration, taken from config/default.yaml:

mongodb:
  server:   localhost
  database: cron
  user:     root 
  password:

server:
  port:     8082

To modify this configuration, create a development.yaml or a production.yaml file in the same directory, and override just the settings you need. For instance, to run the service on port 80 in production, create a production.yaml file as follows:

server:
  port:     80

LICENSE

The code is free to use and distribute, under the MIT license.

TODO

  • Web GUI
  • Record response status for each executed job
  • Run jobs in a separate process
  • Deal with web proxies