dispatch-rider 0.0.4 → 0.0.5
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.
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'daemons'
|
2
|
+
require 'pathname'
|
3
|
+
require 'optparse'
|
4
|
+
|
5
|
+
module DispatchRider
|
6
|
+
class Command
|
7
|
+
|
8
|
+
def initialize(options = {})
|
9
|
+
@app_home = Pathname.new(Dir.getwd)
|
10
|
+
@options = {
|
11
|
+
:log_output => true,
|
12
|
+
:dir_mode => :normal,
|
13
|
+
:log_dir => (@app_home + "log").to_s,
|
14
|
+
:dir => (@app_home + "log").to_s,
|
15
|
+
:multiple => false,
|
16
|
+
:monitor => false,
|
17
|
+
:identifier => 0,
|
18
|
+
}.merge(options)
|
19
|
+
end
|
20
|
+
|
21
|
+
def run(args, &block)
|
22
|
+
process_args(args)
|
23
|
+
|
24
|
+
process_name = "dispatch_rider.#{@options[:identifier]}"
|
25
|
+
Daemons.run_proc(process_name, @options) do
|
26
|
+
$0 = File.join(@options[:prefix], process_name) if @options[:prefix]
|
27
|
+
Dir.chdir(@app_home.to_s) do
|
28
|
+
block.call
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def process_args(args)
|
36
|
+
opts = OptionParser.new do |opts|
|
37
|
+
opts.banner = "Usage: #{File.basename($0)} [options] start|stop|restart|run"
|
38
|
+
opts.on('-h', '--help', 'Show this message') do
|
39
|
+
puts opts
|
40
|
+
exit 1
|
41
|
+
end
|
42
|
+
opts.on('-i', '--identifier=n', 'A numeric identifier for the worker.') do |n|
|
43
|
+
@options[:identifier] = n
|
44
|
+
end
|
45
|
+
opts.on('-m', '--monitor', 'Start monitor process.') do
|
46
|
+
@options[:monitor] = true
|
47
|
+
end
|
48
|
+
opts.on('-p', '--prefix NAME', "String to be prefixed to worker process names") do |prefix|
|
49
|
+
@options[:prefix] = prefix
|
50
|
+
end
|
51
|
+
end
|
52
|
+
@opts = opts.parse!(args)
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
@@ -7,7 +7,7 @@ module DispatchRider
|
|
7
7
|
|
8
8
|
def assign_storage(attrs)
|
9
9
|
begin
|
10
|
-
AWS::SQS.new.queues.named(attrs.fetch(:name))
|
10
|
+
AWS::SQS.new(:logger => nil).queues.named(attrs.fetch(:name))
|
11
11
|
rescue NameError
|
12
12
|
raise AdapterNotFoundError.new(self.class.name, 'aws-sdk')
|
13
13
|
rescue IndexError
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dispatch-rider
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-08-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -159,15 +159,14 @@ description: Messaging system that is customizable based on which queueing syste
|
|
159
159
|
we are using.
|
160
160
|
email:
|
161
161
|
- sumanmukherjee03@gmail.com
|
162
|
-
executables:
|
163
|
-
- dispatch_rider
|
162
|
+
executables: []
|
164
163
|
extensions: []
|
165
164
|
extra_rdoc_files:
|
166
165
|
- LICENSE.txt
|
167
166
|
- README.md
|
168
167
|
files:
|
169
|
-
- bin/dispatch_rider
|
170
168
|
- lib/dispatch-rider.rb
|
169
|
+
- lib/dispatch-rider/command.rb
|
171
170
|
- lib/dispatch-rider/demultiplexer.rb
|
172
171
|
- lib/dispatch-rider/dispatcher.rb
|
173
172
|
- lib/dispatch-rider/errors.rb
|
@@ -214,7 +213,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
214
213
|
version: '0'
|
215
214
|
segments:
|
216
215
|
- 0
|
217
|
-
hash: -
|
216
|
+
hash: -2508309376756664510
|
218
217
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
219
218
|
none: false
|
220
219
|
requirements:
|
@@ -223,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
223
222
|
version: '0'
|
224
223
|
requirements: []
|
225
224
|
rubyforge_project:
|
226
|
-
rubygems_version: 1.8.
|
225
|
+
rubygems_version: 1.8.23
|
227
226
|
signing_key:
|
228
227
|
specification_version: 3
|
229
228
|
summary: Messaging system based on the reactor patter. You can publish messages to
|
data/bin/dispatch_rider
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
#!/bin/env ruby
|
2
|
-
|
3
|
-
raise "this script is meant to be ran from inside of a Rails.root" unless File.exist?("config/environment.rb")
|
4
|
-
|
5
|
-
require 'rubygems'
|
6
|
-
require 'daemons'
|
7
|
-
require 'pathname'
|
8
|
-
|
9
|
-
gem_home = Pathname.new(__FILE__) + "../.."
|
10
|
-
app_home = Pathname.new(Dir.getwd)
|
11
|
-
|
12
|
-
Daemons.run_proc("dispatch_rider", :log_output => true, :dir_mode => :normal, :log_dir => (app_home + "log").to_s, :dir => (app_home + "log").to_s) do
|
13
|
-
Dir.chdir(app_home.to_s) do
|
14
|
-
require "./config/environment"
|
15
|
-
Rails.application.config.dispatch_rider.process
|
16
|
-
end
|
17
|
-
end
|