def start
include_ramaze
app_name = default_pidfile.sub(/\.pid$/,'')
rack_args = []
if daemonize = @ourargs.detect { |arg| arg.match(/^(-[dD]|--daemonize)$/) }
if pid_arg = @ourargs.detect { |arg| arg.match(/^(-P|--pid)/) }
puts "User supplied pid: #{pid_arg}"
pid_file = @ourargs[@ourargs.index(pid_arg) + 1]
puts "Starting daemon with user defined pidfile: #{pid_file}"
else
puts "Starting daemon with default pidfile: #{pid_file = default_pidfile}"
rack_args += ["-P", pid_file]
end
if check_running?(pid_file)
$stderr.puts "Ramaze is already running with pidfile: #{pid_file}"
exit 127
end
end
port = Ramaze.options.adapter.port.to_s
rack_args += ["-p", port ] if @ourargs.grep(/^(-p|--port)/).empty?
handler = Ramaze.options.adapter.handler.to_s
rack_args += ["-s", handler] if @ourargs.grep(/^(-s|--server)/).empty?
if is_windows?
exec("ruby", rackup_path.to_s, "config.ru", *(ARGV + rack_args))
else
exec(rackup_path.to_s, "config.ru", *(ARGV + rack_args))
end
end