def run_in_front
require 'god'
if @options[:bleakhouse]
BleakHouseDiagnostic.install
end
if @options[:attach]
self.attach
end
if @options[:port]
God.port = @options[:port]
end
if @options[:events]
God::EventHandler.load
end
unless @options[:syslog]
Logger.syslog = false
end
if @options[:log_level]
God.log_level = @options[:log_level]
end
if @options[:config]
unless File.exist?(@options[:config])
abort "File not found: #{@options[:config]}"
end
God::EventHandler.start if God::EventHandler.loaded?
begin
load File.expand_path(@options[:config])
rescue Exception => e
if e.instance_of?(SystemExit)
raise
else
puts e.message
puts e.backtrace.join("\n")
abort "There was an error in your configuration file (see above)"
end
end
if @options[:log]
log_file = File.expand_path(@options[:log])
puts "Sending output to log file: #{log_file}"
STDIN.reopen "/dev/null"
STDOUT.reopen(log_file, "a")
STDERR.reopen STDOUT
STDOUT.sync = true
end
end
end