Module: PhusionPassenger

Defined in:
lib/phusion_passenger.rb,
lib/phusion_passenger/utils.rb,
lib/phusion_passenger/plugin.rb,
lib/phusion_passenger/constants.rb,
lib/phusion_passenger/packaging.rb,
lib/phusion_passenger/exceptions.rb,
lib/phusion_passenger/public_api.rb,
lib/phusion_passenger/admin_tools.rb,
lib/phusion_passenger/app_process.rb,
lib/phusion_passenger/dependencies.rb,
lib/phusion_passenger/utils/tmpdir.rb,
lib/phusion_passenger/debug_logging.rb,
lib/phusion_passenger/html_template.rb,
lib/phusion_passenger/platform_info.rb,
lib/phusion_passenger/spawn_manager.rb,
lib/phusion_passenger/message_client.rb,
lib/phusion_passenger/native_support.rb,
lib/phusion_passenger/abstract_server.rb,
lib/phusion_passenger/message_channel.rb,
lib/phusion_passenger/standalone/main.rb,
lib/phusion_passenger/analytics_logger.rb,
lib/phusion_passenger/standalone/utils.rb,
lib/phusion_passenger/abstract_installer.rb,
lib/phusion_passenger/platform_info/curl.rb,
lib/phusion_passenger/platform_info/ruby.rb,
lib/phusion_passenger/platform_info/zlib.rb,
lib/phusion_passenger/standalone/command.rb,
lib/phusion_passenger/platform_info/linux.rb,
lib/phusion_passenger/platform_info/apache.rb,
lib/phusion_passenger/rack/request_handler.rb,
lib/phusion_passenger/console_text_template.rb,
lib/phusion_passenger/standalone/app_finder.rb,
lib/phusion_passenger/platform_info/compiler.rb,
lib/phusion_passenger/rails3_extensions/init.rb,
lib/phusion_passenger/standalone/config_file.rb,
lib/phusion_passenger/utils/rewindable_input.rb,
lib/phusion_passenger/classic_rails/cgi_fixed.rb,
lib/phusion_passenger/standalone/help_command.rb,
lib/phusion_passenger/standalone/stop_command.rb,
lib/phusion_passenger/utils/hosts_file_parser.rb,
lib/phusion_passenger/utils/unseekable_socket.rb,
lib/phusion_passenger/abstract_request_handler.rb,
lib/phusion_passenger/admin_tools/memory_stats.rb,
lib/phusion_passenger/rack/application_spawner.rb,
lib/phusion_passenger/standalone/start_command.rb,
lib/phusion_passenger/wsgi/application_spawner.rb,
lib/phusion_passenger/standalone/status_command.rb,
lib/phusion_passenger/utils/file_system_watcher.rb,
lib/phusion_passenger/abstract_server_collection.rb,
lib/phusion_passenger/standalone/version_command.rb,
lib/phusion_passenger/admin_tools/server_instance.rb,
lib/phusion_passenger/standalone/runtime_installer.rb,
lib/phusion_passenger/classic_rails/request_handler.rb,
lib/phusion_passenger/classic_rails_extensions/init.rb,
lib/phusion_passenger/classic_rails_extensions/init.rb,
lib/phusion_passenger/platform_info/operating_system.rb,
lib/phusion_passenger/classic_rails/framework_spawner.rb,
lib/phusion_passenger/classic_rails/application_spawner.rb,
lib/phusion_passenger/platform_info/documentation_tools.rb,
lib/phusion_passenger/platform_info/binary_compatibility.rb,
lib/phusion_passenger/standalone/package_runtime_command.rb,
lib/phusion_passenger/classic_rails_extensions/analytics_logging/ac_base_extension.rb,
lib/phusion_passenger/classic_rails_extensions/analytics_logging/as_cache_extension.rb,
lib/phusion_passenger/classic_rails_extensions/analytics_logging/ac_rescue_extension.rb,
lib/phusion_passenger/classic_rails_extensions/analytics_logging/ac_benchmarking_extension.rb,
lib/phusion_passenger/classic_rails_extensions/analytics_logging/ar_abstract_adapter_extension.rb,
lib/phusion_passenger/classic_rails_extensions/analytics_logging/av_benchmark_helper_extension.rb,
ext/ruby/passenger_native_support.c

Overview

Phusion Passenger - www.modrails.com/

Copyright (c) 2010 Phusion

"Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Defined Under Namespace

Modules: AdminTools, ClassicRails, ClassicRailsExtensions, DebugLogging, Dependencies, NativeSupport, Packaging, PlatformInfo, Rack, Rails3Extensions, Standalone, Utils, WSGI Classes: AbstractInstaller, AbstractRequestHandler, AbstractServer, AbstractServerCollection, AnalyticsLogger, AppInitError, AppProcess, ConsoleTextTemplate, Dependency, FrameworkInitError, HTMLTemplate, InitializationError, InvalidPath, MessageChannel, MessageClient, NativeSupportLoader, Plugin, SpawnManager, UnknownError, VersionNotFound

Constant Summary collapse

VERSION_STRING =

Phusion Passenger version number. Don’t forget to edit ext/common/Constants.h too.

'3.0.1'
PREFERRED_NGINX_VERSION =
'0.8.53'
PREFERRED_PCRE_VERSION =
'8.10'
STANDALONE_INTERFACE_VERSION =
1
NATIVELY_PACKAGED_SOURCE_ROOT =
"/usr/share/phusion-passenger/source"
NATIVELY_PACKAGED_DOCDIR =
"/usr/share/doc/phusion-passenger"
NATIVELY_PACKAGED_RESOURCES_DIR =
"/usr/share/phusion-passenger"
NATIVELY_PACKAGED_APACHE2_MODULE =
"/usr/lib/apache2/modules/mod_passenger.so"
LIBDIR =

