dynopoker 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/Gemfile +4 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/dynopoker.gemspec +24 -0
- data/lib/dynopoker.rb +43 -0
- data/lib/dynopoker/configuration.rb +16 -0
- data/lib/dynopoker/rails.rb +16 -0
- data/lib/dynopoker/railtie.rb +9 -0
- data/lib/dynopoker/version.rb +3 -0
- metadata +56 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
DynoPoker
|
2
|
+
=============
|
3
|
+
|
4
|
+
Dynopoker is a gem which prevent your Heroku dyno from falling asleep.
|
5
|
+
|
6
|
+
Inspired and sponsored by [http://wakemydyno.com](http://wakemydyno.com)
|
7
|
+
|
8
|
+
Idea
|
9
|
+
-------
|
10
|
+
Dynopoker will command your app to ping itself every hour.
|
11
|
+
|
12
|
+
Installation
|
13
|
+
-------
|
14
|
+
Put this line into your `Gemfile`:
|
15
|
+
|
16
|
+
gem 'dynopoker', :git => 'git://github.com/kubenstein/dynopoker.git'
|
17
|
+
|
18
|
+
( In future Dynopoker will be pushed to official gem repository, so not git url will be required )
|
19
|
+
|
20
|
+
Usage
|
21
|
+
-----
|
22
|
+
Add this configuration to your config file:
|
23
|
+
|
24
|
+
Dynopoker.configure do |config|
|
25
|
+
config.address = 'http://dynopoker.com'
|
26
|
+
# config.enable = false # default is true
|
27
|
+
# config.poke_frequency = 123 # default is 3600s (1hour)
|
28
|
+
end
|
29
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/dynopoker.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "dynopoker/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "dynopoker"
|
7
|
+
s.version = Dynopoker::VERSION
|
8
|
+
s.authors = ["kubenstein"]
|
9
|
+
s.email = ["kubenstein@gmail.com"]
|
10
|
+
s.homepage = "http://wakemydyno.com"
|
11
|
+
s.summary = %q{Dynopoker: prevent your heroku dyno from falling asleep}
|
12
|
+
s.description = %q{Dynopoker is a gem that will make your ruby based heroku app self pinging system, preventing single dyno from falling asleep}
|
13
|
+
|
14
|
+
s.rubyforge_project = "dynopoker"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
# s.add_development_dependency "rspec"
|
23
|
+
# s.add_runtime_dependency "rest-client"
|
24
|
+
end
|
data/lib/dynopoker.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require "dynopoker/version"
|
2
|
+
require 'dynopoker/configuration'
|
3
|
+
require 'open-uri'
|
4
|
+
|
5
|
+
module Dynopoker
|
6
|
+
class << self
|
7
|
+
attr_accessor :configuration, :already_started
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.configure
|
11
|
+
self.configuration ||= Configuration.new
|
12
|
+
yield configuration
|
13
|
+
|
14
|
+
if configuration.should_poke? && !already_started
|
15
|
+
self.already_started = true
|
16
|
+
self.start
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
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
|
+
|
25
|
+
def self.poke
|
26
|
+
while(true)
|
27
|
+
begin
|
28
|
+
configuration.logger.info "Dynopoker: poking #{self.configuration.address}"
|
29
|
+
open(configuration.address).content_type
|
30
|
+
rescue Exception => exception
|
31
|
+
configuration.logger.error "Dynopoker: poking error #{exception.class.name}: #{exception.message}"
|
32
|
+
end
|
33
|
+
|
34
|
+
sleep(configuration.poke_frequency)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
if defined? Rails
|
41
|
+
require 'dynopoker/rails'
|
42
|
+
end
|
43
|
+
|
@@ -0,0 +1,16 @@
|
|
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 = 3600
|
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
|
@@ -0,0 +1,16 @@
|
|
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
|
+
|
metadata
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dynopoker
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- kubenstein
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-05-19 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Dynopoker is a gem that will make your ruby based heroku app self pinging
|
15
|
+
system, preventing single dyno from falling asleep
|
16
|
+
email:
|
17
|
+
- kubenstein@gmail.com
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- .gitignore
|
23
|
+
- Gemfile
|
24
|
+
- README.md
|
25
|
+
- Rakefile
|
26
|
+
- dynopoker.gemspec
|
27
|
+
- lib/dynopoker.rb
|
28
|
+
- lib/dynopoker/configuration.rb
|
29
|
+
- lib/dynopoker/rails.rb
|
30
|
+
- lib/dynopoker/railtie.rb
|
31
|
+
- lib/dynopoker/version.rb
|
32
|
+
homepage: http://wakemydyno.com
|
33
|
+
licenses: []
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options: []
|
36
|
+
require_paths:
|
37
|
+
- lib
|
38
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ! '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
requirements: []
|
51
|
+
rubyforge_project: dynopoker
|
52
|
+
rubygems_version: 1.8.25
|
53
|
+
signing_key:
|
54
|
+
specification_version: 3
|
55
|
+
summary: ! 'Dynopoker: prevent your heroku dyno from falling asleep'
|
56
|
+
test_files: []
|