170: def daemonize(options={})
171: ops = resolve_defaults(options)
172:
173: if RUBY_PLATFORM !~ /mswin/
174: require 'daemons/daemonize'
175:
176: logfile = ops[:log_file]
177: if logfile[0].chr != "/"
178: logfile = File.join(ops[:cwd],logfile)
179: if not File.exist?(File.dirname(logfile))
180: log "!!! Log file directory not found at full path #{File.dirname(logfile)}. Update your configuration to use a full path."
181: exit 1
182: end
183: end
184:
185: Daemonize.daemonize(logfile)
186:
187:
188: Dir.chdir(ops[:cwd])
189:
190: else
191: log "WARNING: Win32 does not support daemon mode."
192: end
193: end