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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d0b2126a8b6322257975cfa14b323e8adc2b764
4
- data.tar.gz: 9d5cd048fed57092de5bca35d930f25cc7ec1ae5
3
+ metadata.gz: dddfc053344357d876c12752682cfe4d8b37cfc4
4
+ data.tar.gz: 5de52afce7b4095875968f82946aa0deaa02e336
5
5
  SHA512:
6
- metadata.gz: 2e557daafe0982331f859d5c6b0100b1c8cbfedcd8e2256215fc1a4175ceb4628a70c9edef86a962d19bccf769412ee8ea42c2721464fce3d0486689287dea31
7
- data.tar.gz: e7d8736c85e18449ba7cf4192bd7840547c05bc12eedcb13651d9db74b302ca6f38e1a519a5a3b432eb114292df25126aeff28d5ccf422edc24f7f385e51bfcf
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, :exec
14
+ attr_reader :name, :exec_path
15
15
 
16
16
  def initialize(options={})
17
- @exec = options.fetch(:exec_path)
18
- @name = determine_name(options[: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(exec, ".rb")
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
- puts "Usage: #{name} <start|stop|restart> [options]"
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 exec, *ARGV
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: language-identifier.rb <start|stop|restart> [options]"
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
 
@@ -12,7 +12,12 @@ module Opener
12
12
  def initialize(name)
13
13
  @sqs = Aws::SQS.new
14
14
  @name = name
15
- @url = sqs.get_queue_url(:queue_name=>name)[:queue_url]
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)
@@ -1,5 +1,5 @@
1
1
  module Opener
2
2
  module Daemons
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
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.1.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-05 00:00:00.000000000 Z
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