5 def initialize(options)
12 # have at_exit start god
15 if @options[:daemonize]
23 # trap and ignore SIGHUP
30 log_file = @options[:log] || "/dev/null"
32 unless God::EventHandler.loaded?
34 puts "***********************************************************************"
36 puts "* Event conditions are not available for your installation of god."
37 puts "* You may still use and write custom conditions using the poll system"
39 puts "***********************************************************************"
43 # set port if requested
45 God.port = @options[:port]
48 # set pid if requested
50 God.pid = @options[:pid]
53 unless @options[:syslog]
59 # set log level, defaults to WARN
60 if @options[:log_level]
61 God.log_level = @options[:log_level]
66 unless File.exist?(@options[:config])
67 abort "File not found: #{@options[:config]}"
71 load File.expand_path(@options[:config])
73 if e.instance_of?(SystemExit)
77 puts e.backtrace.join("\n")
78 abort "There was an error in your configuration file (see above)"
83 # reset file descriptors
84 STDIN.reopen "/dev/null"
85 STDOUT.reopen(log_file, "a")
89 puts e.backtrace.join("\n")
90 abort "There was a fatal system error while starting god (see above)"
95 File.open(@options[:pid], 'w') { |f| f.write pid }
107 God.port = @options[:port]
110 # set log level if requested
111 if @options[:log_level]
112 God.log_level = @options[:log_level]
116 unless File.exist?(@options[:config])
117 abort "File not found: #{@options[:config]}"
121 load File.expand_path(@options[:config])
122 rescue Exception => e
123 if e.instance_of?(SystemExit)
127 puts e.backtrace.join("\n")
128 abort "There was an error in your configuration file (see above)"