ezmobius-nanite 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -29,7 +29,8 @@ In your Nanites you can have any number of actor classes. These actors are like
29
29
  in Rails or Merb and this is where you implement your own custom functionality. An actor looks
30
30
  like:
31
31
 
32
- class Foo < Nanite::Actor
32
+ class Foo
33
+ include Nanite::Actor
33
34
  expose :bar
34
35
  def bar(payload)
35
36
  "got payload: #{payload}"
@@ -128,22 +129,22 @@ If you don't have easy_install, install setuptools from http://pypi.python.org/p
128
129
 
129
130
  and install simplejson, which is needed for the "make" step below.
130
131
 
131
- These instructions assume the latest RabbitMQ release 1.5.1:
132
+ These instructions assume the latest RabbitMQ release 1.5.3:
132
133
 
133
134
  # Download somewhere
134
135
  cd /root
135
- wget http://www.rabbitmq.com/releases/rabbitmq-server/v1.5.1/rabbitmq-server-1.5.1.tar.gz
136
+ wget http://www.rabbitmq.com/releases/rabbitmq-server/v1.5.3/rabbitmq-server-1.5.3.tar.gz
136
137
 
137
138
  # Go to your erlang lib directory, usually /usr/lib/erlang/lib or:
138
139
  cd /usr/local/lib/erlang/lib
139
140
 
140
- tar -zxf ~/rabbitmq-server-1.5.1.tar.gz
141
- cd rabbitmq-server-1.5.1
141
+ tar -zxf ~/rabbitmq-server-1.5.3.tar.gz
142
+ cd rabbitmq-server-1.5.3
142
143
  make
143
144
 
144
145
  # There is no "make install" phase.
145
146
 
146
- Be sure to add the /usr/local/lib/erlang/lib/rabbitmq-server-1.5.1/scripts to your $PATH.
147
+ Be sure to add the /usr/local/lib/erlang/lib/rabbitmq-server-1.5.3/scripts to your $PATH.
147
148
 
148
149
  The following websites may also be useful:
149
150
  * RabbitMQ website for the latest info : http://www.rabbitmq.com/download.html
@@ -154,9 +155,9 @@ The following websites may also be useful:
154
155
 
155
156
  === Install RabbitMQ (Linux .deb)
156
157
 
157
- wget http://www.rabbitmq.com/releases/rabbitmq-server/v1.5.1/rabbitmq-server_1.5.1-1_all.deb
158
+ wget http://www.rabbitmq.com/releases/rabbitmq-server/v1.5.3/rabbitmq-server_1.5.3-1_all.deb
158
159
  sudo apt-get install logrotate
159
- sudo dpkg -i rabbitmq-server_1.5.1-1_all.deb
160
+ sudo dpkg -i rabbitmq-server_1.5.3-1_all.deb
160
161
 
161
162
  == Test your installation
162
163
 
@@ -282,17 +283,41 @@ Thin is EventMachine-based, so we only need to make sure that the EventMachine r
282
283
  until EM.reactor_running?
283
284
  sleep 1
284
285
  end
285
- Nanite.start :mapper => true, :host => 'localhost', :user => 'mapper', :pass => 'testing', :vhost => '/nanite', :log_level => 'info'
286
+ Nanite.start_mapper(:host => 'localhost', :user => 'mapper', :pass => 'testing', :vhost => '/nanite', :log_level => 'info')
286
287
  end
287
288
 
288
289
  Mongrel on the other hand does not use EventMachine and therefore requires to wrap the start of our mapper
289
290
 
290
291
  Thread.new do
291
292
  EM.run do
292
- Nanite.start :mapper => true, :host => 'localhost', :user => 'mapper', :pass => 'testing', :vhost => '/nanite', :log_level => 'info'
293
+ Nanite.start_mapper(:host => 'localhost', :user => 'mapper', :pass => 'testing', :vhost => '/nanite', :log_level => 'info')
293
294
  end
294
295
  end
295
296
 
297
+ Using nanite with Passenger:
298
+
299
+ current = Thread.current
300
+ Thread.new do
301
+ AMQP.start(:host => AMQP_HOST) do
302
+ current.wakeup
303
+ end
304
+ end
305
+ Thread.stop
306
+
307
+ # catch these, stop AMQP, stop eventmachine, and re-throw to
308
+ Mongrel/Passenger's signal traps
309
+ EM.run do
310
+ ['INT', 'TERM'].each do |sig|
311
+ old = trap(sig) do
312
+ AMQP.stop do
313
+ EM.stop
314
+ old.call
315
+ end
316
+ end
317
+ end
318
+ end
319
+
320
+ =======
296
321
  Where to put the mapper initialization code depends on the framework and our preference.
297
322
  For Rails the canonical place to start our mapper is within nanite.rb (or any other filename you prefer) in config/initalizers.
298
323
  In Merb we can use init.rb in config.
@@ -321,7 +346,7 @@ The easiest way to verify it is by starting two separate Erlang shells like this
321
346
  $ erl -sname fred
322
347
  (fred@odin)1>
323
348
 
324
- $erl -sname bob
349
+ $ erl -sname bob
325
350
  (bob@odin)1>
326
351
 
327
352
  And then trying to 'ping' one from the other. In the 'fred' node you can do that like this:
