Permalink
Browse files

added scale tasks

  • Loading branch information...
1 parent d3c0998 commit 4453f48a2ac732b318e68d2993b35c7115efc7aa @hsbt committed Mar 5, 2012
@@ -15,5 +15,6 @@ Gem::Specification.new do |gem|
gem.require_paths = ["lib"]
gem.version = HerokuScaleScheduler::VERSION
- gem.add_dependency 'heroku', ['>= 0']
+ gem.add_runtime_dependency 'heroku', ['>= 2']
+ gem.add_runtime_dependency 'railties', ['>= 3.0']
end
@@ -1,5 +1,5 @@
-require "heroku_scale_scheduler/version"
-
module HerokuScaleScheduler
- # Your code goes here...
+ class Railtie < Rails::Railtie
+ rake_tasks { load 'heroku_scale_scheduler/tasks/heroku_scale_scheduler.rake' }
+ end
end
@@ -0,0 +1,24 @@
+require 'heroku/client'
+
+client = Heroku::Client.new(*Heroku::Auth.read_credentials)
+config = if File.exists? Rails.root.join('config', 'heroku_ps.yml')
+ YAML.load(Rails.root.join('config', 'heroku_ps.yml'))
+ else
+ {}
+ end
+
+namespace :heroku do
+ namespace :scale do
+ desc 'scaling heroku dynos'
+ task :dynos do
+ qty = config['dynos'][Time.now.strftime('%H%M')]
+ client.set_dynos(config['app'], qty) if qty
+ end
+
+ desc 'scaling heroku workers'
+ task :workers do
+ qty = config['workers'][Time.now.strftime('%H%M')]
+ client.set_workers(config['app'], qty) if qty
+ end
+ end
+end

0 comments on commit 4453f48

Please sign in to comment.