0
+ # start attached pid watcher if necessary
0
+ God.port = @options[:port]
0
+ God::EventHandler.load
0
+ # set log level, defaults to WARN
0
+ if @options[:log_level]
0
+ God.log_level = @options[:log_level]
0
+ God.log_level = @options[:daemonize] ? :warn : :info
0
+ unless File.exist?(@options[:config])
0
+ abort "File not found: #{@options[:config]}"
0
+ # start the event handler
0
+ God::EventHandler.start if God::EventHandler.loaded?
0
+ load_config @options[:config]
0
+ if @options[:bleakhouse]
0
+ BleakHouseDiagnostic.install
0
+ log_file = File.expand_path(@options[:log])
0
+ puts "Sending output to log file: #{log_file}"
0
+ # reset file descriptors
0
+ STDIN.reopen "/dev/null"
0
+ STDOUT.reopen(log_file, "a")
0
# trap and ignore SIGHUP
0
- # start attached pid watcher if necessary
0
- # set port if requested
0
- God.port = @options[:port]
0
+ if @options[:pid]
# and as deamon0
God.pid = @options[:pid]
0
- God::EventHandler.load
0
unless God::EventHandler.loaded?
0
- # set log level, defaults to WARN
0
- if @options[:log_level]
0
- God.log_level = @options[:log_level]
0
- unless File.exist?(@options[:config])
0
- abort "File not found: #{@options[:config]}"
0
- # start the event handler
0
- God::EventHandler.start if God::EventHandler.loaded?
0
- load File.expand_path(@options[:config])
0
- if e.instance_of?(SystemExit)
0
- puts e.backtrace.join("\n")
0
- abort "There was an error in your configuration file (see above)"
0
puts e.backtrace.join("\n")
0
- if @options[:bleakhouse]
0
- BleakHouseDiagnostic.install
0
- # start attached pid watcher if necessary
0
- God.port = @options[:port]
0
- God::EventHandler.load
0
- # set log level if requested
0
- if @options[:log_level]
0
- God.log_level = @options[:log_level]
0
- unless File.exist?(@options[:config])
0
- abort "File not found: #{@options[:config]}"
0
+ def load_config(config)
0
+ if File.directory? config
0
+ Dir[File.expand_path('**/*.god', config)].each do |god_file|
0
+ files_loaded ||= load_god_file(File.expand_path(god_file))
0
- # start the event handler
0
- God::EventHandler.start if God::EventHandler.loaded?
0
- load File.expand_path(@options[:config])
0
- if e.instance_of?(SystemExit)
0
- puts e.backtrace.join("\n")
0
- abort "There was an error in your configuration file (see above)"
0
+ abort "No files could be loaded"
0
- log_file = File.expand_path(@options[:log])
0
- puts "Sending output to log file: #{log_file}"
0
- # reset file descriptors
0
- STDIN.reopen "/dev/null"
0
- STDOUT.reopen(log_file, "a")
0
+ unless load_god_file(File.expand_path(config))
0
+ abort "File could not be loaded"
0
+ def load_god_file(god_file)
0
+ load File.expand_path(god_file)
0
+ if e.instance_of?(SystemExit)
0
+ puts "There was an error in #{god_file}"
0
+ puts "\t" + e.backtrace.join("\n\t")
Comments
No one has commented yet.