opener-daemons 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/opener/daemons/controller.rb +10 -8
- data/lib/opener/daemons/opt_parser.rb +4 -1
- data/lib/opener/daemons/sqs.rb +6 -1
- data/lib/opener/daemons/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dddfc053344357d876c12752682cfe4d8b37cfc4
|
4
|
+
data.tar.gz: 5de52afce7b4095875968f82946aa0deaa02e336
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92433dfca4b37bd36cbd3a18ccd01aca500693cecca1b332030ddf3777fbe113a49ab8e43b40dd03fd3807418b8fe4e20ba234ed07a6a6fdb037bb9bddf0195f
|
7
|
+
data.tar.gz: 01655ecacf831442ec2e534820bb4dcc44ef3679bd27f8409e42c6270d5816f0fd07f2a6fbac5835c28f2bb24e2a7a1956e0140802542ef99c92885a5ee3c65c
|
@@ -11,11 +11,11 @@ require 'spoon'
|
|
11
11
|
module Opener
|
12
12
|
module Daemons
|
13
13
|
class Controller
|
14
|
-
attr_reader :name, :
|
14
|
+
attr_reader :name, :exec_path
|
15
15
|
|
16
16
|
def initialize(options={})
|
17
|
-
@
|
18
|
-
@name
|
17
|
+
@exec_path = options.fetch(:exec_path)
|
18
|
+
@name = determine_name(options[:name])
|
19
19
|
read_commandline
|
20
20
|
end
|
21
21
|
|
@@ -25,7 +25,7 @@ module Opener
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def get_name_from_exec_path
|
28
|
-
File.basename(
|
28
|
+
File.basename(exec_path, ".rb")
|
29
29
|
end
|
30
30
|
|
31
31
|
def read_commandline
|
@@ -42,9 +42,7 @@ module Opener
|
|
42
42
|
elsif ARGV[0] == '-h'
|
43
43
|
Opener::Daemons::OptParser.parse!(ARGV)
|
44
44
|
else
|
45
|
-
|
46
|
-
puts "Or for help use: #{name} -h"
|
47
|
-
exit!
|
45
|
+
start_foreground
|
48
46
|
end
|
49
47
|
end
|
50
48
|
|
@@ -143,7 +141,7 @@ module Opener
|
|
143
141
|
end
|
144
142
|
|
145
143
|
STDOUT.puts "Starting DAEMON"
|
146
|
-
pid = Spoon.spawnp
|
144
|
+
pid = Spoon.spawnp exec_path, *ARGV
|
147
145
|
STDOUT.puts "Started DAEMON"
|
148
146
|
create_pid(pid)
|
149
147
|
begin
|
@@ -154,6 +152,10 @@ module Opener
|
|
154
152
|
File::umask(0)
|
155
153
|
end
|
156
154
|
|
155
|
+
def start_foreground
|
156
|
+
exec [exec_path, ARGV].flatten.join(" ")
|
157
|
+
end
|
158
|
+
|
157
159
|
def identify(string)
|
158
160
|
string.gsub(/\W/,"-").gsub("--","-")
|
159
161
|
end
|
@@ -14,9 +14,12 @@ module Opener
|
|
14
14
|
|
15
15
|
def self.process(args, call)
|
16
16
|
options = {}
|
17
|
+
script_name = File.basename($0, ".rb")
|
17
18
|
|
18
19
|
OptionParser.new do |opts|
|
19
|
-
opts.banner = "Usage:
|
20
|
+
opts.banner = "Usage: #{script_name} <start|stop|restart> [options]"
|
21
|
+
opts.separator ""
|
22
|
+
opts.separator "When calling #{script_name} without <start|stop|restart> the daemon will start as a foreground process"
|
20
23
|
opts.separator ""
|
21
24
|
opts.separator "Specific options:"
|
22
25
|
|
data/lib/opener/daemons/sqs.rb
CHANGED
@@ -12,7 +12,12 @@ module Opener
|
|
12
12
|
def initialize(name)
|
13
13
|
@sqs = Aws::SQS.new
|
14
14
|
@name = name
|
15
|
-
|
15
|
+
begin
|
16
|
+
@url = sqs.get_queue_url(:queue_name=>name)[:queue_url]
|
17
|
+
rescue Aws::SQS::Errors::NonExistentQueue => e
|
18
|
+
STDERR.puts "Could not find queue #{name}"
|
19
|
+
raise
|
20
|
+
end
|
16
21
|
end
|
17
22
|
|
18
23
|
def send_message(message)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opener-daemons
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wilco van Duinkerken
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-core
|