dynopoker 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/dynopoker.rb +37 -28
- data/lib/dynopoker/version.rb +1 -1
- metadata +8 -13
- data/lib/dynopoker/configuration.rb +0 -16
- data/lib/dynopoker/rails.rb +0 -16
- data/lib/dynopoker/railtie.rb +0 -9
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a8730d712a53b1d43a64390a0f4159c360dc8697
|
4
|
+
data.tar.gz: 7da96ae9107ad603e5c838dcd3006617bc7d2d76
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ecca503d727e217d7c7e14a5fb0f7b45b663612d1ab44c676e2d25f2bee28dc7981de5a3f876797394b96bba69bdd6fc64f2f84828d6675a12ad54a552d317ac
|
7
|
+
data.tar.gz: b373c3a25c0122a00241841befd858e0b0ecba509cc795b6ea532048f4eb647a110358a634bcb0fc25c1ff9ed793001c39223cce7f945176ae87ac9dfe80a827
|
data/lib/dynopoker.rb
CHANGED
@@ -1,43 +1,52 @@
|
|
1
|
-
require
|
2
|
-
require 'dynopoker/configuration'
|
1
|
+
require 'dynopoker/version'
|
3
2
|
require 'open-uri'
|
4
3
|
|
5
4
|
module Dynopoker
|
6
|
-
class << self
|
7
|
-
attr_accessor :configuration, :already_started
|
8
|
-
end
|
9
5
|
|
10
6
|
def self.configure
|
11
|
-
|
12
|
-
|
7
|
+
Poker.new.tap { |p| yield p }.start!
|
8
|
+
end
|
13
9
|
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
class Poker
|
11
|
+
attr_accessor :enable, :address, :poke_frequency, :logger
|
12
|
+
|
13
|
+
def start!
|
14
|
+
merge_default_options!
|
15
|
+
start_poking_thread! if should_poke?
|
17
16
|
end
|
18
|
-
end
|
19
17
|
|
20
|
-
def self.start
|
21
|
-
configuration.logger.info 'Dynopoker: starting thread'
|
22
|
-
Thread.new { poke } or configuration.logger.error 'Dynopoker: error while starting thread'
|
23
|
-
end
|
24
18
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
19
|
+
private
|
20
|
+
|
21
|
+
def start_poking_thread!
|
22
|
+
logger.info 'Dynopoker: starting thread'
|
23
|
+
Thread.new { poking } or logger.error 'Dynopoker: error while starting thread'
|
24
|
+
end
|
25
|
+
|
26
|
+
def poking
|
27
|
+
while true
|
28
|
+
poke!
|
29
|
+
sleep(poke_frequency)
|
32
30
|
end
|
31
|
+
end
|
33
32
|
|
34
|
-
|
33
|
+
def poke!
|
34
|
+
logger.info "Dynopoker: poking #{address}"
|
35
|
+
open(address).status
|
36
|
+
rescue Exception => exception
|
37
|
+
configuration.logger.error "Dynopoker: poking error #{exception.class.name}: #{exception.message}"
|
35
38
|
end
|
36
|
-
end
|
37
39
|
|
38
|
-
|
40
|
+
def merge_default_options!
|
41
|
+
self.poke_frequency ||= 1800
|
42
|
+
self.logger ||= Logger.new($stdout)
|
43
|
+
self.enable = enable.nil? ? true : enable
|
44
|
+
raise('Dynopoker: no address provided!') if !address && enable
|
45
|
+
end
|
39
46
|
|
40
|
-
|
41
|
-
|
42
|
-
end
|
47
|
+
def should_poke?
|
48
|
+
address.present? && enable && poke_frequency.present?
|
49
|
+
end
|
43
50
|
|
51
|
+
end
|
52
|
+
end
|
data/lib/dynopoker/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynopoker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.1.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- kubenstein
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-10-12 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
13
|
description: Dynopoker is a gem that will make your ruby based heroku app self pinging
|
15
14
|
system, preventing single dyno from falling asleep
|
@@ -25,32 +24,28 @@ files:
|
|
25
24
|
- Rakefile
|
26
25
|
- dynopoker.gemspec
|
27
26
|
- lib/dynopoker.rb
|
28
|
-
- lib/dynopoker/configuration.rb
|
29
|
-
- lib/dynopoker/rails.rb
|
30
|
-
- lib/dynopoker/railtie.rb
|
31
27
|
- lib/dynopoker/version.rb
|
32
28
|
homepage: https://github.com/kubenstein/dynopoker
|
33
29
|
licenses: []
|
30
|
+
metadata: {}
|
34
31
|
post_install_message:
|
35
32
|
rdoc_options: []
|
36
33
|
require_paths:
|
37
34
|
- lib
|
38
35
|
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
-
none: false
|
40
36
|
requirements:
|
41
|
-
- -
|
37
|
+
- - '>='
|
42
38
|
- !ruby/object:Gem::Version
|
43
39
|
version: '0'
|
44
40
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
|
-
none: false
|
46
41
|
requirements:
|
47
|
-
- -
|
42
|
+
- - '>='
|
48
43
|
- !ruby/object:Gem::Version
|
49
44
|
version: '0'
|
50
45
|
requirements: []
|
51
46
|
rubyforge_project: dynopoker
|
52
|
-
rubygems_version:
|
47
|
+
rubygems_version: 2.0.6
|
53
48
|
signing_key:
|
54
|
-
specification_version:
|
55
|
-
summary:
|
49
|
+
specification_version: 4
|
50
|
+
summary: 'Dynopoker: prevent your heroku dyno from falling asleep'
|
56
51
|
test_files: []
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module Dynopoker
|
2
|
-
class Configuration
|
3
|
-
attr_accessor :address, :enable, :poke_frequency, :logger
|
4
|
-
|
5
|
-
def initialize
|
6
|
-
self.address = ''
|
7
|
-
self.enable = true
|
8
|
-
self.poke_frequency = 1800
|
9
|
-
self.logger = Logger.new($stdout)
|
10
|
-
end
|
11
|
-
|
12
|
-
def should_poke?
|
13
|
-
address.present? && enable && poke_frequency.present?
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
data/lib/dynopoker/rails.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
module Dynopoker
|
2
|
-
module Rails
|
3
|
-
def self.initialize
|
4
|
-
Dynopoker.configure do |config|
|
5
|
-
config.logger = ::Rails.logger
|
6
|
-
end
|
7
|
-
end
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
if defined?(Rails::Railtie)
|
12
|
-
require 'dynopoker/railtie'
|
13
|
-
else
|
14
|
-
Dynopoker::Rails.initialize
|
15
|
-
end
|
16
|
-
|
data/lib/dynopoker/railtie.rb
DELETED