opener-daemons 0.7.1 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NTQ4M2FiNDUwMzBhM2Q3ZTBhZjdlODM1ZjJkOWI5YWZiNzIxYjhkNg==
4
+ ODdlMTlmMWVmODEwYjhhYmUwNDk0ZjdhMjFlMWIwZTg3ZjU3ZTZmNQ==
5
5
  data.tar.gz: !binary |-
6
- YTJjODBiN2IzMjVjNjkwNzZmZTY4ZTI2MTk4NjU4NzlkYmE0ZWViYg==
6
+ NzQ3MTczMjY3ZDE1ZjM5ZmExYjQ0ZTRlN2FjMGZhYTA3NDI0MDQzYQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NDJkOWU3YzU0NzJkMjM2MDUxYjc2OWQ5MDM2YjNjMGY1NGIzOTA1NGEwYmI1
10
- NjRjZmRlYjFhN2M0NTU5ZGEzN2UwNTNhNzFkMGRlM2RkMWZjZmFhYmQ4NDk5
11
- NmE2NTg0ODJiMTEyN2VjZjRhNGU2MjQ2YjBkZWNjNzVkOGVkNzQ=
9
+ ODViNjAwNTA0NWZjMDI5MzA4MzljZmU2ZTgwODYzYjdjYzQ2OTdjMWE2ZTM2
10
+ MDJmYmE1MDNkY2I2MmY5Y2Y1M2JmZDc1ODNjMTZmZTJmOGM4ZjNkZTQ2MTc2
11
+ YTdkNTU0NDBmNjlmMmNjYzRlY2NjYjk5ZDU2NzgzMTIxMWI1YWM=
12
12
  data.tar.gz: !binary |-
13
- ZTZiOWIwNTEwN2MxZWU2NWY5YzQ0MDdkNWI5NDBmYjM5YzFiYmE5ODEwZWMy
14
- Mjk0YWY4NmZjYTQ4NTMyYjIzNTE2ODNhNjQ1YThiODUzM2FhNWQyZWU5NWNi
15
- NzIzZDRiMDVmZjZhNzFhYjI4YWQ2ZmZiZWYxZTg5NTQ4ZjMyMDc=
13
+ NDBhMzkxZTUxODI2ZjczYjc4MmNkMmQ3ODc4MDZhOGIxNzE3MjBjOWI4NDBk
14
+ YWU1MmMwZjM1MDBmYTE3YWZiMjA3YWJlMGViZjhiODYzMzIyZGFlY2ZhOTE5
15
+ OWIxYjQzNzMyZDI3OTk2MGQwODEwYTEwZWMxOTc3MzE4NTQwODI=
@@ -44,15 +44,15 @@ module Opener
44
44
  def options
45
45
  return @options if @options
46
46
  args = ARGV.dup
47
- @options = Opener::Daemons::OptParser.parse!(args)
47
+ @options = Opener::Daemons::OptParser.pre_parse!(args)
48
48
  end
49
49
 
50
50
 
51
51
  def pid_path
52
52
  return @pid_path unless @pid_path.nil?
53
- @pid_path = if @options[:pid]
53
+ @pid_path = if options[:pid]
54
54
  File.expand_path(@options[:pid])
55
- elsif @options[:pidpath]
55
+ elsif options[:pidpath]
56
56
  File.expand_path(File.join(@options[:pidpath], "#{name}.pid"))
57
57
  else
58
58
  "/var/run/#{File.basename($0, ".rb")}.pid"
@@ -79,7 +79,7 @@ module Opener
79
79
  pid = pid.to_s.gsub(/[^0-9]/,'')
80
80
  end
81
81
  rescue => e
82
- STDOUT.puts "Info: Unable to open #{pid_path} for reading:\n\t" +
82
+ STDOUT.puts "Info: Unable to open #{pid_path} for reading while checking for existing PID:\n\t" +
83
83
  "(#{e.class}) #{e.message}"
84
84
  end
85
85
 
@@ -18,6 +18,16 @@ module Opener
18
18
  process(:parse!, args)
19
19
  end
20
20
 
21
+ def pre_parse!(args)
22
+ delete_double_dash = false
23
+ process(:parse!, args, delete_double_dash)
24
+ end
25
+
26
+ def pre_parse(args)
27
+ delete_double_dash = false
28
+ process(:parse, args, delete_double_dash)
29
+ end
30
+
21
31
  def self.parse(args)
22
32
  new.parse(args)
23
33
  end
@@ -26,9 +36,18 @@ module Opener
26
36
  new.parse!(args)
27
37
  end
28
38
 
39
+ def self.pre_parse!(args)
40
+ new.pre_parse!(args)
41
+ end
42
+
43
+ def self.pre_parse(args)
44
+ new.pre_parse(args)
45
+ end
46
+
29
47
  private
