Permalink
Switch branches/tags
request_handler_with_pipes release-5.3.1 release-5.3.0 release-5.2.3 release-5.2.2 release-5.2.1 release-5.2.0 release-5.1.12 release-5.1.11 release-5.1.10 release-5.1.9 release-5.1.8 release-5.1.7 release-5.1.6 release-5.1.5 release-5.1.4 release-5.1.3 release-5.1.2 release-5.1.1 release-5.1.0 release-5.0.30 release-5.0.29 release-5.0.28 release-5.0.27 release-5.0.26 release-5.0.25 release-5.0.24 release-5.0.23 release-5.0.22 release-5.0.21 release-5.0.20 release-5.0.19 release-5.0.18 release-5.0.17 release-5.0.16 release-5.0.15 release-5.0.14 release-5.0.13 release-5.0.11 release-5.0.10 release-5.0.9 release-5.0.8 release-5.0.7 release-5.0.6 release-5.0.5 release-5.0.4 release-5.0.3 release-5.0.2 release-5.0.1 release-5.0.0.rc2 release-5.0.0.rc1 release-5.0.0.beta3 release-5.0.0.beta2 release-5.0.0.beta1 release-4.0.60 release-4.0.59 release-4.0.58 release-4.0.57 release-4.0.56 release-4.0.55 release-4.0.53 release-4.0.52 release-4.0.51 release-4.0.50 release-4.0.49 release-4.0.48 release-4.0.46 release-4.0.45 release-4.0.44 release-4.0.43 release-4.0.42 release-4.0.41 release-4.0.40 release-4.0.39 release-4.0.38 release-4.0.37 release-4.0.36 release-4.0.35 release-4.0.34 release-4.0.33 release-4.0.32 release-4.0.31 release-4.0.30 release-4.0.29 release-4.0.28 release-4.0.27 release-4.0.26 release-4.0.25 release-4.0.24 release-4.0.23 release-4.0.21 release-4.0.20 release-4.0.19 release-4.0.18 release-4.0.17 release-4.0.16 release-4.0.14 release-4.0.13 release-4.0.10 release-4.0.8
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 97 lines (88 sloc) 2.57 KB
#!/usr/bin/env ruby
# Phusion Passenger - http://www.modrails.com/
# Copyright (C) 2008 Phusion
#
# Phusion Passenger is a trademark of Hongli Lai & Ninh Bui.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
$LOAD_PATH << File.expand_path(File.dirname(__FILE__) + "/../lib")
$LOAD_PATH << File.expand_path(File.dirname(__FILE__) + "/../ext")
class StatusFifo
attr_accessor :filename
attr_accessor :pid
def initialize(filename, pid)
@filename = filename
@pid = pid
end
end
# Returns an array of all status FIFO files that are alive,
# and attempt to remove stale status FIFO files.
def list_and_clean_status_fifos
result = []
Dir["/tmp/passenger_status.*.fifo"].each do |filename|
filename =~ /(\d+).fifo$/
pid = $1.to_i
if process_is_alive?(pid)
result << StatusFifo.new(filename, pid)
else
puts "*** NOTICE: Removing stale status FIFO file #{filename}"
File.unlink(filename) rescue nil
end
end
return result
end
def process_is_alive?(pid)
begin
Process.kill(0, pid)
return true
rescue Errno::ESRCH
return false
rescue SystemCallError => e
return true
end
end
def show_status(status_fifo)
begin
puts File.read(status_fifo.filename)
rescue => e
STDERR.puts "*** ERROR: Cannot query status for Passenger instance #{status_fifo.pid}:"
STDERR.puts e.to_s
exit 2
end
end
def start
if ARGV.empty?
status_fifos = list_and_clean_status_fifos
if status_fifos.size == 0
STDERR.puts("ERROR: Phusion Passenger doesn't seem to be running.")
exit 2
elsif status_fifos.size == 1
show_status(status_fifos[0])
else
puts "It appears that multiple Passenger instances are running. Please select a"
puts "specific one by running:"
puts
puts " passenger-status <PID>"
puts
puts "The following Passenger instances are running:"
status_fifos.each do |status_fifo|
puts " PID: #{status_fifo.pid}"
end
exit 1
end
else
show_status(StatusFifo.new("/tmp/passenger_status.#{ARGV[0]}.fifo", ARGV[0].to_i))
end
end
start