0
+ # Classes are modules and I hate this 'Base' class pattern. I'm putting
0
+ # other classes inside this one.
0
+ autoload :Rails, LIBDIR + '/ebb/runner/rails'
0
# Kill the process which PID is stored in +pid_file+.
0
def self.kill(pid_file, timeout=60)
0
raise ArgumentError, 'You must specify a pid_file to stop deamonized server' unless pid_file
0
@@ -28,12 +32,12 @@ module Ebb
0
Process.kill('KILL', pid)
0
+ Ebb.log.puts "stopped!"
0
- puts "Can't stop process, no PID found in #{@pid_file}"
0
+ Ebb.log.puts "Can't stop process, no PID found in #{@pid_file}"
0
rescue Errno::ESRCH # No such process
0
- puts "process not found!"
0
+ Ebb.log.puts "process not found!"
0
File.delete(pid_file) rescue nil
0
@@ -43,13 +47,14 @@ module Ebb
0
def self.write_pid_file(file)
0
- puts ">> Writing PID to #{file}"
0
+ Ebb.log.puts ">> Writing PID to #{file}"
0
open(file,"w+") { |f| f.write(Process.pid) }
0
@parser = OptionParser.new
0
@@ -58,8 +63,7 @@ module Ebb
0
+ def parse_options(argv)
0
@parser.banner = "Usage: #{self.class} [options] start | stop"
0
extra_options if respond_to?(:extra_options)
0
@@ -74,22 +78,26 @@ module Ebb
0
@parser.on_tail("-h", "--help", "Show this message") do
0
@parser.on_tail('-v', '--version', "Show version") do
0
- puts "Ebb #{Ebb::VERSION}"
0
+ Ebb.log.puts "Ebb #{Ebb::VERSION}"
0
- STDOUT.print("Ebb is loading the application...")
0
+ Ebb.log.print("Ebb is loading the application...")
0
+ Ebb.log.puts("loaded")
0
if @options[:daemonize]
0
pwd = Dir.pwd # Current directory is changed during daemonization, so store it
0
@@ -105,7 +113,7 @@ module Ebb
0
Runner.write_pid_file(@options[:pid_file])
0
+ Ebb.log.puts ">> Exiting!"
0
Runner.remove_pid_file(@options[:pid_file])
0
@@ -114,8 +122,8 @@ module Ebb
0
Ebb::Runner.kill @options[:pid_file], @options[:timeout]
0
- puts "Command required"
0
+ Ebb.log.puts "Command required"
0
abort "Invalid command : #{argv[0]}"
0
@@ -124,3 +132,4 @@ module Ebb