data/Rakefile CHANGED
@@ -10,7 +10,7 @@ end
10
10
  require 'rake/clean'
11
11
 
12
12
  GEM = "nanite"
13
- VER = "0.3.0"
13
+ VER = "0.4.0"
14
14
  AUTHOR = "Ezra Zygmuntowicz"
15
15
  EMAIL = "ezra@engineyard.com"
16
16
  HOMEPAGE = "http://github.com/ezmobius/nanite"
@@ -33,7 +33,6 @@ spec = Gem::Specification.new do |s|
33
33
  s.bindir = "bin"
34
34
  s.executables = %w( nanite-agent nanite-mapper nanite-admin )
35
35
 
36
- s.add_dependency "extlib"
37
36
  s.add_dependency('amqp', '>= 0.6.0')
38
37
 
39
38
  s.require_path = 'lib'
data/TODO CHANGED
@@ -9,17 +9,16 @@ Ian:
9
9
  - Update docs for Agent#start and Mapper#start
10
10
  - Update docs in nanite-agent and nanite-mapper
11
11
  - Ensure file transfer works
12
- - Ensure admin works
13
12
  - Check secure stuff still works
14
13
  - Check custom status_proc works
15
- - Update README
16
14
  - Check documentation, only document public methods
17
- - no_declare => true in dispatcher.rb?
18
15
  - ensure the removal of threaded_actors option doesn't cause shit to block
19
16
 
20
- Points:
17
+ - Look into using EM deferables for actors dispatch.
18
+ - Integration specs that spawn a small cluster of nanites
19
+ - Rename Ping to Status
20
+ - request/push should take *args for payload?
21
21
 
22
- - Is exchanges.rb old code?
23
- - Removed threaded_actors option as subscribe is async anyway - true?
24
- - Wouldn't it be better to blow up if the default serializer doesn't work? We could be cascading with every messages and never know.
25
- - What's the point of || 'index' in the dispatcher?
22
+ Maybe:
23
+ - Make mapper queue durable and Results respect :persistent flag on the request
24
+ - Add a global result received callback
data/bin/nanite-admin CHANGED
@@ -48,12 +48,18 @@ opts = OptionParser.new do |opts|
48
48
  opts.separator '*'*80
49
49
 
50
50
  setup_mapper_options(opts, options)
51
+
52
+ opts.on("--thin-debug", "Set the equivalent of the '--debug' flag on the Thin webserver.") do
53
+ options[:thin_debug] = true
54
+ end
51
55
  end
52
56
 
53
57
  opts.parse!
54
58
 
55
59
  EM.run do
56
- mapper = Nanite::Mapper.start(options)
57
- puts "starting nanite-admin"
58
- Rack::Handler::Thin.run(Nanite::Admin.new(mapper), :Port => 4000)
60
+ Nanite.start_mapper(options)
61
+ Nanite::Log.info "starting nanite-admin"
62
+ Rack::Handler::Thin.run(Nanite::Admin.new(Nanite.mapper), :Port => 4000) do
63
+ Thin::Logging.debug = options[:thin_debug]
64
+ end
59
65
  end
data/bin/nanite-agent CHANGED
@@ -25,6 +25,24 @@ end
25
25
 
26
26
  opts.parse!
27
27
 
28
+ if ARGV[0] == 'stop'
29
+ agent = Nanite::Agent.new(options)
30
+ pid_file = Nanite::PidFile.new(agent.identity, agent.options)
31
+ unless pid = pid_file.read_pid
32
+ puts "#{pid_file} not found"
33
+ exit
34
+ end
35
+ puts "Stopping nanite agent #{agent.identity} (pid #{pid})"
36
+ begin
37
+ Process.kill('TERM', pid)
38
+ rescue Errno::ESRCH
39
+ puts "Process does not exist (pid #{pid})"
40
+ exit
41
+ end
42
+ puts 'Done.'
43
+ exit
44
+ end
45
+
28
46
  EM.run do
29
- Nanite::Agent.start(options)
47
+ Nanite.start_agent(options)
30
48
  end
data/bin/nanite-mapper CHANGED
@@ -17,6 +17,24 @@ end
17
17
 
18
18
  opts.parse!
19
19
 
20
+ if ARGV[0] == 'stop'
21
+ mapper = Nanite::Mapper.new(options)
22
+ pid_file = Nanite::PidFile.new(mapper.identity, mapper.options)
23
+ unless pid = pid_file.read_pid
24
+ puts "#{pid_file} not found"
25
+ exit
26
+ end
27
+ puts "Stopping nanite mapper #{mapper.identity} (pid #{pid})"
28
+ begin
29
+ Process.kill('TERM', pid)
30
+ rescue Errno::ESRCH
31
+ puts "Process does not exist (pid #{pid})"
32
+ exit
33
+ end
34
+ puts 'Done.'
35
+ exit
36
+ end
37
+
20
38
  EM.run do
21
- Nanite::Mapper.start(options)
39
+ Nanite.start_mapper(options)
22
40
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ezmobius-nanite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ezra Zygmuntowicz
@@ -9,19 +9,9 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-13 00:00:00 -08:00
12
+ date: 2009-02-25 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: extlib
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "0"
24
- version:
25
15
  - !ruby/object:Gem::Dependency
26
16
  name: amqp
27
17
  type: :runtime