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 # set log level if requested
54 if @options[:log_level]
55 God.log_level = @options[:log_level]
60 unless File.exist?(@options[:config])
61 abort "File not found: #{@options[:config]}"
65 load File.expand_path(@options[:config])
67 if e.instance_of?(SystemExit)
71 puts e.backtrace.join("\n")
72 abort "There was an error in your configuration file (see above)"
77 # reset file descriptors
78 STDIN.reopen "/dev/null"
79 STDOUT.reopen(log_file, "a")
83 puts e.backtrace.join("\n")
84 abort "There was a fatal system error while starting god (see above)"
89 File.open(@options[:pid], 'w') { |f| f.write pid }
101 God.port = @options[:port]
104 # set log level if requested
105 if @options[:log_level]
106 God.log_level = @options[:log_level]
110 unless File.exist?(@options[:config])
111 abort "File not found: #{@options[:config]}"
115 load File.expand_path(@options[:config])
116 rescue Exception => e
117 if e.instance_of?(SystemExit)
121 puts e.backtrace.join("\n")
122 abort "There was an error in your configuration file (see above)"