Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A sample app using Clockwork with a Sinatra/Beanstalk app to fetch market prices periodically

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 .gitignore
Octocat-spinner-32 Gemfile
Octocat-spinner-32 Procfile
Octocat-spinner-32 README.md
Octocat-spinner-32 clock.rb
Octocat-spinner-32 jobs.rb
Octocat-spinner-32 market_point.rb
Octocat-spinner-32 web.rb
README.md

Sample Clockwork App (Sinatra/Beanstalk)

Clockwork is a library to replace cron for scheduling jobs from within an application. This is a sample application which uses the Sinatra web framework, a MongoDB database, and the Beanstalk queueing backend to demonstrate Clockwork's use.

The app fetches the Dow Jones index from Google Finance once every three minutes, and puts the results in the Mongo database. The web app shows the history of all fetched data points.

Prerequistes

  • Ruby
  • Bundler (gem install bundler)
  • Beanstalkd (brew install beanstalk)
  • MongoDB (brew install mongodb)

Setup

$ git clone git://github.com/adamwiggins/clockwork-sinatra-beanstalk.git
$ cd clockwork-sinatra-beanstalk
$ bundle install

Running the db and queue

$ mkdir -p data; mongod --dbpath data &
$ beanstalkd &

Running the app

$ bundle exec ruby web.rb &
$ bundle exec stalk jobs.rb & 
$ bundle exec clockwork clock.rb &

Alternately, use Foreman (gem install foreman):

$ foreman start

Visit http://localhost:4567/ and you should see the first data point.

Something went wrong with that request. Please try again.