test/support/apache2_controller.rb
# Create an Apache configuration folder and start Apache on that
# configuration folder. This method does not return until Apache
# has done initializing.
#
# If Apache is already started, this this method will stop Apache first.
Create an Apache configuration folder and start Apache on that
configuration folder. This method does not return until Apache
has done initializing.

If Apache is already started, this this method will stop Apache first.
Create an Apache configuration folder and start Apache on that configuration folder . This method does not return until Apache has done initializing . If Apache is already started this this method will stop Apache first .
def start
    if running?
      stop
    else
      File.unlink("#{@server_root}/httpd.pid") rescue nil
    end
    if File.exist?(@server_root)
      FileUtils.rm_r(@server_root)
    end
    FileUtils.mkdir_p(@server_root)
    write_config_file
    FileUtils.cp("#{STUB_DIR}/mime.types", @server_root)
    command = [PlatformInfo.httpd, "-f", "#{@server_root}/httpd.conf", "-k", "start"]
    if boolean_option('VALGRIND')
      command = ['valgrind', '--dsymutil=yes', '--vgdb=yes',
        '--vgdb-error=1', '--trace-children=no'] + command
    end
    if !system(*command)
      raise "Could not start an Apache server."
    end
    begin
      Timeout::timeout(20) do
        while !File.exist?("#{@server_root}/httpd.pid")
          sleep(0.1)
        end
      end
      Timeout::timeout(7) do
        done = false
        while !done
          begin
            socket = TCPSocket.new('localhost', @port)
            socket.close
            done = true
          rescue Errno::ECONNREFUSED
            sleep(0.1)
          end
        end
      end
    rescue Timeout::Error
      raise "Could not start an Apache server."
    end
    Dir["#{@server_root}/*"].each do |filename|
      if File.file?(filename)
        File.chmod(0666, filename)
      end
    end
  end
def start if running? stop else File . unlink ( "#{@server_root}/httpd.pid" ) rescue nil end if File . exist? ( @server_root ) FileUtils . rm_r ( @server_root ) end FileUtils . mkdir_p ( @server_root ) write_config_file FileUtils . cp ( "#{STUB_DIR}/mime.types" , @server_root ) command = [ PlatformInfo . httpd , "-f" , "#{@server_root}/httpd.conf" , "-k" , "start" ] if boolean_option ( 'VALGRIND' ) command = [ 'valgrind' , '--dsymutil=yes' , '--vgdb=yes' , '--vgdb-error=1' , '--trace-children=no' ] + command end if ! system ( * command ) raise "Could not start an Apache server." end begin Timeout :: timeout ( 20 ) do while ! File . exist? ( "#{@server_root}/httpd.pid" ) sleep ( 0.1 ) end end Timeout :: timeout ( 7 ) do done = false while ! done begin socket = TCPSocket . new ( 'localhost' , @port ) socket . close done = true rescue Errno :: ECONNREFUSED sleep ( 0.1 ) end end end rescue Timeout :: Error raise "Could not start an Apache server." end Dir [ "#{@server_root}/*" ] . each do | filename | if File . file? ( filename ) File . chmod ( 0666 , filename ) end end end
Create an Apache configuration folder and start Apache on that
configuration folder.
Create an Apache configuration folder and start Apache on that configuration folder .
# Wait until the PID file has been created. # Wait until Apache is listening on the server port.