heroku_scale_scheduler 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +51 -0
- data/Rakefile +2 -0
- data/heroku_scale_scheduler.gemspec +20 -0
- data/lib/generators/heroku_scale_scheduler/install_generator.rb +16 -0
- data/lib/generators/heroku_scale_scheduler/templates/heroku_ps.yml +9 -0
- data/lib/heroku_scale_scheduler.rb +3 -0
- data/lib/heroku_scale_scheduler/client.rb +22 -0
- data/lib/heroku_scale_scheduler/config.rb +11 -0
- data/lib/heroku_scale_scheduler/railtie.rb +5 -0
- data/lib/heroku_scale_scheduler/tasks/heroku_scale_scheduler.rake +13 -0
- data/lib/heroku_scale_scheduler/version.rb +3 -0
- metadata +82 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 SHIBATA Hiroshi
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# HerokuScaleScheduler
|
2
|
+
|
3
|
+
HerokuScaleScheduler is schedule scale of heroku dynos/workers.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'heroku_scale_scheduler'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install heroku_scale_scheduler
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
1. run the folllow commands
|
22
|
+
|
23
|
+
```
|
24
|
+
$ bundle exec rails g heroku_scale_scheduler:install
|
25
|
+
```
|
26
|
+
|
27
|
+
2. write your scheduling configuration to config/heroku_ps.yml. notice: schedule time is must be 10 minutes periods.
|
28
|
+
3. add Heroku scheduler addons.
|
29
|
+
4. visit your Heroku scheduler dashboard, and added follow tasks
|
30
|
+
|
31
|
+
<table>
|
32
|
+
<tr><th>TASK</th><th>FREQUENCY<th></tr>
|
33
|
+
<tr><td>rake heroku:scale:dynos</td><td>Every 10 minutes</td></tr>
|
34
|
+
<tr><td>rake heroku:scale:workers</td><td>Every 10 minutes</td></tr>
|
35
|
+
<table>
|
36
|
+
|
37
|
+
5. add your heroku api key to Heroku env. example for
|
38
|
+
|
39
|
+
```
|
40
|
+
$ heroku config:add HEROKU_API_KEY=xxx --app example_app
|
41
|
+
```
|
42
|
+
|
43
|
+
6. push your app for heroku.
|
44
|
+
|
45
|
+
## Contributing
|
46
|
+
|
47
|
+
1. Fork it
|
48
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
49
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
50
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
51
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/heroku_scale_scheduler/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["SHIBATA Hiroshi"]
|
6
|
+
gem.email = ["shibata.hiroshi@gmail.com"]
|
7
|
+
gem.description = "scaling scheduler for heroku dynos/workers"
|
8
|
+
gem.summary = "heroku_scale_scheduler is simple scaling scheduler for heroku dynos/workers."
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
gem.name = "heroku_scale_scheduler"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = HerokuScaleScheduler::VERSION
|
17
|
+
|
18
|
+
gem.add_runtime_dependency 'heroku', ['>= 2']
|
19
|
+
gem.add_runtime_dependency 'railties', ['>= 3.0']
|
20
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module HerokuScaleScheduler
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
|
5
|
+
|
6
|
+
desc <<DESC
|
7
|
+
Description:
|
8
|
+
Copies Heroku Scheduler configuration file to your config directory.
|
9
|
+
DESC
|
10
|
+
|
11
|
+
def copy_config_file
|
12
|
+
copy_file 'heroku_ps.yml', 'config/heroku_ps.yml'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'heroku/client'
|
2
|
+
|
3
|
+
module HerokuScaleScheduler
|
4
|
+
class Client
|
5
|
+
def initialize(type)
|
6
|
+
@type = type
|
7
|
+
end
|
8
|
+
|
9
|
+
def run
|
10
|
+
client = Heroku::Client.new(*Heroku::Auth.read_credentials)
|
11
|
+
config = HerokuScaleScheduler::Config.read_config
|
12
|
+
run_at = (Time.now.strftime('%H%M').to_i / 10) * 10
|
13
|
+
|
14
|
+
if qty = config[@type.to_s][run_at]
|
15
|
+
case @type
|
16
|
+
when :dynos then client.set_dynos(config['app'], qty)
|
17
|
+
when :workers then client.set_workers(config['app'], qty)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
namespace :heroku do
|
2
|
+
namespace :scale do
|
3
|
+
desc 'scaling heroku dynos'
|
4
|
+
task :dynos do
|
5
|
+
HerokuScaleScheduler::Client.new(:dynos).run
|
6
|
+
end
|
7
|
+
|
8
|
+
desc 'scaling heroku workers'
|
9
|
+
task :workers do
|
10
|
+
HerokuScaleScheduler::Client.new(:workers).run
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: heroku_scale_scheduler
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- SHIBATA Hiroshi
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-05 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: heroku
|
16
|
+
requirement: &2249401240 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '2'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2249401240
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: railties
|
27
|
+
requirement: &2249400720 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '3.0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2249400720
|
36
|
+
description: scaling scheduler for heroku dynos/workers
|
37
|
+
email:
|
38
|
+
- shibata.hiroshi@gmail.com
|
39
|
+
executables: []
|
40
|
+
extensions: []
|
41
|
+
extra_rdoc_files: []
|
42
|
+
files:
|
43
|
+
- .gitignore
|
44
|
+
- Gemfile
|
45
|
+
- LICENSE
|
46
|
+
- README.md
|
47
|
+
- Rakefile
|
48
|
+
- heroku_scale_scheduler.gemspec
|
49
|
+
- lib/generators/heroku_scale_scheduler/install_generator.rb
|
50
|
+
- lib/generators/heroku_scale_scheduler/templates/heroku_ps.yml
|
51
|
+
- lib/heroku_scale_scheduler.rb
|
52
|
+
- lib/heroku_scale_scheduler/client.rb
|
53
|
+
- lib/heroku_scale_scheduler/config.rb
|
54
|
+
- lib/heroku_scale_scheduler/railtie.rb
|
55
|
+
- lib/heroku_scale_scheduler/tasks/heroku_scale_scheduler.rake
|
56
|
+
- lib/heroku_scale_scheduler/version.rb
|
57
|
+
homepage: ''
|
58
|
+
licenses: []
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options: []
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ! '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 1.8.17
|
78
|
+
signing_key:
|
79
|
+
specification_version: 3
|
80
|
+
summary: heroku_scale_scheduler is simple scaling scheduler for heroku dynos/workers.
|
81
|
+
test_files: []
|
82
|
+
has_rdoc:
|