whacamole 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/whacamole.rb +1 -1
- data/lib/whacamole/config.rb +3 -1
- data/lib/whacamole/heroku_wrapper.rb +5 -6
- data/lib/whacamole/version.rb +1 -1
- data/spec/heroku_wrapper_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbd9b630afe531f0c7a57a0595d74a20a1c759ce
|
4
|
+
data.tar.gz: c2ddd22b8f2cf8e4f4f17bae77bda2007ff5c6af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57f8817af208cf490c41b2220d10acf104267816f9583833b281d83bee2c611206fc3b1c23281b8db65983c04c4910045f9d514cced19e8280389309a81f3514
|
7
|
+
data.tar.gz: 34fd5b11c1aa89b03e9bb20d62217bd44328b056d4d4f576d400a85a32d485a94c86b799a75353d7e3cfbd670cbf72f898fef7f03f5f04be781b355ba8c9987f
|
data/README.md
CHANGED
@@ -50,6 +50,7 @@ end
|
|
50
50
|
Whacamole.configure("HEROKU APP WITH MULTIPLE DYNO TYPES") do |config|
|
51
51
|
config.api_token = ENV['HEROKU_API_TOKEN'] # you could also paste your token in here as a string
|
52
52
|
config.dynos = %w{web worker}
|
53
|
+
config.restart_threshold = 500 # in megabytes. default is 1000 (good for 2X dynos)
|
53
54
|
end
|
54
55
|
```
|
55
56
|
|
data/lib/whacamole.rb
CHANGED
@@ -16,7 +16,7 @@ module Whacamole
|
|
16
16
|
threads = []
|
17
17
|
@@config.each do |app_name, config|
|
18
18
|
threads << Thread.new do
|
19
|
-
heroku = HerokuWrapper.new(app_name, config.api_token, config.dynos)
|
19
|
+
heroku = HerokuWrapper.new(app_name, config.api_token, config.dynos, config.restart_window)
|
20
20
|
|
21
21
|
while true
|
22
22
|
stream_url = heroku.create_log_session
|
data/lib/whacamole/config.rb
CHANGED
@@ -2,14 +2,16 @@ module Whacamole
|
|
2
2
|
class Config
|
3
3
|
|
4
4
|
RESTART_THRESHOLD = 1000
|
5
|
+
RESTART_RATE_LIMIT = 30*60
|
5
6
|
|
6
|
-
attr_accessor :app_name, :api_token, :event_handler, :dynos, :restart_threshold
|
7
|
+
attr_accessor :app_name, :api_token, :event_handler, :dynos, :restart_threshold, :restart_window
|
7
8
|
|
8
9
|
def initialize(app_name)
|
9
10
|
self.app_name = app_name
|
10
11
|
self.event_handler ||= lambda { |e| puts e.inspect.to_s }
|
11
12
|
self.dynos ||= %w{web}
|
12
13
|
self.restart_threshold ||= RESTART_THRESHOLD
|
14
|
+
self.restart_window ||= RESTART_RATE_LIMIT
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
@@ -4,14 +4,13 @@ require 'json'
|
|
4
4
|
|
5
5
|
module Whacamole
|
6
6
|
class HerokuWrapper
|
7
|
-
attr_accessor :api_token, :app_name, :dynos
|
7
|
+
attr_accessor :api_token, :app_name, :dynos, :restart_window
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
def initialize(app_name, api_token, dynos)
|
9
|
+
def initialize(app_name, api_token, dynos, restart_window)
|
12
10
|
self.app_name = app_name
|
13
11
|
self.api_token = api_token
|
14
12
|
self.dynos = dynos
|
13
|
+
self.restart_window = restart_window
|
15
14
|
end
|
16
15
|
|
17
16
|
def create_log_session
|
@@ -45,7 +44,7 @@ module Whacamole
|
|
45
44
|
end
|
46
45
|
|
47
46
|
def recently_restarted?(process)
|
48
|
-
restarts[process] > (Time.now -
|
47
|
+
restarts[process] > (Time.now - restart_window)
|
49
48
|
end
|
50
49
|
|
51
50
|
private
|
@@ -66,7 +65,7 @@ module Whacamole
|
|
66
65
|
end
|
67
66
|
|
68
67
|
def restarts
|
69
|
-
@restarts ||= Hash.new { Time.now -
|
68
|
+
@restarts ||= Hash.new { Time.now - restart_window*2 }
|
70
69
|
end
|
71
70
|
end
|
72
71
|
end
|
data/lib/whacamole/version.rb
CHANGED
data/spec/heroku_wrapper_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
# TODO: use VCR instead of these method expectations
|
4
4
|
describe Whacamole::HerokuWrapper do
|
5
|
-
let(:h) { Whacamole::HerokuWrapper.new("staging", "foobar", %w{web worker}) }
|
5
|
+
let(:h) { Whacamole::HerokuWrapper.new("staging", "foobar", %w{web worker}, Whacamole::Config::RESTART_RATE_LIMIT) }
|
6
6
|
|
7
7
|
describe "dynos" do
|
8
8
|
it "returns dyno types to monitor as given to initialize" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whacamole
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Doyle
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|