hirefireapp 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/bin/hirefireapp CHANGED
@@ -31,9 +31,10 @@ else
31
31
  exit 1
32
32
  end
33
33
 
34
- if response =~ /\[HireFireApp\:\s/
34
+ if response =~ /HireFire/
35
35
  puts response
36
36
  else
37
37
  puts "Could not find HireFireApp at #{url}."
38
+ exit 1
38
39
  end
39
40
  end
data/hirefireapp.gemspec CHANGED
@@ -4,7 +4,7 @@ Gem::Specification.new do |gem|
4
4
 
5
5
  # General configuration / information
6
6
  gem.name = 'hirefireapp'
7
- gem.version = '0.0.3'
7
+ gem.version = '0.0.4'
8
8
  gem.platform = Gem::Platform::RUBY
9
9
  gem.authors = 'Michael van Rooijen'
10
10
  gem.email = 'meskyanichi@gmail.com'
@@ -13,12 +13,8 @@ module HireFireApp
13
13
  end
14
14
 
15
15
  ##
16
- # Simple router. If a request come in at the "test" url (the url to test if HireFire is properly installed)
17
- # then we return information about the current environment (orm, odm, kvs, worker library, etc). Returns "Not Found"
18
- # and specified "what wasn't found" in case the environment isn't complete (e.g. the worker library could not be found).
19
- #
20
- # HireFireApp.com will always ping to the "info?" url. This will return JSON format containing the current job queue
21
- # for the given worker library, as well as the queue_wait_time
16
+ # Return a HTML response if the "test url" has been requested.
17
+ # Return a JSON requested if the "info url" has been requested.
22
18
  #
23
19
  def call(env)
24
20
  @env = env
@@ -33,32 +29,33 @@ module HireFireApp
33
29
  end
34
30
 
35
31
  ##
36
- # Response body - This is the data that gets returned to the requester
37
- # depending on which URL was requested.
32
+ # If the "test url" has been requested, we'll return information regarding the HireFire installation in HTML format.
33
+ # If the "info url" has been regarding, we'll return the job count for the worker library (if applicable)
34
+ # in JSON format.
38
35
  #
39
36
  def each(&block)
40
37
  if test?
41
- block.call "[HireFireApp: #{ok}] Worker: #{worker} - Mapper: #{mapper}"
38
+ out = "\n"
39
+ out << "[HireFire][Web] OK\n"
40
+ out << "[HireFire][Worker] #{worker_ok} (Library: #{worker_library}, Mapper: #{mapper_library})\n\n"
41
+
42
+ if worker_library =~ /Not Found/
43
+ out << "HireFire is able to auto-scale your web dynos, but not your worker dynos.\n"
44
+ else
45
+ out << "HireFire is able to auto-scale both your web, as well as your worker dynos."
46
+ end
47
+
48
+ block.call out
42
49
  elsif info?
43
- block.call %|{"job_count":#{job_count || 'null'}, "queue_wait_time":#{queue_wait_time}}|
50
+ block.call %|{"job_count":#{job_count || "null"}}|
44
51
  end
45
52
  end
46
53
 
47
54
  private
48
55
 
49
56
  ##
50
- # Returns the time it took to allow the request
51
- # (delayed by the queue) in miliseconds
52
- #
53
- # @request [Integer] the queue wait time in miliseconds
54
- #
55
- def queue_wait_time
56
- @env["HTTP_X_HEROKU_QUEUE_WAIT_TIME"].to_i
57
- end
58
-
59
- ##
60
- # Counts the amount of jobs that are currently queued
61
- # and show be processed as soon as possible (aka the ones that are pending)
57
+ # Returns the amount of queued jobs that are scheduled to be processed
58
+ # at this time, or in the past, but not in the future.
62
59
  #
63
60
  # @returns [Fixnum, nil] job_count returns nil if something went wrong
64
61
  #
@@ -77,7 +74,7 @@ module HireFireApp
77
74
  ##
78
75
  # Makes Delayed::Job count the amount of currently pending jobs.
79
76
  # It'll use the ActiveRecord ORM, or the Mongoid ODM depending on
80
- # which of them is defined.
77
+ # which is defined.
81
78
  #
82
79
  # If ActiveRecord 2 (or earlier) is being used, ActiveRecord::Relation doesn't
83
80
  # exist, and we'll have to use the old :conditions hash notation.
@@ -106,7 +103,7 @@ module HireFireApp
106
103
  end
107
104
 
108
105
  ##
109
- # Makes Resque count the amount of currently pending jobs.
106
+ # Returns the amount of jobs in the queue + the ones that are being processed
110
107
  #
111
108
  # @returns [Fixnum] resque_job_count
112
109
  # the number of jobs pending + the amount of workers currently working
@@ -116,11 +113,12 @@ module HireFireApp
116
113
  end
117
114
 
118
115
  ##
119
- # Returns the name of the mapper, or "Not Found" if not found
116
+ # Returns the name of the mapper as a string, or "Not Found" if
117
+ # the mapper could not be found
120
118
  #
121
119
  # @returns [String]
122
120
  #
123
- def mapper
121
+ def mapper_library
124
122
  if defined?(Redis) and defined?(Resque)
125
123
  "Redis"
126
124
  elsif defined?(Delayed::Worker)
@@ -137,11 +135,12 @@ module HireFireApp
137
135
  end
138
136
 
139
137
  ##
140
- # Returns the name of the worker type, or "Not Found" if not found
138
+ # Returns the name of the worker library, or "Not Found" if the worker library
139
+ # could not be found / is not supported
141
140
  #
142
141
  # @returns [String]
143
142
  #
144
- def worker
143
+ def worker_library
145
144
  if defined?(Delayed::Job)
146
145
  "Delayed Job"
147
146
  elsif defined?(Resque)
@@ -152,13 +151,14 @@ module HireFireApp
152
151
  end
153
152
 
154
153
  ##
155
- # Returns "OK" if both the mapper and worker were found
154
+ # Returns "OK" if both the mapper and worker were found, or "INCOMPLETE"
155
+ # if either of them could not be found
156
156
  #
157
157
  # @returns [String]
158
158
  #
159
- def ok
160
- if mapper =~ /Not Found/ or worker =~ /Not Found/
161
- "Incomplete"
159
+ def worker_ok
160
+ if mapper_library =~ /Not Found/ or worker_library =~ /Not Found/
161
+ "INCOMPLETE"
162
162
  else
163
163
  "OK"
164
164
  end
metadata CHANGED
@@ -1,28 +1,24 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: hirefireapp
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
4
5
  prerelease:
5
- version: 0.0.3
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Michael van Rooijen
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-08-05 00:00:00 +02:00
14
- default_executable:
12
+ date: 2011-08-25 00:00:00.000000000 Z
15
13
  dependencies: []
16
-
17
- description: HireFireApp.com - The Heroku Process Manager - Autoscaling your web and worker dynos saving you time and money!
14
+ description: HireFireApp.com - The Heroku Process Manager - Autoscaling your web and
15
+ worker dynos saving you time and money!
18
16
  email: meskyanichi@gmail.com
19
- executables:
17
+ executables:
20
18
  - hirefireapp
21
19
  extensions: []
22
-
23
20
  extra_rdoc_files: []
24
-
25
- files:
21
+ files:
26
22
  - .gitignore
27
23
  - README.md
28
24
  - bin/hirefireapp
@@ -30,33 +26,29 @@ files:
30
26
  - lib/hirefireapp.rb
31
27
  - lib/hirefireapp/middleware.rb
32
28
  - lib/hirefireapp/railtie.rb
33
- has_rdoc: true
34
29
  homepage: http://hirefireapp.com/
35
30
  licenses: []
36
-
37
31
  post_install_message:
38
32
  rdoc_options: []
39
-
40
- require_paths:
33
+ require_paths:
41
34
  - lib
42
- required_ruby_version: !ruby/object:Gem::Requirement
35
+ required_ruby_version: !ruby/object:Gem::Requirement
43
36
  none: false
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: "0"
48
- required_rubygems_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
42
  none: false
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: "0"
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
54
47
  requirements: []
55
-
56
48
  rubyforge_project:
57
- rubygems_version: 1.6.2
49
+ rubygems_version: 1.8.6
58
50
  signing_key:
59
51
  specification_version: 3
60
- summary: HireFireApp.com - The Heroku Process Manager - Autoscaling your web and worker dynos!
52
+ summary: HireFireApp.com - The Heroku Process Manager - Autoscaling your web and worker
53
+ dynos!
61
54
  test_files: []
62
-