Directory containing the Phusion Passenger Ruby libraries.

File.expand_path(File.dirname(__FILE__))
TEMPLATES_DIR =

Directory containing templates.

File.join(LIBDIR, "phusion_passenger", "templates")
LOCAL_DIR =

Subdirectory under $HOME to use for storing resource files.

".passenger"
PLUGIN_DIRS =

Directories in which to look for plugins.

["/usr/share/phusion-passenger/plugins",
"/usr/local/share/phusion-passenger/plugins",
"~/#{LOCAL_DIR}/plugins"]
LOCAL_STANDALONE_RESOURCE_DIR =

Directory under $HOME for storing Phusion Passenger Standalone resource files.

File.join(LOCAL_DIR, "standalone")
GLOBAL_STANDALONE_RESOURCE_DIR =

System-wide directory for storing Phusion Passenger Standalone resource files.

"/var/lib/passenger-standalone"
SOURCE_ROOT =

Top directory of the Phusion Passenger source code.

NATIVELY_PACKAGED_SOURCE_ROOT
DOCDIR =

Documentation directory.

NATIVELY_PACKAGED_DOCDIR
RESOURCES_DIR =

Directory containing Phusion Passenger resource files.

NATIVELY_PACKAGED_RESOURCES_DIR
APACHE2_MODULE =

Location of the Apache 2 module.

NATIVELY_PACKAGED_APACHE2_MODULE
NATIVE_SUPPORT_DIR =

Directory possibly containing #archdir/passenger_native_support.so. Not available when natively packaged.

File.join(SOURCE_ROOT, "ext", "ruby")
STANDALONE_BINARIES_URL_ROOT =

Other resource locations ######

"http://standalone-binaries.modrails.com"
DEFAULT_FRAMEWORK_SPAWNER_MAX_IDLE_TIME =
30 * 60
DEFAULT_APP_SPAWNER_MAX_IDLE_TIME =
10 * 60
ROOT_UID =
0
ROOT_GID =
0
PASSENGER_ANALYTICS_WEB_LOG =
"PASSENGER_ANALYTICS_WEB_LOG"
PASSENGER_TXN_ID =
"PASSENGER_TXN_ID"
PASSENGER_GROUP_NAME =
"PASSENGER_GROUP_NAME"
PASSENGER_UNION_STATION_KEY =
"PASSENGER_UNION_STATION_KEY"
@@event_starting_worker_process =
[]
@@event_stopping_worker_process =
[]
@@event_credentials =
[]
@@event_after_installing_signal_handlers =
[]

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

._spawn_optionsObject

Set during spawning, and set back to nil when spawning is done.



27
28
29
# File 'lib/phusion_passenger/public_api.rb', line 27

def _spawn_options
  @_spawn_options
end

Class Method Details

.benchmark(env = nil, title = "Benchmarking") ⇒ Object



52
53
54
55
56
57
58
59
60
61
# File 'lib/phusion_passenger/public_api.rb', line 52

def benchmark(env = nil, title = "Benchmarking")
	log = lookup_analytics_log(env)
	if log
		log.measure("BENCHMARK: #{title}") do
			yield
		end
	else
		yield
	end
end

.call_event(name, *args) ⇒ Object



38
39
40
41
42
# File 'lib/phusion_passenger/public_api.rb', line 38

def call_event(name, *args)
	callback_list_for_event(name).each do |callback|
		callback.call(*args)
	end
end

.install_framework_extensions!(*args) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/phusion_passenger/public_api.rb', line 44

def install_framework_extensions!(*args)
	require 'rails/version' if defined?(::Rails) && !defined?(::Rails::VERSION)
	if defined?(::Rails) && ::Rails::VERSION::MAJOR == 3
		require 'phusion_passenger/rails3_extensions/init'
		Rails3Extensions.init!(_spawn_options, *args)
	end
end

.log_cache_hit(env, name) ⇒ Object



63
64
65
66
67
68
69
70
71
# File 'lib/phusion_passenger/public_api.rb', line 63

def log_cache_hit(env, name)
	log = lookup_analytics_log(env)
	if log
		log.message("Cache hit: #{name}")
		return true
	else
		return false
	end
end

.log_cache_miss(env, name, generation_time = nil) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/phusion_passenger/public_api.rb', line 73

def log_cache_miss(env, name, generation_time = nil)
	log = lookup_analytics_log(env)
	if log
		if generation_time
			log.message("Cache miss (#{generation_time.to_i}): #{name}")
		else
			log.message("Cache miss: #{name}")
		end
		return true
	else
		return false
	end
end

.natively_packaged?Boolean

Returns whether this Phusion Passenger installation is packaged using the OS’s native package management system, i.e. as opposed to being installed from source or with RubyGems.

Returns:

  • (Boolean)


41
42
43
44
45
46
47
# File 'lib/phusion_passenger.rb', line 41

def self.natively_packaged?
	if !defined?(@natively_packaged)
		@natively_packaged = !File.exist?("#{LIBDIR}/../Rakefile") ||
		                     !File.exist?("#{LIBDIR}/../DEVELOPERS.TXT")
	end
	return @natively_packaged
end

.on_event(name, &block) ⇒ Object



34
35
36
# File 'lib/phusion_passenger/public_api.rb', line 34

def on_event(name, &block)
	callback_list_for_event(name) << block
end