Naptime is a project mainly written in Clojure, it's free.
REST based URL hook scheduler
Naptime is an application that calls http endpoints at fixed intervals.
mongod
.cd
into the naptime directory.lein deps && lein swank
.naptime.dev
namespace. This will
start the web process and 1 worker.http://localhost:8080
.heroku create --stack cedar
git push heorku master
heroku config:add
. You can use
MongoHQ for a free 16 meg mongo database.http://<your-app-name>.herokuapp.com
Naptime's configured (dev and production) through several environment variables.
MONGO_DB
-- Mongo db name.MONGO_HOST
MONGO_PORT
MONGO_USER
(if appicable)MONGO_PASSWORD
(if applicable)WORKER_MAX_CAPACITY
-- Max number of concurrent http requests per worker.WEB_MAX_THREADS
-- Max number of threads used to serve HTTP
requests to the web interface.WEB_WORKER_MAX_CAPACITY
-- The web process also runs a worker, set
the web process' worker max capacity here.WORKER_SLEEP_TIME
-- Sleep time per worker run loop iteration.The endpoint and period are recieved from the user, and a next-update absolute time value is calculated based on currrent time and period:
next execution time = current time + period
This information is then stored like so in the :jobs
collection:
{:endpoint "http://heroku.com"
:period 5000 ; (ms)
:next-update 1316480549459}
A worker continuously pulls the next job to be executed (where current time > next update), atomically locks the entry so that no other workers can grab it, and makes an http request against the endpoint.
The next execution time is calculated at the beginning of this process. The next execution time is then updated on the job, and the job is unlocked, available for another worker to process.
Standard operations against the database.
Naptime should scale nicely. Simply add more workers when load gets too high (see load charts on naptime webapp index page).
Copyright (C) 2011 Zachary Kim
Distributed under the Eclipse Public License, the same as Clojure.