Sha256: fdae594fa0a0869bb964afb6d6b8a41e7366adeb5f237acd71f613144203b826

Contents?: true

Size: 1.14 KB

Versions: 6

Compression:

Stored size: 1.14 KB

Contents

#!/usr/bin/env ruby
require 'socket'

STDOUT.sync = true
STDERR.sync = true
puts "!> I have control 1.0"
abort "Invalid initialization header" if STDIN.readline != "You have control 1.0\n"

options = {}
while (line = STDIN.readline) != "\n"
  name, value = line.strip.split(/: */, 2)
  options[name] = value
end

if ARGV[0] == "--execself"
  # Used for testing https://code.google.com/p/phusion-passenger/issues/detail?id=842#c19
  exec("ruby", $0)
end

server = TCPServer.new('127.0.0.1', 0)
puts "!> Ready"
puts "!> socket: main;tcp://127.0.0.1:#{server.addr[1]};session;1"
puts "!> "

while true
  ios = select([server, STDIN])[0]
  if ios.include?(server)
    client = server.accept
    line = client.readline
    if line == "ping\n"
      client.write("pong\n")
    elsif line == "pid\n"
      client.write("#{Process.pid}\n")
    elsif line == "envvars\n"
      str = ""
      ENV.each_pair do |key, value|
        str << "#{key} = #{value}\n"
      end
      client.write(str)
    else
      client.write("unknown request\n")
    end
    client.close
  end
  if ios.include?(STDIN)
    begin
      STDIN.readline
    rescue EOFError
      exit
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
passenger-5.0.4 test/stub/rack/start.rb
passenger-5.0.3 test/stub/rack/start.rb
passenger-5.0.2 test/stub/rack/start.rb
passenger-5.0.1 test/stub/rack/start.rb
passenger-5.0.0.rc2 test/stub/rack/start.rb
passenger-5.0.0.rc1 test/stub/rack/start.rb