30
48
 
31
- def process(call, args)
49
+ def process(call, args, delete_double_dash=true)
50
+ args.delete("--") if delete_double_dash
32
51
  option_parser.send(call, args)
33
52
  return options
34
53
  end
@@ -37,7 +56,12 @@ module Opener
37
56
  script_name = File.basename($0, ".rb")
38
57
 
39
58
  OptionParser.new do |opts|
40
- opts.banner = "Usage: #{script_name} <start|stop|restart> [options]"
59
+ if block_given?
60
+ opts.banner = "Usage: #{script_name} <start|stop|restart> [daemon_options] -- [component_options]"
61
+ else
62
+ opts.banner = "Usage: #{script_name} <start|stop|restart> [options]"
63
+ end
64
+
41
65
  opts.separator ""
42
66
  opts.separator "When calling #{script_name} without <start|stop|restart> the daemon will start as a foreground process"
43
67
  opts.separator ""
@@ -51,43 +75,43 @@ module Opener
51
75
 
52
76
  opts.separator "Daemon options:"
53
77
 
54
- opts.on("-i", "--input INPUT_QUEUE_NAME", "Input queue name") do |v|
78
+ opts.on("-i", "--input QUEUE_NAME", "Input queue name") do |v|
55
79
  options[:input_queue] = v
56
80
  end
57
81
 
58
- opts.on("-o", "--output OUTPUT_QUEUE_NAME", "Output queue name") do |v|
82
+ opts.on("-o", "--output QUEUE_NAME", "Output queue name") do |v|
59
83
  options[:output_queue] = v
60
84
  end
61
85
 
62
- opts.on("--batch-size ITEMS", Integer, "Request x messages at once where x is between 1 and 10") do |v|
86
+ opts.on("--batch-size COUNT", Integer, "Request x messages at once where x is between 1 and 10") do |v|
63
87
  options[:batch_size] = v
64
88
  end
65
89
 
66
- opts.on("--buffer-size ITEMS", Integer, "Size of input and output buffer. Defaults to 4 * batch-size") do |v|
90
+ opts.on("--buffer-size COUNT", Integer, "Size of input and output buffer. Defaults to 4 * batch-size") do |v|
67
91
  options[:buffer_size] = v
68
92
  end
69
93
 
70
- opts.on("--sleep-interval TIME_IN_SECONDS", Integer, "The interval to sleep when the queue is empty (seconds)") do |v|
94
+ opts.on("--sleep-interval SECONDS", Integer, "The interval to sleep when the queue is empty (seconds)") do |v|
71
95
  options[:sleep_interval] = v
72
96
  end
73
97
 
74
- opts.on("-w", "--workers NUMBER", Integer, "number of worker thread") do |v|
75
- options[:workers] = v
98
+ opts.on("-r", "--readers COUNT", Integer, "number of reader threads") do |v|
99
+ options[:readers] = v
76
100
  end
77
101
 
78
- opts.on("-r", "--readers NUMBER", Integer, "number of reader threads") do |v|
79
- options[:readers] = v
102
+ opts.on("-w", "--workers COUNT", Integer, "number of worker thread") do |v|
103
+ options[:workers] = v
80
104
  end
81
105
 
82
- opts.on("-p", "--writers NUMBER", Integer, "number of writer / pusher threads") do |v|
106
+ opts.on("-p", "--writers COUNT", Integer, "number of writer / pusher threads") do |v|
83
107
  options[:writers] = v
84
108
  end
85
109
 
86
- opts.on("--log FILENAME", "Filename and path of logfile. Defaults to STDOUT") do |v|
110
+ opts.on("-l", "--logfile FILENAME", "--log FILENAME", "Filename and path of logfile. Defaults to STDOUT") do |v|
87
111
  options[:log] = v
88
112
  end
89
113
 
90
- opts.on("--pidfile FILENAME", "--pid FILENAME", "Filename and path of pidfile. Defaults to /var/run/#{script_name}.pid") do |v|
114
+ opts.on("-P", "--pidfile FILENAME", "--pid FILENAME", "Filename and path of pidfile. Defaults to /var/run/#{script_name}.pid") do |v|
91
115
  options[:pid] = v
92
116
  end
93
117
 
@@ -109,7 +133,7 @@ module Opener
109
133
 
110
134
  # No argument, shows at tail. This will print an options summary.
111
135
  # Try it and see!
112
- opts.on_tail("-h", "--help", "Show this message") do
136
+ opts.on_tail("-h", "--help", "Show this message. Usage: #{script_name} -h") do
113
137
  puts opts
114
138
  exit
115
139
  end
@@ -1,5 +1,5 @@
1
1
  module Opener
2
2
  module Daemons
3
- VERSION = "0.7.1"
3
+ VERSION = "0.8.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opener-daemons
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wilco van Duinkerken