Permalink
Browse files

no need to use resque/scheduler at all, rufus/scheduler will do what …

…we need; props to @bernd
  • Loading branch information...
obfuscurity committed Nov 8, 2012
1 parent 0fa0f5c commit 683e9c24175d1e2deff8817cce0dfad05caf9e62
Showing with 11 additions and 43 deletions.
  1. +1 −2 Gemfile
  2. +1 −15 Gemfile.lock
  3. +0 −2 Procfile
  4. +1 −1 README.md
  5. +0 −21 Rakefile
  6. +8 −1 config.ru
  7. +0 −1 lib/descartes/models/init.rb
View
@@ -15,8 +15,7 @@ gem "rest-client"
gem "haml"
gem "json"
gem "rspec"
gem "resque"
gem "resque-scheduler"
gem "rufus-scheduler"
group :development do
gem "foreman"
View
@@ -60,17 +60,6 @@ GEM
rack (>= 1.0)
rake (0.9.2.2)
redis (3.0.1)
redis-namespace (1.2.1)
redis (~> 3.0.0)
resque (1.23.0)
multi_json (~> 1.0)
redis-namespace (~> 1.0)
sinatra (>= 0.9.2)
vegas (~> 0.1.2)
resque-scheduler (2.0.0)
redis (>= 2.0.1)
resque (>= 1.20.0)
rufus-scheduler
rest-client (1.6.7)
mime-types (>= 1.16)
rspec (2.11.0)
@@ -103,8 +92,6 @@ GEM
thor (0.16.0)
tilt (1.3.3)
tzinfo (0.3.35)
vegas (0.1.11)
rack (>= 1.0.0)
warden (1.2.1)
rack (>= 1.0)
warden-github (0.9.1)
@@ -132,10 +119,9 @@ DEPENDENCIES
rack-ssl-enforcer
rack-test
rake
resque
resque-scheduler
rest-client
rspec
rufus-scheduler
sequel
sinatra (= 1.3.1)
sinatra_auth_github (= 0.9.0)
View
@@ -1,3 +1 @@
web: bundle exec rackup -p $PORT -s thin
scheduler: bundle exec rake resque:scheduler QUEUE=*
worker: bundle exec rake resque:work QUEUE=*
View
@@ -28,7 +28,7 @@ Descartes stores configuration data in PostgreSQL and Google OpenID state in Red
### Options
* `METRICS_UPDATE_INTERVAL` - How frequently to update the list of known metrics from the remote Graphite server. The more often you add new metrics, the lower this value should be. A reasonable default for most installations would be `1h` (time strings as understood by [Rufus scheduler](https://github.com/jmettraux/rufus-scheduler#the-time-strings-understood-by-rufus-scheduler)). If users complain that they don't see new metrics, it means that it hasn't synced since a new metric has been added. You can simply restart Descartes, and optionally lower this value to suit your users' patience threshold, to manually update the metrics list. __Note__ - this feature adds `scheduler` and `worker` resque classes; if you're hosting your Descartes on Heroku, you will be charged for the extra dyno time.
* `METRICS_UPDATE_INTERVAL` - How frequently to update the list of known metrics from the remote Graphite server. The more often you add new metrics, the lower this value should be. A reasonable default for most installations would be `1h` (time strings as understood by [Rufus scheduler](https://github.com/jmettraux/rufus-scheduler#the-time-strings-understood-by-rufus-scheduler)). If users complain that they don't see new metrics, it means that it hasn't synced since a new metric has been added. You can simply restart Descartes, and optionally lower this value to suit your users' patience threshold, to manually update the metrics list.
* `USE_SVG` - When set to `true`, will cause Descartes to load SVG output from Graphite instead of the default PNG output. In the future SVG will become the default format, but there is currently a bug in stable Graphite (0.9.10 as of this writing) which causes SVG rendering to fail whenever `secondYAxis` is enabled on any target in a graph.
View
@@ -41,25 +41,4 @@ RSpec::Core::RakeTask.new(:spec) do |spec|
spec.ruby_opts = '-I .'
end
# Resque tasks
require 'resque/tasks'
require 'resque_scheduler/tasks'
namespace :resque do
task :setup do
require './lib/descartes/models/init'
require 'resque'
require 'resque/scheduler'
require 'resque_scheduler'
Resque.redis = ENV['REDISTOGO_URL'] || 'redis://localhost:6379/1'
Resque::Scheduler.dynamic = true
Resque.set_schedule('metrics_update', {
:every => ENV['METRICS_UPDATE_INTERVAL'],
:class => 'MetricListUpdate',
:queue => 'low',
:description => 'This job will download /metrics/index.json from Graphite and update our metrics list.'
})
end
end
task :default => :spec
View
@@ -25,4 +25,11 @@ end
run Rack::URLMap.new('/' => Descartes::Web, '/auth/github' => Descartes::GithubAuth)
# seed our Metrics list at startup
Metric.load
Metric.load
# update our Metrics list at regular intervals
require 'rufus/scheduler'
scheduler = Rufus::Scheduler.start_new
scheduler.every ENV['METRICS_UPDATE_INTERVAL'] do
Metric.update
end
@@ -1,6 +1,5 @@
require 'sequel'
require 'securerandom'
require 'rest-client'
require 'json'
db = ENV['DATABASE_URL'] || 'postgres://localhost/descartes'

1 comment on commit 683e9c2

@brntbeer

This comment has been minimized.

Show comment
Hide comment
@brntbeer

brntbeer Nov 8, 2012

Contributor

holy shit yes. 👍 @bernd apparently

Contributor

brntbeer commented on 683e9c2 Nov 8, 2012

holy shit yes. 👍 @bernd apparently

Please sign in to comment.