ernie 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,7 @@
1
+ = 2.2.0 / 2010-03-12
2
+ * Minor Additions
3
+ * Set procline for external Ruby handlers
4
+
1
5
  = 2.1.0 / 2010-02-20
2
6
  * Major Additions
3
7
  * Add access logging
data/Rakefile CHANGED
@@ -5,7 +5,9 @@ begin
5
5
  require 'jeweler'
6
6
  Jeweler::Tasks.new do |gem|
7
7
  gem.name = "ernie"
8
+ gem.rubyforge_project = "ernie"
8
9
  gem.summary = %Q{Ernie is a BERT-RPC server implementation.}
10
+ gem.description = %Q{Ernie is an Erlang/Ruby hybrid BERT-RPC server implementation packaged as a gem.}
9
11
  gem.email = "tom@mojombo.com"
10
12
  gem.homepage = "http://github.com/mojombo/ernie"
11
13
  gem.authors = ["Tom Preston-Werner"]
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :major: 2
3
- :minor: 1
3
+ :minor: 2
4
4
  :patch: 0
5
5
  :build:
@@ -139,4 +139,17 @@ start_handlers(Assets, Count, Handler, Token) ->
139
139
  start_handlers(Assets2, Count - 1, Handler, Token).
140
140
 
141
141
  create_asset(Handler, Token) ->
142
- {asset, port_wrapper:wrap_link(Handler), Token}.
142
+ Len = length(Handler),
143
+ case Len > 150 of
144
+ true -> Cmd = Handler;
145
+ false -> Cmd = lists:flatten(Handler ++ " --procline " ++ pad(150 - Len - 12))
146
+ end,
147
+ io:format("~p~n", [Cmd]),
148
+ {asset, port_wrapper:wrap_link(Cmd), Token}.
149
+
150
+ pad(Size) ->
151
+ pad(Size, []).
152
+ pad(0, Acc) ->
153
+ Acc;
154
+ pad(Size, Acc) ->
155
+ pad(Size - 1, ["x" | Acc]).
@@ -5,12 +5,13 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ernie}
8
- s.version = "2.1.0"
8
+ s.version = "2.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tom Preston-Werner"]
12
- s.date = %q{2010-02-24}
12
+ s.date = %q{2010-03-12}
13
13
  s.default_executable = %q{ernie}
14
+ s.description = %q{Ernie is an Erlang/Ruby hybrid BERT-RPC server implementation packaged as a gem.}
14
15
  s.email = %q{tom@mojombo.com}
15
16
  s.executables = ["ernie"]
16
17
  s.extensions = ["ext/extconf.rb", "ext/extconf.rb"]
@@ -62,6 +63,7 @@ Gem::Specification.new do |s|
62
63
  s.homepage = %q{http://github.com/mojombo/ernie}
63
64
  s.rdoc_options = ["--charset=UTF-8"]
64
65
  s.require_paths = ["lib"]
66
+ s.rubyforge_project = %q{ernie}
65
67
  s.rubygems_version = %q{1.3.5}
66
68
  s.summary = %q{Ernie is a BERT-RPC server implementation.}
67
69
  s.test_files = [
@@ -6,8 +6,11 @@ class Ernie
6
6
  class << self
7
7
  attr_accessor :mods, :current_mod, :log
8
8
  attr_accessor :auto_start
9
+ attr_accessor :count, :virgin_procline
9
10
  end
10
11
 
12
+ self.count = 0
13
+ self.virgin_procline = $0
11
14
  self.mods = {}
12
15
  self.current_mod = nil
13
16
  self.log = Logger.new(STDOUT)
@@ -117,6 +120,7 @@ class Ernie
117
120
  #
118
121
  # Loops forever
119
122
  def self.start
123
+ self.procline('starting')
120
124
  self.log.info("(#{Process.pid}) Starting")
121
125
  self.log.debug(self.mods.inspect)
122
126
 
@@ -126,7 +130,10 @@ class Ernie
126
130
  output.sync = true
127
131
 
128
132
  loop do
133
+ self.procline('waiting')
129
134
  iruby = self.read_berp(input)
135
+ self.count += 1
136
+
130
137
  unless iruby
131
138
  puts "Could not read BERP length header. Ernie server may have gone away. Exiting now."
132
139
  self.log.info("(#{Process.pid}) Could not read BERP length header. Ernie server may have gone away. Exiting now.")
@@ -135,6 +142,7 @@ class Ernie
135
142
 
136
143
  if iruby.size == 4 && iruby[0] == :call
137
144
  mod, fun, args = iruby[1..3]
145
+ self.procline("#{mod}:#{fun}(#{args})")
138
146
  self.log.info("-> " + iruby.inspect)
139
147
  begin
140
148
  res = self.dispatch(mod, fun, args)
@@ -154,6 +162,7 @@ class Ernie
154
162
  end
155
163
  elsif iruby.size == 4 && iruby[0] == :cast
156
164
  mod, fun, args = iruby[1..3]
165
+ self.procline("#{mod}:#{fun}(#{args})")
157
166
  self.log.info("-> " + [:cast, mod, fun, args].inspect)
158
167
  begin
159
168
  self.dispatch(mod, fun, args)
@@ -162,6 +171,7 @@ class Ernie
162
171
  end
163
172
  write_berp(output, t[:noreply])
164
173
  else
174
+ self.procline("invalid request")
165
175
  self.log.error("-> " + iruby.inspect)
166
176
  oruby = t[:error, t[:server, 0, "Invalid request: #{iruby.inspect}"]]
167
177
  self.log.error("<- " + oruby.inspect)
@@ -169,6 +179,19 @@ class Ernie
169
179
  end
170
180
  end
171
181
  end
182
+
183
+ def self.procline(msg)
184
+ $0 = "ernie handler #{VERSION} (ruby) - #{self.virgin_procline} - [#{self.count}] #{msg}"[0..159]
185
+ end
186
+
187
+ def self.version
188
+ yml = YAML.load(File.read(File.join(File.dirname(__FILE__), *%w[.. VERSION.yml])))
189
+ "#{yml[:major]}.#{yml[:minor]}.#{yml[:patch]}"
190
+ rescue
191
+ 'unknown'
192
+ end
193
+
194
+ VERSION = self.version
172
195
  end
173
196
 
174
197
  class Ernie::ServerError < StandardError; end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ernie
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Preston-Werner
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-24 00:00:00 -08:00
12
+ date: 2010-03-12 00:00:00 -08:00
13
13
  default_executable: ernie
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -32,7 +32,7 @@ dependencies:
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.0.0
34
34
  version:
35
- description:
35
+ description: Ernie is an Erlang/Ruby hybrid BERT-RPC server implementation packaged as a gem.
36
36
  email: tom@mojombo.com
37
37
  executables:
38
38
  - ernie
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  version:
106
106
  requirements: []
107
107
 
108
- rubyforge_project:
108
+ rubyforge_project: ernie
109
109
  rubygems_version: 1.3.5
110
110
  signing_key:
111
111
  specification_version: 3