lib/dante/runner.rb in dante-0.1.1 vs lib/dante/runner.rb in dante-0.1.2
- old
+ new
@@ -118,17 +118,34 @@
def interrupt
raise Interrupt
sleep(1)
end
+ # Returns true if process is not running
+ def daemon_stopped?
+ ! self.daemon_running?
+ end
+
+ # Returns running for the daemonized process
+ # self.daemon_running?
+ def daemon_running?
+ return false unless File.exist?(options[:pid_path])
+ Process.kill 0, File.read(options[:pid_path]).to_i
+ true
+ rescue Errno::ESRCH
+ false
+ end
+
+ protected
+
def parse_options
headline = [@name, @description].compact.join(" - ")
OptionParser.new do |opts|
opts.summary_width = 25
opts.banner = [headline, "\n\n",
- "Usage: #{@name} [-p port] [-P file] [-d] [-k]\n",
- " #{@name} --help\n"].compact.join("")
+ "Usage: #{@name} [-p port] [-P file] [-d] [-k]\n",
+ " #{@name} --help\n"].compact.join("")
opts.separator ""
opts.on("-p", "--port PORT", Integer, "Specify port", "(default: #{options[:port]})") do |v|
options[:port] = v
end
@@ -162,12 +179,10 @@
instance_exec(opts, &@with_options) if @with_options
end.parse!
options
end
- protected
-
def store_pid(pid)
FileUtils.mkdir_p(File.dirname(options[:pid_path]))
File.open(options[:pid_path], 'w'){|f| f.write("#{pid}\n")}
end
@@ -191,24 +206,9 @@
while elapsed_seconds < timeout_seconds && block.call != true
elapsed_seconds += interval
sleep(interval)
end
elapsed_seconds < timeout_seconds
- end
-
- # Returns true if process is not running
- def daemon_stopped?
- ! self.daemon_running?
- end
-
- # Returns running for the daemonized process
- # self.daemon_running?
- def daemon_running?
- return false unless File.exist?(options[:pid_path])
- Process.kill 0, File.read(options[:pid_path]).to_i
- true
- rescue Errno::ESRCH
- false
end
def log(message)
puts message if options[:debug]
end
\ No newline at end of file