passenger 2.0.6 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of passenger might be problematic. Click here for more details.
- data/DEVELOPERS.TXT +10 -4
- data/LICENSE +1 -1
- data/NEWS +0 -0
- data/Rakefile +183 -117
- data/benchmark/dispatcher.rb +5 -9
- data/bin/passenger-install-apache2-module +52 -18
- data/bin/passenger-memory-stats +67 -13
- data/bin/passenger-spawn-server +8 -4
- data/bin/passenger-status +21 -46
- data/bin/passenger-stress-test +5 -5
- data/debian/postinst +1 -1
- data/doc/ApplicationPool algorithm.txt +180 -128
- data/doc/Architectural overview.html +1 -778
- data/doc/Security of user switching support.html +1 -643
- data/doc/Users guide Apache.html +3127 -0
- data/doc/Users guide Nginx.html +1458 -0
- data/doc/Users guide.html +1404 -467
- data/doc/Users guide.txt +843 -105
- data/doc/cxxapi/ApplicationPoolServer_8h-source.html +751 -641
- data/doc/cxxapi/ApplicationPool_8h-source.html +168 -171
- data/doc/cxxapi/Application_8h-source.html +494 -394
- data/doc/cxxapi/Bucket_8h-source.html +21 -15
- data/doc/cxxapi/CachedFileStat_8h-source.html +191 -0
- data/doc/cxxapi/Configuration_8h-source.html +311 -149
- data/doc/cxxapi/DirectoryMapper_8h-source.html +309 -0
- data/doc/cxxapi/DummySpawnManager_8h-source.html +3 -4
- data/doc/cxxapi/Exceptions_8h-source.html +182 -165
- data/doc/cxxapi/FileChecker_8h-source.html +130 -0
- data/doc/cxxapi/Hooks_8h-source.html +2 -3
- data/doc/cxxapi/Logging_8h-source.html +92 -89
- data/doc/cxxapi/MessageChannel_8h-source.html +585 -477
- data/doc/cxxapi/PoolOptions_8h-source.html +305 -0
- data/doc/cxxapi/SpawnManager_8h-source.html +515 -540
- data/doc/cxxapi/StandardApplicationPool_8h-source.html +779 -679
- data/doc/cxxapi/SystemTime_8h-source.html +104 -0
- data/doc/cxxapi/Utils_8h-source.html +331 -227
- data/doc/cxxapi/annotated.html +6 -7
- data/doc/cxxapi/classClient-members.html +1 -2
- data/doc/cxxapi/classClient.html +1 -2
- data/doc/cxxapi/classHooks-members.html +5 -2
- data/doc/cxxapi/classHooks.html +112 -2
- data/doc/cxxapi/classPassenger_1_1Application-members.html +2 -3
- data/doc/cxxapi/classPassenger_1_1Application.html +8 -9
- data/doc/cxxapi/classPassenger_1_1ApplicationPool-members.html +4 -4
- data/doc/cxxapi/classPassenger_1_1ApplicationPool.html +42 -81
- data/doc/cxxapi/classPassenger_1_1ApplicationPoolServer-members.html +1 -2
- data/doc/cxxapi/classPassenger_1_1ApplicationPoolServer.html +3 -4
- data/doc/cxxapi/classPassenger_1_1ApplicationPool__inherit__graph.png +0 -0
- data/doc/cxxapi/classPassenger_1_1Application_1_1Session-members.html +3 -2
- data/doc/cxxapi/classPassenger_1_1Application_1_1Session.html +74 -3
- data/doc/cxxapi/classPassenger_1_1BusyException-members.html +1 -2
- data/doc/cxxapi/classPassenger_1_1BusyException.html +2 -3
- data/doc/cxxapi/classPassenger_1_1ConfigurationException-members.html +1 -2
- data/doc/cxxapi/classPassenger_1_1ConfigurationException.html +2 -3
- data/doc/cxxapi/classPassenger_1_1DirectoryMapper-members.html +38 -0
- data/doc/cxxapi/classPassenger_1_1DirectoryMapper.html +256 -0
- data/doc/cxxapi/classPassenger_1_1DummySpawnManager-members.html +1 -2
- data/doc/cxxapi/classPassenger_1_1DummySpawnManager.html +2 -3
- data/doc/cxxapi/{classPassenger_1_1Thread-members.html → classPassenger_1_1FileChecker-members.html} +4 -5
- data/doc/cxxapi/classPassenger_1_1FileChecker.html +121 -0
- data/doc/cxxapi/classPassenger_1_1FileNotFoundException-members.html +1 -2
- data/doc/cxxapi/classPassenger_1_1FileNotFoundException.html +2 -3
- data/doc/cxxapi/classPassenger_1_1FileNotFoundException__inherit__graph.png +0 -0
- data/doc/cxxapi/classPassenger_1_1FileSystemException-members.html +2 -3
- data/doc/cxxapi/classPassenger_1_1FileSystemException.html +2 -3
- data/doc/cxxapi/classPassenger_1_1FileSystemException__inherit__graph.png +0 -0
- data/doc/cxxapi/classPassenger_1_1IOException-members.html +1 -2
- data/doc/cxxapi/classPassenger_1_1IOException.html +2 -3
- data/doc/cxxapi/classPassenger_1_1IOException__inherit__graph.png +0 -0
- data/doc/cxxapi/classPassenger_1_1MessageChannel-members.html +5 -2
- data/doc/cxxapi/classPassenger_1_1MessageChannel.html +155 -5
- data/doc/cxxapi/{classboost_1_1this__thread_1_1enable__syscall__interruption-members.html → classPassenger_1_1RuntimeException-members.html} +2 -3
- data/doc/cxxapi/{classboost_1_1this__thread_1_1enable__syscall__interruption.html → classPassenger_1_1RuntimeException.html} +10 -8
- data/doc/cxxapi/classPassenger_1_1SpawnException-members.html +1 -2
- data/doc/cxxapi/classPassenger_1_1SpawnException.html +2 -3
- data/doc/cxxapi/classPassenger_1_1SpawnManager-members.html +2 -3
- data/doc/cxxapi/classPassenger_1_1SpawnManager.html +15 -56
- data/doc/cxxapi/classPassenger_1_1StandardApplicationPool-members.html +5 -4
- data/doc/cxxapi/classPassenger_1_1StandardApplicationPool.html +20 -81
- data/doc/cxxapi/classPassenger_1_1StandardApplicationPool__inherit__graph.png +0 -0
- data/doc/cxxapi/classPassenger_1_1SystemException-members.html +2 -3
- data/doc/cxxapi/classPassenger_1_1SystemException.html +9 -10
- data/doc/cxxapi/classPassenger_1_1SystemException__inherit__graph.png +0 -0
- data/doc/cxxapi/{classboost_1_1this__thread_1_1disable__syscall__interruption-members.html → classPassenger_1_1SystemTime-members.html} +5 -3
- data/doc/cxxapi/classPassenger_1_1SystemTime.html +86 -0
- data/doc/cxxapi/classPassenger_1_1TempFile-members.html +2 -3
- data/doc/cxxapi/classPassenger_1_1TempFile.html +17 -9
- data/doc/cxxapi/definitions_8h-source.html +1 -2
- data/doc/cxxapi/files.html +6 -3
- data/doc/cxxapi/functions.html +98 -35
- data/doc/cxxapi/functions_func.html +60 -32
- data/doc/cxxapi/functions_type.html +1 -2
- data/doc/cxxapi/functions_vars.html +27 -2
- data/doc/cxxapi/graph_legend.html +1 -2
- data/doc/cxxapi/graph_legend.png +0 -0
- data/doc/cxxapi/group__Configuration.html +3 -4
- data/doc/cxxapi/group__Configuration.png +0 -0
- data/doc/cxxapi/group__Core.html +3 -4
- data/doc/cxxapi/group__Core.png +0 -0
- data/doc/cxxapi/group__Exceptions.html +4 -2
- data/doc/cxxapi/group__Hooks.html +1 -6
- data/doc/cxxapi/group__Hooks.png +0 -0
- data/doc/cxxapi/group__Support.html +259 -36
- data/doc/cxxapi/hierarchy.html +6 -7
- data/doc/cxxapi/inherit__graph__0.map +1 -1
- data/doc/cxxapi/inherit__graph__0.md5 +1 -1
- data/doc/cxxapi/inherit__graph__0.png +0 -0
- data/doc/cxxapi/inherit__graph__1.map +1 -1
- data/doc/cxxapi/inherit__graph__1.md5 +1 -1
- data/doc/cxxapi/inherit__graph__1.png +0 -0
- data/doc/cxxapi/inherit__graph__10.map +1 -1
- data/doc/cxxapi/inherit__graph__10.md5 +1 -1
- data/doc/cxxapi/inherit__graph__10.png +0 -0
- data/doc/cxxapi/inherit__graph__11.map +1 -1
- data/doc/cxxapi/inherit__graph__11.md5 +1 -1
- data/doc/cxxapi/inherit__graph__11.png +0 -0
- data/doc/cxxapi/inherit__graph__12.map +2 -1
- data/doc/cxxapi/inherit__graph__12.md5 +1 -1
- data/doc/cxxapi/inherit__graph__12.png +0 -0
- data/doc/cxxapi/inherit__graph__13.map +1 -1
- data/doc/cxxapi/inherit__graph__13.md5 +1 -1
- data/doc/cxxapi/inherit__graph__13.png +0 -0
- data/doc/cxxapi/inherit__graph__14.map +1 -2
- data/doc/cxxapi/inherit__graph__14.md5 +1 -1
- data/doc/cxxapi/inherit__graph__14.png +0 -0
- data/doc/cxxapi/inherit__graph__15.map +1 -1
- data/doc/cxxapi/inherit__graph__15.md5 +1 -1
- data/doc/cxxapi/inherit__graph__15.png +0 -0
- data/doc/cxxapi/inherit__graph__16.map +1 -1
- data/doc/cxxapi/inherit__graph__16.md5 +1 -1
- data/doc/cxxapi/inherit__graph__16.png +0 -0
- data/doc/cxxapi/inherit__graph__17.png +0 -0
- data/doc/cxxapi/inherit__graph__18.png +0 -0
- data/doc/cxxapi/inherit__graph__19.png +0 -0
- data/doc/cxxapi/inherit__graph__2.map +1 -1
- data/doc/cxxapi/inherit__graph__2.md5 +1 -1
- data/doc/cxxapi/inherit__graph__2.png +0 -0
- data/doc/cxxapi/inherit__graph__20.map +1 -1
- data/doc/cxxapi/inherit__graph__20.md5 +1 -1
- data/doc/cxxapi/inherit__graph__20.png +0 -0
- data/doc/cxxapi/inherit__graph__21.map +1 -1
- data/doc/cxxapi/inherit__graph__21.md5 +1 -1
- data/doc/cxxapi/inherit__graph__21.png +0 -0
- data/doc/cxxapi/inherit__graph__3.map +1 -1
- data/doc/cxxapi/inherit__graph__3.md5 +1 -1
- data/doc/cxxapi/inherit__graph__3.png +0 -0
- data/doc/cxxapi/inherit__graph__4.map +1 -1
- data/doc/cxxapi/inherit__graph__4.md5 +1 -1
- data/doc/cxxapi/inherit__graph__4.png +0 -0
- data/doc/cxxapi/inherit__graph__5.map +2 -1
- data/doc/cxxapi/inherit__graph__5.md5 +1 -1
- data/doc/cxxapi/inherit__graph__5.png +0 -0
- data/doc/cxxapi/inherit__graph__6.map +1 -1
- data/doc/cxxapi/inherit__graph__6.md5 +1 -1
- data/doc/cxxapi/inherit__graph__6.png +0 -0
- data/doc/cxxapi/inherit__graph__7.map +1 -1
- data/doc/cxxapi/inherit__graph__7.md5 +1 -1
- data/doc/cxxapi/inherit__graph__7.png +0 -0
- data/doc/cxxapi/inherit__graph__8.map +1 -1
- data/doc/cxxapi/inherit__graph__8.md5 +1 -1
- data/doc/cxxapi/inherit__graph__8.png +0 -0
- data/doc/cxxapi/inherit__graph__9.map +1 -2
- data/doc/cxxapi/inherit__graph__9.md5 +1 -1
- data/doc/cxxapi/inherit__graph__9.png +0 -0
- data/doc/cxxapi/inherits.html +30 -31
- data/doc/cxxapi/main.html +1 -2
- data/doc/cxxapi/modules.html +1 -2
- data/doc/cxxapi/structPassenger_1_1AnythingToString-members.html +1 -2
- data/doc/cxxapi/structPassenger_1_1AnythingToString.html +2 -3
- data/doc/cxxapi/structPassenger_1_1AnythingToString_3_01vector_3_01string_01_4_01_4-members.html +1 -2
- data/doc/cxxapi/structPassenger_1_1AnythingToString_3_01vector_3_01string_01_4_01_4.html +2 -3
- data/doc/cxxapi/structPassenger_1_1PoolOptions-members.html +49 -0
- data/doc/cxxapi/structPassenger_1_1PoolOptions.html +404 -0
- data/doc/cxxapi/tree.html +18 -20
- data/doc/images/conservative_spawning.png +0 -0
- data/doc/images/conservative_spawning.svg +248 -0
- data/doc/images/smart-lv2.png +0 -0
- data/doc/images/smart-lv2.svg +320 -0
- data/doc/rdoc/classes/ConditionVariable.html +68 -34
- data/doc/rdoc/classes/Exception.html +16 -16
- data/doc/rdoc/classes/GC.html +9 -9
- data/doc/rdoc/classes/IO.html +36 -17
- data/doc/rdoc/classes/PhusionPassenger.html +183 -0
- data/doc/rdoc/classes/PhusionPassenger/AbstractRequestHandler.html +511 -0
- data/doc/rdoc/classes/{Passenger → PhusionPassenger}/AbstractServer.html +285 -242
- data/doc/rdoc/classes/{Passenger → PhusionPassenger}/AbstractServer/ServerAlreadyStarted.html +3 -3
- data/doc/rdoc/classes/{Passenger → PhusionPassenger}/AbstractServer/ServerError.html +3 -3
- data/doc/rdoc/classes/{Passenger → PhusionPassenger}/AbstractServer/ServerNotStarted.html +3 -3
- data/doc/rdoc/classes/{Passenger → PhusionPassenger}/AbstractServer/UnknownMessage.html +3 -3
- data/doc/rdoc/classes/PhusionPassenger/AbstractServerCollection.html +598 -0
- data/doc/rdoc/classes/PhusionPassenger/AdminTools.html +140 -0
- data/doc/rdoc/classes/PhusionPassenger/AdminTools/ControlProcess.html +247 -0
- data/doc/rdoc/classes/PhusionPassenger/AdminTools/ControlProcess/Instance.html +138 -0
- data/doc/rdoc/classes/{Passenger → PhusionPassenger}/AppInitError.html +36 -19
- data/doc/rdoc/classes/{Passenger → PhusionPassenger}/Application.html +81 -96
- data/doc/rdoc/classes/{Passenger → PhusionPassenger}/ConsoleTextTemplate.html +18 -18
- data/doc/rdoc/classes/{Passenger → PhusionPassenger}/FrameworkInitError.html +20 -18
- data/doc/rdoc/classes/{Passenger → PhusionPassenger}/HTMLTemplate.html +18 -18
- data/doc/rdoc/classes/{Passenger → PhusionPassenger}/InitializationError.html +9 -9
- data/doc/rdoc/classes/PhusionPassenger/InvalidPath.html +92 -0
- data/doc/rdoc/classes/{Passenger → PhusionPassenger}/MessageChannel.html +93 -92
- data/doc/rdoc/classes/{Passenger → PhusionPassenger}/NativeSupport.html +55 -25
- data/doc/rdoc/classes/PhusionPassenger/Rack.html +91 -0
- data/doc/rdoc/classes/PhusionPassenger/Rack/ApplicationSpawner.html +185 -0
- data/doc/rdoc/classes/PhusionPassenger/Rack/RequestHandler.html +182 -0
- data/doc/rdoc/classes/PhusionPassenger/Railz.html +95 -0
- data/doc/rdoc/classes/PhusionPassenger/Railz/ApplicationSpawner.html +424 -0
- data/doc/rdoc/classes/PhusionPassenger/Railz/ApplicationSpawner/Error.html +98 -0
- data/doc/rdoc/classes/PhusionPassenger/Railz/CGIFixed.html +200 -0
- data/doc/rdoc/classes/PhusionPassenger/Railz/FrameworkSpawner.html +444 -0
- data/doc/rdoc/classes/PhusionPassenger/Railz/FrameworkSpawner/Error.html +98 -0
- data/doc/rdoc/classes/PhusionPassenger/Railz/RequestHandler.html +154 -0
- data/doc/rdoc/classes/PhusionPassenger/SpawnManager.html +408 -0
- data/doc/rdoc/classes/{Passenger → PhusionPassenger}/UnknownError.html +13 -13
- data/doc/rdoc/classes/PhusionPassenger/Utils.html +687 -0
- data/doc/rdoc/classes/{Passenger → PhusionPassenger}/VersionNotFound.html +8 -8
- data/doc/rdoc/classes/PhusionPassenger/WSGI.html +89 -0
- data/doc/rdoc/classes/PhusionPassenger/WSGI/ApplicationSpawner.html +188 -0
- data/doc/rdoc/classes/PlatformInfo.html +663 -159
- data/doc/rdoc/classes/RakeExtensions.html +4 -4
- data/doc/rdoc/classes/Signal.html +134 -0
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/DEVELOPERS_TXT.html +15 -10
- data/doc/rdoc/files/README.html +5 -7
- data/doc/rdoc/files/ext/{passenger → phusion_passenger}/native_support_c.html +2 -2
- data/doc/rdoc/files/lib/{passenger → phusion_passenger}/abstract_request_handler_rb.html +7 -9
- data/doc/rdoc/files/lib/phusion_passenger/abstract_server_collection_rb.html +120 -0
- data/doc/rdoc/files/lib/{passenger → phusion_passenger}/abstract_server_rb.html +7 -10
- data/doc/rdoc/files/lib/phusion_passenger/admin_tools/control_process_rb.html +99 -0
- data/doc/rdoc/files/lib/phusion_passenger/admin_tools_rb.html +92 -0
- data/doc/rdoc/files/lib/{passenger → phusion_passenger}/application_rb.html +6 -8
- data/doc/rdoc/files/lib/{passenger → phusion_passenger}/console_text_template_rb.html +5 -7
- data/doc/rdoc/files/lib/{passenger → phusion_passenger}/constants_rb.html +4 -5
- data/doc/rdoc/files/lib/{passenger → phusion_passenger}/dependencies_rb.html +6 -8
- data/doc/rdoc/files/lib/phusion_passenger/events_rb.html +116 -0
- data/doc/rdoc/files/lib/{passenger → phusion_passenger}/exceptions_rb.html +5 -7
- data/doc/rdoc/files/lib/{passenger → phusion_passenger}/html_template_rb.html +5 -7
- data/doc/rdoc/files/lib/{passenger → phusion_passenger}/message_channel_rb.html +5 -7
- data/doc/rdoc/files/lib/{passenger → phusion_passenger}/platform_info_rb.html +6 -7
- data/doc/rdoc/files/lib/phusion_passenger/rack/application_spawner_rb.html +123 -0
- data/doc/rdoc/files/lib/phusion_passenger/rack/request_handler_rb.html +117 -0
- data/doc/rdoc/files/lib/{passenger/utils_rb.html → phusion_passenger/railz/application_spawner_rb.html} +24 -17
- data/doc/rdoc/files/lib/phusion_passenger/railz/cgi_fixed_rb.html +126 -0
- data/doc/rdoc/files/lib/phusion_passenger/railz/framework_spawner_rb.html +139 -0
- data/doc/rdoc/files/lib/phusion_passenger/railz/request_handler_rb.html +118 -0
- data/doc/rdoc/files/lib/{passenger → phusion_passenger}/simple_benchmarking_rb.html +5 -7
- data/doc/rdoc/files/lib/{passenger → phusion_passenger}/spawn_manager_rb.html +40 -24
- data/doc/rdoc/files/lib/phusion_passenger/utils_rb.html +169 -0
- data/doc/rdoc/files/lib/phusion_passenger/wsgi/application_spawner_rb.html +120 -0
- data/doc/rdoc/files/lib/rake/extensions_rb.html +3 -4
- data/doc/rdoc/fr_class_index.html +37 -19
- data/doc/rdoc/fr_file_index.html +25 -14
- data/doc/rdoc/fr_method_index.html +145 -74
- data/ext/apache2/Application.h +145 -44
- data/ext/apache2/ApplicationPool.h +27 -29
- data/ext/apache2/ApplicationPoolServer.h +183 -72
- data/ext/apache2/ApplicationPoolServerExecutable.cpp +249 -42
- data/ext/apache2/Bucket.cpp +61 -9
- data/ext/apache2/Bucket.h +15 -8
- data/ext/apache2/CachedFileStat.cpp +114 -0
- data/ext/apache2/CachedFileStat.h +169 -0
- data/ext/apache2/Configuration.cpp +213 -22
- data/ext/apache2/Configuration.h +176 -13
- data/ext/apache2/DirectoryMapper.h +287 -0
- data/ext/apache2/Exceptions.h +30 -12
- data/ext/apache2/FileChecker.h +108 -0
- data/ext/apache2/Hooks.cpp +709 -493
- data/ext/apache2/LICENSE-CNRI.TXT +15 -0
- data/ext/apache2/Logging.h +26 -22
- data/ext/apache2/MessageChannel.h +124 -15
- data/ext/apache2/PoolOptions.h +283 -0
- data/ext/apache2/SpawnManager.h +75 -99
- data/ext/apache2/StandardApplicationPool.h +296 -195
- data/ext/apache2/SystemTime.cpp +28 -0
- data/ext/apache2/SystemTime.h +82 -0
- data/ext/apache2/Utils.cpp +172 -18
- data/ext/apache2/Utils.h +124 -19
- data/ext/boost/cstdint.hpp +4 -2
- data/ext/boost/current_function.hpp +67 -0
- data/ext/boost/detail/sp_counted_base.hpp +4 -4
- data/ext/boost/thread/exceptions.hpp +2 -1
- data/ext/boost/thread/pthread/thread.hpp +11 -3
- data/ext/boost/thread/pthread/thread_data.hpp +2 -1
- data/ext/oxt/backtrace.cpp +172 -0
- data/ext/oxt/backtrace.hpp +135 -0
- data/ext/oxt/detail/backtrace_disabled.hpp +39 -0
- data/ext/oxt/detail/backtrace_enabled.hpp +155 -0
- data/ext/oxt/detail/spin_lock_gcc_x86.hpp +82 -0
- data/ext/oxt/detail/spin_lock_portable.hpp +38 -0
- data/ext/oxt/detail/spin_lock_pthreads.hpp +97 -0
- data/ext/oxt/detail/tracable_exception_disabled.hpp +46 -0
- data/ext/oxt/detail/tracable_exception_enabled.hpp +48 -0
- data/ext/oxt/macros.hpp +58 -0
- data/ext/oxt/spin_lock.hpp +55 -0
- data/ext/{apache2/System.cpp → oxt/system_calls.cpp} +87 -52
- data/ext/oxt/system_calls.hpp +234 -0
- data/ext/oxt/thread.cpp +32 -0
- data/ext/oxt/thread.hpp +223 -0
- data/ext/oxt/tracable_exception.cpp +87 -0
- data/ext/oxt/tracable_exception.hpp +35 -0
- data/{lib/passenger/constants.rb → ext/phusion_passenger/extconf.rb} +14 -9
- data/ext/{passenger → phusion_passenger}/native_support.c +33 -6
- data/lib/{passenger → phusion_passenger}/abstract_request_handler.rb +209 -93
- data/lib/{passenger → phusion_passenger}/abstract_server.rb +23 -8
- data/lib/phusion_passenger/abstract_server_collection.rb +301 -0
- data/lib/phusion_passenger/admin_tools.rb +25 -0
- data/lib/phusion_passenger/admin_tools/control_process.rb +107 -0
- data/lib/{passenger → phusion_passenger}/application.rb +13 -16
- data/lib/{passenger → phusion_passenger}/console_text_template.rb +2 -2
- data/{ext/passenger/extconf.rb → lib/phusion_passenger/constants.rb} +5 -5
- data/lib/{passenger → phusion_passenger}/dependencies.rb +38 -32
- data/lib/phusion_passenger/events.rb +45 -0
- data/lib/{passenger → phusion_passenger}/exceptions.rb +12 -5
- data/lib/{passenger → phusion_passenger}/html_template.rb +2 -2
- data/lib/{passenger → phusion_passenger}/message_channel.rb +3 -2
- data/lib/phusion_passenger/platform_info.rb +500 -0
- data/lib/{passenger → phusion_passenger}/rack/application_spawner.rb +29 -22
- data/lib/{passenger → phusion_passenger}/rack/request_handler.rb +14 -9
- data/lib/{passenger → phusion_passenger}/railz/application_spawner.rb +94 -74
- data/lib/{passenger → phusion_passenger}/railz/cgi_fixed.rb +2 -2
- data/lib/{passenger → phusion_passenger}/railz/framework_spawner.rb +86 -98
- data/lib/{passenger → phusion_passenger}/railz/request_handler.rb +6 -6
- data/lib/{passenger → phusion_passenger}/simple_benchmarking.rb +0 -0
- data/lib/{passenger → phusion_passenger}/spawn_manager.rb +136 -128
- data/lib/{passenger → phusion_passenger}/templates/apache2_config_snippets.txt.erb +0 -0
- data/lib/{passenger → phusion_passenger}/templates/apache_must_be_compiled_with_compatible_mpm.txt.erb +0 -0
- data/lib/phusion_passenger/templates/app_exited_during_initialization.html.erb +38 -0
- data/lib/{passenger → phusion_passenger}/templates/app_init_error.html.erb +0 -0
- data/lib/{passenger → phusion_passenger}/templates/database_error.html.erb +0 -0
- data/lib/{passenger → phusion_passenger}/templates/deployment_example.txt.erb +1 -1
- data/lib/{passenger → phusion_passenger}/templates/error_layout.css +0 -0
- data/lib/{passenger → phusion_passenger}/templates/error_layout.html.erb +0 -0
- data/lib/{passenger → phusion_passenger}/templates/framework_init_error.html.erb +0 -0
- data/lib/{passenger → phusion_passenger}/templates/general_error.html.erb +0 -0
- data/lib/{passenger → phusion_passenger}/templates/invalid_app_root.html.erb +1 -1
- data/lib/{passenger → phusion_passenger}/templates/load_error.html.erb +0 -0
- data/lib/{passenger → phusion_passenger}/templates/no_write_permission_to_passenger_root.txt.erb +0 -0
- data/lib/{passenger → phusion_passenger}/templates/possible_solutions_for_compilation_and_installation_problems.txt.erb +0 -0
- data/lib/{passenger → phusion_passenger}/templates/run_installer_as_root.txt.erb +0 -0
- data/lib/{passenger → phusion_passenger}/templates/version_not_found.html.erb +0 -0
- data/lib/{passenger → phusion_passenger}/templates/welcome.txt.erb +0 -0
- data/lib/{passenger → phusion_passenger}/utils.rb +210 -44
- data/lib/{passenger → phusion_passenger}/wsgi/application_spawner.rb +18 -15
- data/lib/{passenger → phusion_passenger}/wsgi/request_handler.py +7 -1
- data/man/passenger-memory-stats.8 +1 -1
- data/misc/render_error_pages.rb +1 -1
- data/test/ApplicationPoolServerTest.cpp +0 -28
- data/test/ApplicationPoolServer_ApplicationPoolTest.cpp +4 -0
- data/test/ApplicationPoolTest.cpp +307 -69
- data/test/CachedFileStatTest.cpp +262 -0
- data/test/FileCheckerTest.cpp +79 -0
- data/test/MessageChannelTest.cpp +3 -3
- data/test/PoolOptionsTest.cpp +37 -0
- data/test/SpawnManagerTest.cpp +4 -4
- data/test/StandardApplicationPoolTest.cpp +4 -0
- data/test/SystemTimeTest.cpp +37 -0
- data/test/UtilsTest.cpp +137 -0
- data/test/integration_tests.rb +270 -23
- data/test/oxt/backtrace_test.cpp +128 -0
- data/test/oxt/oxt_test_main.cpp +25 -0
- data/test/oxt/syscall_interruption_test.cpp +50 -0
- data/test/ruby/abstract_request_handler_spec.rb +83 -0
- data/test/ruby/abstract_server_collection_spec.rb +246 -0
- data/test/ruby/application_spec.rb +3 -3
- data/test/ruby/message_channel_spec.rb +2 -2
- data/test/ruby/rack/application_spawner_spec.rb +3 -5
- data/test/ruby/rails/application_spawner_spec.rb +54 -15
- data/test/ruby/rails/framework_spawner_spec.rb +6 -8
- data/test/ruby/rails/minimal_spawner_spec.rb +29 -0
- data/test/ruby/rails/spawner_error_handling_spec.rb +1 -1
- data/test/ruby/rails/spawner_privilege_lowering_spec.rb +3 -3
- data/test/ruby/spawn_manager_spec.rb +23 -12
- data/test/ruby/utils_spec.rb +36 -2
- data/test/ruby/wsgi/application_spawner_spec.rb +47 -0
- data/test/stub/apache2/httpd.conf.erb +3 -5
- data/test/stub/message_channel.rb +2 -2
- data/test/stub/message_channel_2.rb +2 -2
- data/test/stub/message_channel_3.rb +3 -3
- data/test/stub/minimal-railsapp/README +0 -0
- data/test/stub/minimal-railsapp/config/application.rb +0 -0
- data/test/stub/minimal-railsapp/config/environment.rb +0 -0
- data/test/stub/minimal-railsapp/vendor/rails/actionmailer/lib/action_mailer.rb +0 -0
- data/test/stub/minimal-railsapp/vendor/rails/actionpack/lib/action_controller.rb +0 -0
- data/test/stub/minimal-railsapp/vendor/rails/actionpack/lib/action_pack.rb +0 -0
- data/test/stub/minimal-railsapp/vendor/rails/actionpack/lib/action_view.rb +0 -0
- data/test/stub/minimal-railsapp/vendor/rails/activerecord/lib/active_record.rb +0 -0
- data/test/stub/minimal-railsapp/vendor/rails/activeresource/lib/active_resource.rb +0 -0
- data/test/stub/minimal-railsapp/vendor/rails/activesupport/lib/active_support.rb +0 -0
- data/test/stub/minimal-railsapp/vendor/rails/activesupport/lib/active_support/whiny_nil.rb +0 -0
- data/test/stub/minimal-railsapp/vendor/rails/railties/lib/dispatcher.rb +0 -0
- data/test/stub/minimal-railsapp/vendor/rails/railties/lib/initializer.rb +0 -0
- data/test/stub/minimal-railsapp/vendor/rails/railties/lib/ruby_version_check.rb +0 -0
- data/test/stub/rails_apps/foobar/app/controllers/foo_controller.rb +8 -0
- data/test/stub/rails_apps/foobar/config/environments/development.rb +1 -2
- data/test/stub/rails_apps/mycook/app/controllers/welcome_controller.rb +21 -1
- data/test/stub/rails_apps/mycook/sites/some.site/public/uploads.html +26 -0
- data/test/stub/rails_apps/mycook/sites/some.site/public/welcome/cached.html +26 -0
- data/test/stub/railsapp/app/controllers/application.rb +0 -0
- data/test/stub/railsapp/app/controllers/bar_controller_1.rb +0 -0
- data/test/stub/railsapp/app/controllers/bar_controller_2.rb +1 -1
- data/test/stub/railsapp/app/controllers/foo_controller.rb +4 -0
- data/test/stub/railsapp/app/helpers/application_helper.rb +0 -0
- data/test/stub/railsapp/config/boot.rb +0 -0
- data/test/stub/railsapp/config/database.yml +0 -0
- data/test/stub/railsapp/config/environment.rb +0 -0
- data/test/stub/railsapp/config/environments/development.rb +0 -0
- data/test/stub/railsapp/config/environments/production.rb +0 -0
- data/test/stub/railsapp/config/initializers/inflections.rb +0 -0
- data/test/stub/railsapp/config/initializers/mime_types.rb +0 -0
- data/test/stub/railsapp/config/routes.rb +0 -0
- data/test/stub/railsapp/public/useless.txt +0 -0
- data/test/stub/spawn_server.rb +3 -4
- data/test/stub/wsgi/passenger_wsgi.pyc +0 -0
- data/test/support/apache2_controller.rb +57 -7
- data/test/support/tut.h +15 -0
- data/vendor/README +12 -0
- data/vendor/README_FOR_PACKAGERS +1 -0
- data/vendor/rack-0.9.1/AUTHORS +8 -0
- data/vendor/rack-0.9.1/COPYING +18 -0
- data/vendor/rack-0.9.1/ChangeLog +1423 -0
- data/vendor/rack-0.9.1/KNOWN-ISSUES +18 -0
- data/vendor/rack-0.9.1/README +306 -0
- data/vendor/rack-0.9.1/Rakefile +188 -0
- data/vendor/rack-0.9.1/SPEC +129 -0
- data/vendor/rack-0.9.1/lib/rack.rb +86 -0
- data/vendor/rack-0.9.1/lib/rack/adapter/camping.rb +22 -0
- data/vendor/rack-0.9.1/lib/rack/auth/abstract/handler.rb +28 -0
- data/vendor/rack-0.9.1/lib/rack/auth/abstract/request.rb +37 -0
- data/vendor/rack-0.9.1/lib/rack/auth/basic.rb +58 -0
- data/vendor/rack-0.9.1/lib/rack/auth/digest/md5.rb +124 -0
- data/vendor/rack-0.9.1/lib/rack/auth/digest/nonce.rb +51 -0
- data/vendor/rack-0.9.1/lib/rack/auth/digest/params.rb +55 -0
- data/vendor/rack-0.9.1/lib/rack/auth/digest/request.rb +40 -0
- data/vendor/rack-0.9.1/lib/rack/auth/openid.rb +438 -0
- data/vendor/rack-0.9.1/lib/rack/builder.rb +67 -0
- data/vendor/rack-0.9.1/lib/rack/cascade.rb +36 -0
- data/vendor/rack-0.9.1/lib/rack/commonlogger.rb +61 -0
- data/vendor/rack-0.9.1/lib/rack/conditionalget.rb +43 -0
- data/vendor/rack-0.9.1/lib/rack/content_length.rb +25 -0
- data/vendor/rack-0.9.1/lib/rack/deflater.rb +87 -0
- data/vendor/rack-0.9.1/lib/rack/directory.rb +150 -0
- data/vendor/rack-0.9.1/lib/rack/file.rb +85 -0
- data/vendor/rack-0.9.1/lib/rack/handler.rb +48 -0
- data/vendor/rack-0.9.1/lib/rack/handler/cgi.rb +57 -0
- data/vendor/rack-0.9.1/lib/rack/handler/evented_mongrel.rb +8 -0
- data/vendor/rack-0.9.1/lib/rack/handler/fastcgi.rb +86 -0
- data/vendor/rack-0.9.1/lib/rack/handler/lsws.rb +52 -0
- data/vendor/rack-0.9.1/lib/rack/handler/mongrel.rb +82 -0
- data/vendor/rack-0.9.1/lib/rack/handler/scgi.rb +57 -0
- data/vendor/rack-0.9.1/lib/rack/handler/swiftiplied_mongrel.rb +8 -0
- data/vendor/rack-0.9.1/lib/rack/handler/thin.rb +15 -0
- data/vendor/rack-0.9.1/lib/rack/handler/webrick.rb +61 -0
- data/vendor/rack-0.9.1/lib/rack/head.rb +19 -0
- data/vendor/rack-0.9.1/lib/rack/lint.rb +465 -0
- data/vendor/rack-0.9.1/lib/rack/lobster.rb +65 -0
- data/vendor/rack-0.9.1/lib/rack/methodoverride.rb +27 -0
- data/vendor/rack-0.9.1/lib/rack/mime.rb +204 -0
- data/vendor/rack-0.9.1/lib/rack/mock.rb +160 -0
- data/vendor/rack-0.9.1/lib/rack/recursive.rb +57 -0
- data/vendor/rack-0.9.1/lib/rack/reloader.rb +64 -0
- data/vendor/rack-0.9.1/lib/rack/request.rb +218 -0
- data/vendor/rack-0.9.1/lib/rack/response.rb +171 -0
- data/vendor/rack-0.9.1/lib/rack/session/abstract/id.rb +153 -0
- data/vendor/rack-0.9.1/lib/rack/session/cookie.rb +89 -0
- data/vendor/rack-0.9.1/lib/rack/session/memcache.rb +97 -0
- data/vendor/rack-0.9.1/lib/rack/session/pool.rb +73 -0
- data/vendor/rack-0.9.1/lib/rack/showexceptions.rb +348 -0
- data/vendor/rack-0.9.1/lib/rack/showstatus.rb +106 -0
- data/vendor/rack-0.9.1/lib/rack/static.rb +38 -0
- data/vendor/rack-0.9.1/lib/rack/urlmap.rb +48 -0
- data/vendor/rack-0.9.1/lib/rack/utils.rb +347 -0
- metadata +1197 -1055
- data/doc/cxxapi/System_8h-source.html +0 -251
- data/doc/cxxapi/classDirectoryMapper-members.html +0 -38
- data/doc/cxxapi/classDirectoryMapper.html +0 -203
- data/doc/cxxapi/classPassenger_1_1Thread.html +0 -100
- data/doc/cxxapi/classboost_1_1this__thread_1_1disable__syscall__interruption.html +0 -46
- data/doc/cxxapi/classboost_1_1this__thread_1_1restore__syscall__interruption-members.html +0 -33
- data/doc/cxxapi/classboost_1_1this__thread_1_1restore__syscall__interruption.html +0 -44
- data/doc/cxxapi/namespacePassenger.html +0 -208
- data/doc/cxxapi/namespacePassenger_1_1InterruptableCalls.html +0 -43
- data/doc/cxxapi/namespacemembers.html +0 -70
- data/doc/cxxapi/namespacemembers_func.html +0 -66
- data/doc/cxxapi/namespacemembers_type.html +0 -46
- data/doc/cxxapi/namespaces.html +0 -35
- data/doc/rdoc/classes/Passenger.html +0 -136
- data/doc/rdoc/classes/Passenger/AbstractRequestHandler.html +0 -402
- data/doc/rdoc/classes/Passenger/SpawnManager.html +0 -379
- data/doc/rdoc/classes/Passenger/Utils.html +0 -578
- data/ext/apache2/System.h +0 -228
- data/lib/passenger/platform_info.rb +0 -302
- data/lib/passenger/templates/app_exited_during_initialization.html.erb +0 -19
- data/test/stub/apache2/httpd.conf +0 -75
- data/test/stub/rails_apps/foobar/config/environments/test.rb +0 -22
- data/test/stub/rails_apps/mycook/config/environments/test.rb +0 -22
- data/test/stub/railsapp/config/environments/test.rb +0 -22
- data/test/stub/railsapp2/config/environments/test.rb +0 -22
data/doc/Users guide.html
CHANGED
@@ -3,7 +3,8 @@
|
|
3
3
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
4
4
|
<head>
|
5
5
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
6
|
-
<meta name="generator" content="AsciiDoc 8.
|
6
|
+
<meta name="generator" content="AsciiDoc 8.3.4" />
|
7
|
+
<title>Phusion Passenger users guide</title>
|
7
8
|
<style type="text/css">
|
8
9
|
/* Debug borders */
|
9
10
|
p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
|
@@ -110,7 +111,10 @@ div#footer-badges {
|
|
110
111
|
padding-bottom: 0.5em;
|
111
112
|
}
|
112
113
|
|
113
|
-
div#preamble
|
114
|
+
div#preamble {
|
115
|
+
margin-top: 1.5em;
|
116
|
+
margin-bottom: 1.5em;
|
117
|
+
}
|
114
118
|
div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
|
115
119
|
div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
|
116
120
|
div.admonitionblock {
|
@@ -218,6 +222,7 @@ dt {
|
|
218
222
|
margin-top: 0.5em;
|
219
223
|
margin-bottom: 0;
|
220
224
|
font-style: normal;
|
225
|
+
color: navy;
|
221
226
|
}
|
222
227
|
dd > *:first-child {
|
223
228
|
margin-top: 0.1em;
|
@@ -226,12 +231,28 @@ dd > *:first-child {
|
|
226
231
|
ul, ol {
|
227
232
|
list-style-position: outside;
|
228
233
|
}
|
229
|
-
|
234
|
+
ol.arabic {
|
230
235
|
list-style-type: decimal;
|
231
236
|
}
|
232
|
-
|
237
|
+
ol.loweralpha {
|
233
238
|
list-style-type: lower-alpha;
|
234
239
|
}
|
240
|
+
ol.upperalpha {
|
241
|
+
list-style-type: upper-alpha;
|
242
|
+
}
|
243
|
+
ol.lowerroman {
|
244
|
+
list-style-type: lower-roman;
|
245
|
+
}
|
246
|
+
ol.upperroman {
|
247
|
+
list-style-type: upper-roman;
|
248
|
+
}
|
249
|
+
|
250
|
+
div.compact ul, div.compact ol,
|
251
|
+
div.compact p, div.compact p,
|
252
|
+
div.compact div, div.compact div {
|
253
|
+
margin-top: 0.1em;
|
254
|
+
margin-bottom: 0.1em;
|
255
|
+
}
|
235
256
|
|
236
257
|
div.tableblock > table {
|
237
258
|
border: 3px solid #527bbd;
|
@@ -243,22 +264,53 @@ thead {
|
|
243
264
|
tfoot {
|
244
265
|
font-weight: bold;
|
245
266
|
}
|
267
|
+
td > div.verse {
|
268
|
+
white-space: pre;
|
269
|
+
}
|
270
|
+
p.table {
|
271
|
+
margin-top: 0;
|
272
|
+
}
|
273
|
+
/* Because the table frame attribute is overriden by CSS in most browsers. */
|
274
|
+
div.tableblock > table[frame="void"] {
|
275
|
+
border-style: none;
|
276
|
+
}
|
277
|
+
div.tableblock > table[frame="hsides"] {
|
278
|
+
border-left-style: none;
|
279
|
+
border-right-style: none;
|
280
|
+
}
|
281
|
+
div.tableblock > table[frame="vsides"] {
|
282
|
+
border-top-style: none;
|
283
|
+
border-bottom-style: none;
|
284
|
+
}
|
285
|
+
|
246
286
|
|
247
|
-
div.
|
287
|
+
div.hdlist {
|
248
288
|
margin-top: 0.8em;
|
249
289
|
margin-bottom: 0.8em;
|
250
290
|
}
|
251
|
-
div.
|
291
|
+
div.hdlist tr {
|
252
292
|
padding-bottom: 15px;
|
253
293
|
}
|
254
|
-
td.
|
294
|
+
dt.hdlist1.strong, td.hdlist1.strong {
|
295
|
+
font-weight: bold;
|
296
|
+
}
|
297
|
+
td.hdlist1 {
|
255
298
|
vertical-align: top;
|
256
299
|
font-style: normal;
|
257
300
|
padding-right: 0.8em;
|
301
|
+
color: navy;
|
258
302
|
}
|
259
|
-
td.
|
303
|
+
td.hdlist2 {
|
260
304
|
vertical-align: top;
|
261
305
|
}
|
306
|
+
div.hdlist.compact tr {
|
307
|
+
margin: 0;
|
308
|
+
padding-bottom: 0;
|
309
|
+
}
|
310
|
+
|
311
|
+
.comment {
|
312
|
+
background: yellow;
|
313
|
+
}
|
262
314
|
|
263
315
|
@media print {
|
264
316
|
div#footer-badges { display: none; }
|
@@ -330,14 +382,6 @@ div.exampleblock-content {
|
|
330
382
|
|
331
383
|
/* IE6 sets dynamically generated links as visited. */
|
332
384
|
div#toc a:visited { color: blue; }
|
333
|
-
|
334
|
-
/* Because IE6 child selector is broken. */
|
335
|
-
div.olist2 ol {
|
336
|
-
list-style-type: lower-alpha;
|
337
|
-
}
|
338
|
-
div.olist2 div.olist ol {
|
339
|
-
list-style-type: decimal;
|
340
|
-
}
|
341
385
|
</style>
|
342
386
|
<script type="text/javascript">
|
343
387
|
/*<![CDATA[*/
|
@@ -413,7 +457,6 @@ function generateToc(toclevels) {
|
|
413
457
|
}
|
414
458
|
/*]]>*/
|
415
459
|
</script>
|
416
|
-
<title>Phusion Passenger users guide</title>
|
417
460
|
</head>
|
418
461
|
<body>
|
419
462
|
<div id="header">
|
@@ -425,17 +468,17 @@ function generateToc(toclevels) {
|
|
425
468
|
</div>
|
426
469
|
<div id="preamble">
|
427
470
|
<div class="sectionbody">
|
428
|
-
<div class="
|
471
|
+
<div class="paragraph"><p><span class="image">
|
429
472
|
<a class="image" href="http://www.phusion.nl/">
|
430
473
|
<img src="images/phusion_banner.png" alt="images/phusion_banner.png" />
|
431
474
|
</a>
|
432
475
|
</span></p></div>
|
433
|
-
<div class="
|
476
|
+
<div class="paragraph"><p>Phusion Passenger is an Apache module, which makes deploying Ruby and Ruby on
|
434
477
|
Rails applications on Apache a breeze. It follows the usual Ruby on Rails
|
435
|
-
conventions, such as "Don
|
478
|
+
conventions, such as "Don’t-Repeat-Yourself" and ease of setup, while at the
|
436
479
|
same time providing enough flexibility.</p></div>
|
437
|
-
<div class="
|
438
|
-
<div class="
|
480
|
+
<div class="paragraph"><p>This users guide will teach you:</p></div>
|
481
|
+
<div class="ulist"><ul>
|
439
482
|
<li>
|
440
483
|
<p>
|
441
484
|
How to install Phusion Passenger.
|
@@ -462,16 +505,16 @@ How to solve common problems.
|
|
462
505
|
</p>
|
463
506
|
</li>
|
464
507
|
</ul></div>
|
465
|
-
<div class="
|
508
|
+
<div class="paragraph"><p>This guide assumes that the reader is somewhat familiar with Apache and with
|
466
509
|
using the commandline.</p></div>
|
467
510
|
</div>
|
468
511
|
</div>
|
469
512
|
<h2 id="_supported_operating_systems">1. Supported operating systems</h2>
|
470
513
|
<div class="sectionbody">
|
471
|
-
<div class="
|
514
|
+
<div class="paragraph"><p>Phusion Passenger works on any POSIX-compliant operating system. In other
|
472
515
|
words: practically any operating system on earth, except Microsoft Windows.</p></div>
|
473
|
-
<div class="
|
474
|
-
<div class="
|
516
|
+
<div class="paragraph"><p>Phusion Passenger has been tested on:</p></div>
|
517
|
+
<div class="ulist"><ul>
|
475
518
|
<li>
|
476
519
|
<p>
|
477
520
|
Ubuntu Linux 6.06 (x86)
|
@@ -484,6 +527,11 @@ Ubuntu Linux 7.10 (x86)
|
|
484
527
|
</li>
|
485
528
|
<li>
|
486
529
|
<p>
|
530
|
+
Ubuntu Linux 8.04 (x86)
|
531
|
+
</p>
|
532
|
+
</li>
|
533
|
+
<li>
|
534
|
+
<p>
|
487
535
|
Debian Sarge (x86)
|
488
536
|
</p>
|
489
537
|
</li>
|
@@ -528,19 +576,19 @@ MacOS X Leopard (x86)
|
|
528
576
|
</p>
|
529
577
|
</li>
|
530
578
|
</ul></div>
|
531
|
-
<div class="
|
579
|
+
<div class="paragraph"><p>Other operating systems have not been tested, but Phusion Passenger will probably
|
532
580
|
work fine on them. Please
|
533
581
|
<a href="http://code.google.com/p/phusion-passenger/issues/list">report a bug</a>
|
534
582
|
or
|
535
583
|
<a href="http://groups.google.com/group/phusion-passenger">join our discussion list</a>
|
536
|
-
if it doesn
|
584
|
+
if it doesn’t.</p></div>
|
537
585
|
</div>
|
538
586
|
<h2 id="_installing_phusion_passenger">2. Installing Phusion Passenger</h2>
|
539
587
|
<div class="sectionbody">
|
540
588
|
<h3 id="_generic_installation_instructions">2.1. Generic installation instructions</h3><div style="clear:left"></div>
|
541
589
|
<h4 id="install_passenger">2.1.1. Overview of download and installation methods</h4>
|
542
|
-
<div class="
|
543
|
-
<div class="olist"><ol>
|
590
|
+
<div class="paragraph"><p>There are two ways to install Phusion Passenger:</p></div>
|
591
|
+
<div class="olist arabic"><ol class="arabic">
|
544
592
|
<li>
|
545
593
|
<p>
|
546
594
|
By installing the Phusion Passenger gem, as instructed on the
|
@@ -561,8 +609,8 @@ By downloading the source tarball from the Phusion Passenger website
|
|
561
609
|
</p>
|
562
610
|
</li>
|
563
611
|
</ol></div>
|
564
|
-
<div class="
|
565
|
-
<div class="
|
612
|
+
<div class="paragraph"><p>In our opinion, installing the gem or the native package is easiest.</p></div>
|
613
|
+
<div class="paragraph"><p>Phusion Passenger provides an easy-to-use installer for installing the Phusion
|
566
614
|
Passenger Apache module (<em>mod_passenger</em>).</p></div>
|
567
615
|
<div class="admonitionblock">
|
568
616
|
<table><tr>
|
@@ -580,16 +628,16 @@ you.</td>
|
|
580
628
|
<td class="icon">
|
581
629
|
<img src="./images/icons/note.png" alt="Note" />
|
582
630
|
</td>
|
583
|
-
<td class="content">You can skip this section if you
|
631
|
+
<td class="content">You can skip this section if you’ve installed Phusion Passenger via a
|
584
632
|
native Linux package, because no compilation is necessary.</td>
|
585
633
|
</tr></table>
|
586
634
|
</div>
|
587
|
-
<div class="
|
635
|
+
<div class="paragraph"><p>If your system has multiple Apache installations (this is likely the case on
|
588
636
|
MacOS X), then you will need to tell the Phusion Passenger installer which one
|
589
637
|
to use. If you only have one Apache installation (the case on most Linux
|
590
638
|
systems), then you can skip this section because Phusion Passenger will
|
591
639
|
automatically detect it.</p></div>
|
592
|
-
<div class="
|
640
|
+
<div class="paragraph"><p>Every Apache installation has its own <tt>apxs</tt> program. You will need to tell
|
593
641
|
Phusion Passenger the location of this program, by specifying the <tt>APXS2</tt>
|
594
642
|
environment variable. Suppose that you want to use the Apache installation in
|
595
643
|
<em>/opt/apache2</em>. Then, assuming that the corresponding <tt>apxs</tt> program is located
|
@@ -613,18 +661,18 @@ be located in the <tt>sbin</tt> folder instead of the <tt>bin</tt> folder.</td>
|
|
613
661
|
<td class="icon">
|
614
662
|
<img src="./images/icons/note.png" alt="Note" />
|
615
663
|
</td>
|
616
|
-
<td class="content">You can skip this section if you
|
664
|
+
<td class="content">You can skip this section if you’ve installed Phusion Passenger via a
|
617
665
|
native Linux package, because no compilation is necessary.</td>
|
618
666
|
</tr></table>
|
619
667
|
</div>
|
620
|
-
<div class="
|
668
|
+
<div class="paragraph"><p>If your system has multiple Ruby installations (this is likely the case on
|
621
669
|
MacOS X), then you will need to tell the Phusion Passenger installer which one
|
622
670
|
to use. If you only have one Ruby installation (the case on most Linux systems),
|
623
671
|
then you can skip this section because Phusion Passenger will automatically detect it.</p></div>
|
624
|
-
<div class="
|
672
|
+
<div class="paragraph"><p>To specify the Ruby installation, prepend your Ruby installation’s <tt>bin</tt>
|
625
673
|
directory to the <tt>PATH</tt> environment variable. For example, if you have the
|
626
674
|
following Ruby installations:</p></div>
|
627
|
-
<div class="
|
675
|
+
<div class="ulist"><ul>
|
628
676
|
<li>
|
629
677
|
<p>
|
630
678
|
/usr/bin/ruby
|
@@ -636,44 +684,32 @@ following Ruby installations:</p></div>
|
|
636
684
|
</p>
|
637
685
|
</li>
|
638
686
|
</ul></div>
|
639
|
-
<div class="
|
687
|
+
<div class="paragraph"><p>and you want to use the latter, then type:</p></div>
|
640
688
|
<div class="listingblock">
|
641
689
|
<div class="content">
|
642
690
|
<pre><tt>export PATH=/opt/myruby/bin:$PATH</tt></pre>
|
643
691
|
</div></div>
|
644
692
|
<h4 id="_installing_via_the_gem">2.1.4. Installing via the gem</h4>
|
645
|
-
<div class="
|
693
|
+
<div class="paragraph"><p>Please install the gem and then run the Phusion Passenger installer, by typing the
|
646
694
|
following commands:</p></div>
|
647
695
|
<div class="listingblock">
|
648
696
|
<div class="content">
|
649
697
|
<pre><tt>gem install passenger-x.x.x.gem
|
650
698
|
passenger-install-apache2-module</tt></pre>
|
651
699
|
</div></div>
|
652
|
-
<div class="
|
700
|
+
<div class="paragraph"><p>Please follow the instructions given by the installer.</p></div>
|
653
701
|
<h4 id="_installing_via_a_native_linux_package">2.1.5. Installing via a native Linux package</h4>
|
654
|
-
<div class="
|
702
|
+
<div class="paragraph"><p>John Leach from Brightbox has kindly provided an Ubuntu Hardy package for Phusion Passenger. The package is available from the <a href="http://apt.brightbox.net">Brightbox repository</a>.</p></div>
|
703
|
+
<div class="paragraph"><p>Please install the native Linux package, e.g.:</p></div>
|
655
704
|
<div class="listingblock">
|
656
705
|
<div class="content">
|
657
|
-
<pre><tt>
|
706
|
+
<pre><tt>sudo sh -c 'echo "deb http://apt.brightbox.net hardy main" > /etc/apt/sources.list.d/brightbox.list'
|
707
|
+
sudo sh -c 'wget -q -O - http://apt.brightbox.net/release.asc | apt-key add -'
|
708
|
+
sudo apt-get update
|
709
|
+
sudo apt-get install libapache2-mod-passenger</tt></pre>
|
658
710
|
</div></div>
|
659
|
-
<div class="para"><p>Next, you'll need to configure Apache. Run the "installer", as it will tell you
|
660
|
-
the correct configuration options for Apache:</p></div>
|
661
|
-
<div class="listingblock">
|
662
|
-
<div class="content">
|
663
|
-
<pre><tt>passenger-install-apache2-module</tt></pre>
|
664
|
-
</div></div>
|
665
|
-
<div class="admonitionblock">
|
666
|
-
<table><tr>
|
667
|
-
<td class="icon">
|
668
|
-
<img src="./images/icons/note.png" alt="Note" />
|
669
|
-
</td>
|
670
|
-
<td class="content">The installer doesn't actually install anything because it will automatically
|
671
|
-
detect that Phusion Passenger has already been installed. The only thing the
|
672
|
-
installer will do in this case, is showing the correct Apache configurations.</td>
|
673
|
-
</tr></table>
|
674
|
-
</div>
|
675
711
|
<h4 id="_installing_via_the_source_tarball">2.1.6. Installing via the source tarball</h4>
|
676
|
-
<div class="
|
712
|
+
<div class="paragraph"><p>Extract the tarball to whatever location you prefer. The Phusion Passenger files
|
677
713
|
are to reside in that location permanently. For example, if you would like
|
678
714
|
Phusion Passenger to reside in <tt>/opt/passenger-x.x.x</tt>:</p></div>
|
679
715
|
<div class="listingblock">
|
@@ -681,12 +717,12 @@ Phusion Passenger to reside in <tt>/opt/passenger-x.x.x</tt>:</p></div>
|
|
681
717
|
<pre><tt>cd /opt
|
682
718
|
tar xzvf ~/YourDownloadsFolder/passenger-x.x.x.tar.gz</tt></pre>
|
683
719
|
</div></div>
|
684
|
-
<div class="
|
720
|
+
<div class="paragraph"><p>Next, run the included installer:</p></div>
|
685
721
|
<div class="listingblock">
|
686
722
|
<div class="content">
|
687
723
|
<pre><tt>/opt/passenger-x.x.x/bin/passenger-install-apache2-module</tt></pre>
|
688
724
|
</div></div>
|
689
|
-
<div class="
|
725
|
+
<div class="paragraph"><p>Please follow the instructions given by the installer.</p></div>
|
690
726
|
<div class="admonitionblock">
|
691
727
|
<table><tr>
|
692
728
|
<td class="icon">
|
@@ -698,17 +734,17 @@ installation. Furthermore, the <em>passenger-x.x.x</em> folder must be accessibl
|
|
698
734
|
</div>
|
699
735
|
<h3 id="_operating_system_specific_instructions_and_information">2.2. Operating system-specific instructions and information</h3><div style="clear:left"></div>
|
700
736
|
<h4 id="_macos_x">2.2.1. MacOS X</h4>
|
701
|
-
<div class="
|
737
|
+
<div class="paragraph"><p>Ben Ruebenstein has written an excellent
|
702
738
|
<a href="http://benr75.com/articles/2008/04/12/setup-mod_rails-phusion-mac-os-x-leopard">tutorial
|
703
739
|
on installing Phusion Passenger on OS X</a>.</p></div>
|
704
740
|
<h4 id="_ubuntu_linux">2.2.2. Ubuntu Linux</h4>
|
705
|
-
<div class="
|
741
|
+
<div class="paragraph"><p>Ben Hughes has written an <a href="http://www.railsgarden.com/2008/04/12/configurating-passenger-mod_rails-on-slicehost-with-ubuntu-710/">article on installing Phusion Passenger on Ubuntu</a>.</p></div>
|
706
742
|
</div>
|
707
743
|
<h2 id="_deploying_a_ruby_on_rails_application">3. Deploying a Ruby on Rails application</h2>
|
708
744
|
<div class="sectionbody">
|
709
|
-
<div class="
|
745
|
+
<div class="paragraph"><p>Suppose you have a Ruby on Rails application in <em>/webapps/mycook</em>, and you own
|
710
746
|
the domain <em>www.mycook.com</em>. You can either deploy your application to the
|
711
|
-
virtual host
|
747
|
+
virtual host’s root (i.e. the application will be accessible from the root URL,
|
712
748
|
<em>http://www.mycook.com/</em>), or in a sub URI (i.e. the application will be
|
713
749
|
accessible from a sub URL, such as <em>http://www.mycook.com/railsapplication</em>).</p></div>
|
714
750
|
<div class="admonitionblock">
|
@@ -721,9 +757,9 @@ are run, is “production”. You can change this by changing the
|
|
721
757
|
<a href="#rails_env"><em>RailsEnv</em></a> configuration option.</td>
|
722
758
|
</tr></table>
|
723
759
|
</div>
|
724
|
-
<h3 id="
|
725
|
-
<div class="
|
726
|
-
document root must point to your Ruby on Rails application
|
760
|
+
<h3 id="_deploying_to_a_virtual_host_8217_s_root">3.1. Deploying to a virtual host’s root</h3><div style="clear:left"></div>
|
761
|
+
<div class="paragraph"><p>Add a virtual host entry to your Apache configuration file. The virtual host’s
|
762
|
+
document root must point to your Ruby on Rails application’s <em>public</em> folder.
|
727
763
|
For example:</p></div>
|
728
764
|
<div class="listingblock">
|
729
765
|
<div class="content">
|
@@ -732,9 +768,9 @@ For example:</p></div>
|
|
732
768
|
DocumentRoot /webapps/mycook/public
|
733
769
|
</VirtualHost></tt></pre>
|
734
770
|
</div></div>
|
735
|
-
<div class="
|
771
|
+
<div class="paragraph"><p>Then restart Apache. The application has now been deployed.</p></div>
|
736
772
|
<h3 id="deploying_rails_to_sub_uri">3.2. Deploying to a sub URI</h3><div style="clear:left"></div>
|
737
|
-
<div class="
|
773
|
+
<div class="paragraph"><p>Suppose that you already have a virtual host:</p></div>
|
738
774
|
<div class="listingblock">
|
739
775
|
<div class="content">
|
740
776
|
<pre><tt><VirtualHost *:80>
|
@@ -742,15 +778,15 @@ For example:</p></div>
|
|
742
778
|
DocumentRoot /websites/phusion
|
743
779
|
</VirtualHost></tt></pre>
|
744
780
|
</div></div>
|
745
|
-
<div class="
|
781
|
+
<div class="paragraph"><p>And you want your Ruby on Rails application to be accessible from the URL
|
746
782
|
<em>http://www.phusion.nl/rails</em>.</p></div>
|
747
|
-
<div class="
|
783
|
+
<div class="paragraph"><p>To do this, make a symlink from your Ruby on Rails application’s <em>public</em>
|
748
784
|
folder to a directory in the document root. For example:</p></div>
|
749
785
|
<div class="listingblock">
|
750
786
|
<div class="content">
|
751
787
|
<pre><tt>ln -s /webapps/mycook/public /websites/phusion/rails</tt></pre>
|
752
788
|
</div></div>
|
753
|
-
<div class="
|
789
|
+
<div class="paragraph"><p>Next, add a <a href="#RailsBaseURI">RailsBaseURI</a> option to the virtual host configuration:</p></div>
|
754
790
|
<div class="listingblock">
|
755
791
|
<div class="content">
|
756
792
|
<pre><tt><VirtualHost *:80>
|
@@ -759,14 +795,14 @@ folder to a directory in the document root. For example:</p></div>
|
|
759
795
|
RailsBaseURI /rails # This line has been added.
|
760
796
|
</VirtualHost></tt></pre>
|
761
797
|
</div></div>
|
762
|
-
<div class="
|
798
|
+
<div class="paragraph"><p>Then restart Apache. The application has now been deployed.</p></div>
|
763
799
|
<div class="admonitionblock">
|
764
800
|
<table><tr>
|
765
801
|
<td class="icon">
|
766
802
|
<img src="./images/icons/tip.png" alt="Tip" />
|
767
803
|
</td>
|
768
804
|
<td class="content">
|
769
|
-
<div class="
|
805
|
+
<div class="paragraph"><p>You can deploy multiple Rails applications under a virtual host, by specifying
|
770
806
|
<a href="#RailsBaseURI">RailsBaseURI</a> multiple times. For example:</p></div>
|
771
807
|
<div class="listingblock">
|
772
808
|
<div class="content">
|
@@ -781,10 +817,10 @@ folder to a directory in the document root. For example:</p></div>
|
|
781
817
|
</tr></table>
|
782
818
|
</div>
|
783
819
|
<h3 id="_redeploying_restarting_the_ruby_on_rails_application">3.3. Redeploying (restarting the Ruby on Rails application)</h3><div style="clear:left"></div>
|
784
|
-
<div class="
|
820
|
+
<div class="paragraph"><p>Deploying a new version of a Ruby on Rails application is as simple as
|
785
821
|
re-uploading the application files, and restarting the application.</p></div>
|
786
|
-
<div class="
|
787
|
-
<div class="olist"><ol>
|
822
|
+
<div class="paragraph"><p>There are two ways to restart the application:</p></div>
|
823
|
+
<div class="olist arabic"><ol class="arabic">
|
788
824
|
<li>
|
789
825
|
<p>
|
790
826
|
By restarting Apache.
|
@@ -793,33 +829,33 @@ By restarting Apache.
|
|
793
829
|
<li>
|
794
830
|
<p>
|
795
831
|
By creating or modifying the file <em>tmp/restart.txt</em> in the Rails
|
796
|
-
application
|
797
|
-
restart the application.
|
832
|
+
application’s <a href="#application_root">root folder</a>. Phusion Passenger will
|
833
|
+
automatically restart the application.
|
798
834
|
</p>
|
799
835
|
</li>
|
800
836
|
</ol></div>
|
801
|
-
<div class="
|
837
|
+
<div class="paragraph"><p>For example, to restart our example MyCook application, we type this in the
|
802
838
|
command line:</p></div>
|
803
839
|
<div class="listingblock">
|
804
840
|
<div class="content">
|
805
841
|
<pre><tt>touch /webapps/mycook/tmp/restart.txt</tt></pre>
|
806
842
|
</div></div>
|
807
843
|
<h3 id="_migrations">3.4. Migrations</h3><div style="clear:left"></div>
|
808
|
-
<div class="
|
844
|
+
<div class="paragraph"><p>Phusion Passenger is not related to Ruby on Rails migrations in any way. To
|
809
845
|
run migrations on your deployment server, please login to your deployment
|
810
846
|
server (e.g. with <em>ssh</em>) and type <tt>rake db:migrate RAILS_ENV=production</tt> in
|
811
847
|
a shell console, just like one would normally run migrations.</p></div>
|
812
848
|
<h3 id="_capistrano_integration">3.5. Capistrano integration</h3><div style="clear:left"></div>
|
813
|
-
<div class="
|
849
|
+
<div class="paragraph"><p>See <a href="#capistrano">Capistrano recipe</a>.</p></div>
|
814
850
|
</div>
|
815
851
|
<h2 id="_deploying_a_rack_based_ruby_application">4. Deploying a Rack-based Ruby application</h2>
|
816
852
|
<div class="sectionbody">
|
817
|
-
<div class="
|
853
|
+
<div class="paragraph"><p>Phusion Passenger supports arbitrary Ruby web applications that follow the
|
818
854
|
<a href="http://rack.rubyforge.org/">Rack</a> interface.</p></div>
|
819
|
-
<div class="
|
855
|
+
<div class="paragraph"><p>Phusion Passenger assumes that Rack application directories have a certain layout.
|
820
856
|
Suppose that you have a Rack application in <em>/webapps/rackapp</em>. Then that
|
821
|
-
folder must contain at least
|
822
|
-
<div class="
|
857
|
+
folder must contain at least three entries:</p></div>
|
858
|
+
<div class="ulist"><ul>
|
823
859
|
<li>
|
824
860
|
<p>
|
825
861
|
<em>config.ru</em>, a Rackup file for starting the Rack application. This file must contain
|
@@ -838,7 +874,7 @@ folder must contain at least two entries:</p></div>
|
|
838
874
|
</p>
|
839
875
|
</li>
|
840
876
|
</ul></div>
|
841
|
-
<div class="
|
877
|
+
<div class="paragraph"><p>So <em>/webapps/rackapp</em> must, at minimum, look like this:</p></div>
|
842
878
|
<div class="listingblock">
|
843
879
|
<div class="content">
|
844
880
|
<pre><tt>/webapps/rackapp
|
@@ -849,8 +885,8 @@ folder must contain at least two entries:</p></div>
|
|
849
885
|
|
|
850
886
|
+-- tmp/</tt></pre>
|
851
887
|
</div></div>
|
852
|
-
<div class="
|
853
|
-
to the virtual host
|
888
|
+
<div class="paragraph"><p>Suppose you own the domain <em>www.rackapp.com</em>. You can either deploy your application
|
889
|
+
to the virtual host’s root (i.e. the application will be accessible from the root URL,
|
854
890
|
<em>http://www.rackapp.com/</em>), or in a sub URI (i.e. the application will be
|
855
891
|
accessible from a sub URL, such as <em>http://www.rackapp.com/rackapp</em>).</p></div>
|
856
892
|
<div class="admonitionblock">
|
@@ -864,14 +900,14 @@ are run, is “production”. You can change this by changing the
|
|
864
900
|
</tr></table>
|
865
901
|
</div>
|
866
902
|
<h3 id="_tutorial_example_writing_and_deploying_a_hello_world_rack_application">4.1. Tutorial/example: writing and deploying a Hello World Rack application</h3><div style="clear:left"></div>
|
867
|
-
<div class="
|
903
|
+
<div class="paragraph"><p>First we create a Phusion Passenger-compliant Rack directory structure:</p></div>
|
868
904
|
<div class="listingblock">
|
869
905
|
<div class="content">
|
870
906
|
<pre><tt>$ mkdir /webapps/rack_example
|
871
907
|
$ mkdir /webapps/rack_example/public
|
872
908
|
$ mkdir /webapps/rack_example/tmp</tt></pre>
|
873
909
|
</div></div>
|
874
|
-
<div class="
|
910
|
+
<div class="paragraph"><p>Next, we write a minimal "hello world" Rack application:</p></div>
|
875
911
|
<div class="listingblock">
|
876
912
|
<div class="content">
|
877
913
|
<pre><tt>$ cd /webapps/rack_example
|
@@ -883,7 +919,7 @@ app = proc do |env|
|
|
883
919
|
end
|
884
920
|
run app</tt></pre>
|
885
921
|
</div></div>
|
886
|
-
<div class="
|
922
|
+
<div class="paragraph"><p>Finally, we deploy it by adding the following configuration options to
|
887
923
|
the Apache configuration file:</p></div>
|
888
924
|
<div class="listingblock">
|
889
925
|
<div class="content">
|
@@ -892,11 +928,11 @@ the Apache configuration file:</p></div>
|
|
892
928
|
DocumentRoot /webapps/rack_example/public
|
893
929
|
</VirtualHost></tt></pre>
|
894
930
|
</div></div>
|
895
|
-
<div class="
|
931
|
+
<div class="paragraph"><p>And we’re done! After an Apache restart, the above Rack application will be available
|
896
932
|
under the URL <em>http://www.rackexample.com/</em>.</p></div>
|
897
|
-
<h3 id="
|
898
|
-
<div class="
|
899
|
-
document root must point to your Rack application
|
933
|
+
<h3 id="_deploying_to_a_virtual_host_8217_s_root_2">4.2. Deploying to a virtual host’s root</h3><div style="clear:left"></div>
|
934
|
+
<div class="paragraph"><p>Add a virtual host entry to your Apache configuration file. The virtual host’s
|
935
|
+
document root must point to your Rack application’s <em>public</em> folder.
|
900
936
|
For example:</p></div>
|
901
937
|
<div class="listingblock">
|
902
938
|
<div class="content">
|
@@ -905,9 +941,9 @@ For example:</p></div>
|
|
905
941
|
DocumentRoot /webapps/rackapp/public
|
906
942
|
</VirtualHost></tt></pre>
|
907
943
|
</div></div>
|
908
|
-
<div class="
|
944
|
+
<div class="paragraph"><p>Then restart Apache. The application has now been deployed.</p></div>
|
909
945
|
<h3 id="deploying_rack_to_sub_uri">4.3. Deploying to a sub URI</h3><div style="clear:left"></div>
|
910
|
-
<div class="
|
946
|
+
<div class="paragraph"><p>Suppose that you already have a virtual host:</p></div>
|
911
947
|
<div class="listingblock">
|
912
948
|
<div class="content">
|
913
949
|
<pre><tt><VirtualHost *:80>
|
@@ -915,15 +951,15 @@ For example:</p></div>
|
|
915
951
|
DocumentRoot /websites/phusion
|
916
952
|
</VirtualHost></tt></pre>
|
917
953
|
</div></div>
|
918
|
-
<div class="
|
954
|
+
<div class="paragraph"><p>And you want your Rack application to be accessible from the URL
|
919
955
|
<em>http://www.phusion.nl/rack</em>.</p></div>
|
920
|
-
<div class="
|
956
|
+
<div class="paragraph"><p>To do this, make a symlink from your Rack application’s <em>public</em>
|
921
957
|
folder to a directory in the document root. For example:</p></div>
|
922
958
|
<div class="listingblock">
|
923
959
|
<div class="content">
|
924
960
|
<pre><tt>ln -s /webapps/rackapp/public /websites/phusion/rack</tt></pre>
|
925
961
|
</div></div>
|
926
|
-
<div class="
|
962
|
+
<div class="paragraph"><p>Next, add a <a href="#RackBaseURI">RackBaseURI</a> option to the virtual host configuration:</p></div>
|
927
963
|
<div class="listingblock">
|
928
964
|
<div class="content">
|
929
965
|
<pre><tt><VirtualHost *:80>
|
@@ -932,14 +968,14 @@ folder to a directory in the document root. For example:</p></div>
|
|
932
968
|
RackBaseURI /rack # This line has been added.
|
933
969
|
</VirtualHost></tt></pre>
|
934
970
|
</div></div>
|
935
|
-
<div class="
|
971
|
+
<div class="paragraph"><p>Then restart Apache. The application has now been deployed.</p></div>
|
936
972
|
<div class="admonitionblock">
|
937
973
|
<table><tr>
|
938
974
|
<td class="icon">
|
939
975
|
<img src="./images/icons/tip.png" alt="Tip" />
|
940
976
|
</td>
|
941
977
|
<td class="content">
|
942
|
-
<div class="
|
978
|
+
<div class="paragraph"><p>You can deploy multiple Rack applications under a virtual host, by specifying
|
943
979
|
<a href="#RackBaseURI">RackBaseURI</a> multiple times. For example:</p></div>
|
944
980
|
<div class="listingblock">
|
945
981
|
<div class="content">
|
@@ -954,10 +990,10 @@ folder to a directory in the document root. For example:</p></div>
|
|
954
990
|
</tr></table>
|
955
991
|
</div>
|
956
992
|
<h3 id="_redeploying_restarting_the_rack_application">4.4. Redeploying (restarting the Rack application)</h3><div style="clear:left"></div>
|
957
|
-
<div class="
|
993
|
+
<div class="paragraph"><p>Deploying a new version of a Rack application is as simple as
|
958
994
|
re-uploading the application files, and restarting the application.</p></div>
|
959
|
-
<div class="
|
960
|
-
<div class="olist"><ol>
|
995
|
+
<div class="paragraph"><p>There are two ways to restart the application:</p></div>
|
996
|
+
<div class="olist arabic"><ol class="arabic">
|
961
997
|
<li>
|
962
998
|
<p>
|
963
999
|
By restarting Apache.
|
@@ -966,19 +1002,19 @@ By restarting Apache.
|
|
966
1002
|
<li>
|
967
1003
|
<p>
|
968
1004
|
By creating or modifying the file <em>tmp/restart.txt</em> in the Rack
|
969
|
-
application
|
970
|
-
application.
|
1005
|
+
application’s <a href="#application_root">root folder</a>. Phusion Passenger will
|
1006
|
+
automatically restart the application.
|
971
1007
|
</p>
|
972
1008
|
</li>
|
973
1009
|
</ol></div>
|
974
|
-
<div class="
|
1010
|
+
<div class="paragraph"><p>For example, to restart our example application, we type this in the
|
975
1011
|
command line:</p></div>
|
976
1012
|
<div class="listingblock">
|
977
1013
|
<div class="content">
|
978
1014
|
<pre><tt>touch /webapps/rackapp/tmp/restart.txt</tt></pre>
|
979
1015
|
</div></div>
|
980
1016
|
<h3 id="_rackup_specifications_for_various_web_frameworks">4.5. Rackup specifications for various web frameworks</h3><div style="clear:left"></div>
|
981
|
-
<div class="
|
1017
|
+
<div class="paragraph"><p>This subsection shows example <em>config.ru</em> files for various web frameworks.</p></div>
|
982
1018
|
<h4 id="_camping">4.5.1. Camping</h4>
|
983
1019
|
<div class="listingblock">
|
984
1020
|
<div class="content">
|
@@ -994,7 +1030,7 @@ Camping.goes :Blog
|
|
994
1030
|
|
995
1031
|
run Rack::Adapter::Camping.new(Blog)</tt></pre>
|
996
1032
|
</div></div>
|
997
|
-
<div class="
|
1033
|
+
<div class="paragraph"><p>For Camping versions 2.0 and up, using <tt>run Blog</tt> as the final line will do.</p></div>
|
998
1034
|
<h4 id="_halcyon">4.5.2. Halcyon</h4>
|
999
1035
|
<div class="listingblock">
|
1000
1036
|
<div class="content">
|
@@ -1019,8 +1055,10 @@ run Mack::Utils::Server.build_app</tt></pre>
|
|
1019
1055
|
<pre><tt>require 'rubygems'
|
1020
1056
|
require 'merb-core'
|
1021
1057
|
|
1022
|
-
Merb::Config.setup(
|
1023
|
-
|
1058
|
+
Merb::Config.setup(
|
1059
|
+
:merb_root => File.expand_path(File.dirname(__FILE__)),
|
1060
|
+
:environment => ENV['RACK_ENV']
|
1061
|
+
)
|
1024
1062
|
Merb.environment = Merb::Config[:environment]
|
1025
1063
|
Merb.root = Merb::Config[:merb_root]
|
1026
1064
|
Merb::BootLoader.run
|
@@ -1043,33 +1081,31 @@ require 'sinatra'
|
|
1043
1081
|
|
1044
1082
|
root_dir = File.dirname(__FILE__)
|
1045
1083
|
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
:env => ENV['RACK_ENV'].to_sym
|
1051
|
-
)
|
1084
|
+
set :environment, ENV['RACK_ENV'].to_sym
|
1085
|
+
set :root, root_dir
|
1086
|
+
set :app_file, File.join(root_dir, 'app.rb')
|
1087
|
+
disable :run
|
1052
1088
|
|
1053
|
-
run Sinatra
|
1089
|
+
run Sinatra::Application</tt></pre>
|
1054
1090
|
</div></div>
|
1055
1091
|
</div>
|
1056
1092
|
<h2 id="_configuring_phusion_passenger">5. Configuring Phusion Passenger</h2>
|
1057
1093
|
<div class="sectionbody">
|
1058
|
-
<div class="
|
1094
|
+
<div class="paragraph"><p>After installation, Phusion Passenger does not need any further configurations.
|
1059
1095
|
Nevertheless, the system administrator may be interested in changing
|
1060
|
-
Phusion Passenger
|
1096
|
+
Phusion Passenger’s behavior. Phusion Passenger’s Apache module supports the
|
1061
1097
|
following configuration options:</p></div>
|
1062
1098
|
<h3 id="_passengerroot_lt_directory_gt">5.1. PassengerRoot <directory></h3><div style="clear:left"></div>
|
1063
|
-
<div class="
|
1099
|
+
<div class="paragraph"><p>The location to the Phusion Passenger root directory. This configuration option
|
1064
1100
|
is essential to Phusion Passenger. The correct value is given by the installer,
|
1065
1101
|
and should usually not be changed manually.</p></div>
|
1066
|
-
<div class="
|
1102
|
+
<div class="paragraph"><p>This required option may only occur once, in the global server configuration.</p></div>
|
1067
1103
|
<h3 id="_passengerloglevel_lt_integer_gt">5.2. PassengerLogLevel <integer></h3><div style="clear:left"></div>
|
1068
|
-
<div class="
|
1104
|
+
<div class="paragraph"><p>This option allows one to specify how much information Phusion Passenger should
|
1069
1105
|
write to the Apache error log file. A higher log level value means that more
|
1070
1106
|
information will be logged.</p></div>
|
1071
|
-
<div class="
|
1072
|
-
<div class="
|
1107
|
+
<div class="paragraph"><p>Possible values are:</p></div>
|
1108
|
+
<div class="ulist"><ul>
|
1073
1109
|
<li>
|
1074
1110
|
<p>
|
1075
1111
|
<em>0</em>: Show only errors and warnings.
|
@@ -1093,37 +1129,88 @@ information will be logged.</p></div>
|
|
1093
1129
|
</p>
|
1094
1130
|
</li>
|
1095
1131
|
</ul></div>
|
1096
|
-
<div class="
|
1132
|
+
<div class="paragraph"><p>This option may only occur once, in the global server configuration.
|
1097
1133
|
The default is <em>0</em>.</p></div>
|
1098
1134
|
<h3 id="PassengerRuby">5.3. PassengerRuby <filename></h3><div style="clear:left"></div>
|
1099
|
-
<div class="
|
1100
|
-
<div class="
|
1135
|
+
<div class="paragraph"><p>This option allows one to specify the Ruby interpreter to use.</p></div>
|
1136
|
+
<div class="paragraph"><p>This option may only occur once, in the global server configuration.
|
1101
1137
|
The default is <em>ruby</em>.</p></div>
|
1102
|
-
<h3 id="
|
1103
|
-
<div class="
|
1104
|
-
|
1105
|
-
|
1106
|
-
<
|
1107
|
-
<div class="
|
1138
|
+
<h3 id="PassengerAppRoot">5.4. PassengerAppRoot <path/to/root></h3><div style="clear:left"></div>
|
1139
|
+
<div class="paragraph"><p>By default, Phusion Passenger assumes that the application’s root directory
|
1140
|
+
is the parent directory of the <em>public</em> directory. This option allows one to
|
1141
|
+
specify the application’s root independently from the DocumentRoot, which
|
1142
|
+
is useful if the <em>public</em> directory lives in a non-standard place.</p></div>
|
1143
|
+
<div class="paragraph"><p>This option may occur in the following places:</p></div>
|
1144
|
+
<div class="ulist"><ul>
|
1145
|
+
<li>
|
1146
|
+
<p>
|
1147
|
+
In the global server configuration.
|
1148
|
+
</p>
|
1149
|
+
</li>
|
1150
|
+
<li>
|
1151
|
+
<p>
|
1152
|
+
In a virtual host configuration block.
|
1153
|
+
</p>
|
1154
|
+
</li>
|
1155
|
+
<li>
|
1156
|
+
<p>
|
1157
|
+
In a <tt><Directory></tt> or <tt><Location></tt> block.
|
1158
|
+
</p>
|
1159
|
+
</li>
|
1160
|
+
<li>
|
1161
|
+
<p>
|
1162
|
+
In <em>.htaccess</em>, if <tt>AllowOverride Options</tt> is on.
|
1163
|
+
</p>
|
1164
|
+
</li>
|
1165
|
+
</ul></div>
|
1166
|
+
<div class="paragraph"><p>In each place, it may be specified at most once.</p></div>
|
1167
|
+
<div class="paragraph"><p>Example:</p></div>
|
1168
|
+
<div class="listingblock">
|
1169
|
+
<div class="content">
|
1170
|
+
<pre><tt><VirtualHost test.host>
|
1171
|
+
DocumentRoot /var/rails/zena/sites/example.com/public
|
1172
|
+
PassengerAppRoot /var/rails/zena # <-- normally Phusion Passenger would
|
1173
|
+
# have assumed that the application
|
1174
|
+
# root is "/var/rails/zena/sites/example.com"
|
1175
|
+
</VirtualHost></tt></pre>
|
1176
|
+
</div></div>
|
1177
|
+
<h3 id="PassengerUseGlobalQueue">5.5. PassengerUseGlobalQueue <on|off></h3><div style="clear:left"></div>
|
1178
|
+
<div class="paragraph"><p>Turns the use of global queuing on or off.</p></div>
|
1179
|
+
<div class="paragraph"><p>This option may occur in the following places:</p></div>
|
1180
|
+
<div class="ulist"><ul>
|
1181
|
+
<li>
|
1182
|
+
<p>
|
1183
|
+
In the global server configuration.
|
1184
|
+
</p>
|
1185
|
+
</li>
|
1186
|
+
<li>
|
1187
|
+
<p>
|
1188
|
+
In a virtual host configuration block.
|
1189
|
+
</p>
|
1190
|
+
</li>
|
1191
|
+
</ul></div>
|
1192
|
+
<div class="paragraph"><p>In each place, it may be specified at most once. The default value is <em>off</em>.</p></div>
|
1193
|
+
<div class="paragraph"><p><em>This feature is sponsored by <a href="http://www.37signals.com/">37signals</a>.</em></p></div>
|
1194
|
+
<div class="paragraph"><div class="title">What does this option do?</div><p>Recall that Phusion Passenger spawns multiple backend processes (e.g. multiple
|
1108
1195
|
Ruby on Rails processes), each which processes HTTP requests serially. One of
|
1109
|
-
Phusion Passenger
|
1196
|
+
Phusion Passenger’s jobs is to forward HTTP requests to a suitable backend
|
1110
1197
|
process. A backend process may take an arbitrary amount of time to process a
|
1111
1198
|
specific HTTP request. If the websites are (temporarily) under high load, and
|
1112
1199
|
the backend processes cannot process the requests fast enough, then some
|
1113
1200
|
requests may have to be queued.</p></div>
|
1114
|
-
<div class="
|
1201
|
+
<div class="paragraph"><p>If global queuing is turned off, then Phusion Passenger will use <em>fair load
|
1115
1202
|
balancing</em>. This means that each backend process will have its own private
|
1116
1203
|
queue. Phusion Passenger will forward an HTTP request to the backend process
|
1117
1204
|
that has the least amount of requests in its queue.</p></div>
|
1118
|
-
<div class="
|
1119
|
-
that
|
1205
|
+
<div class="paragraph"><p>If global queuing is turned on, then Phusion Passenger will use a global queue
|
1206
|
+
that’s shared between all backend processes. If an HTTP request comes in, and
|
1120
1207
|
all the backend processes are still busy, then Phusion Passenger will wait until
|
1121
1208
|
at least one backend process is done, and will then forward the request to that
|
1122
1209
|
process.</p></div>
|
1123
|
-
<div class="
|
1210
|
+
<div class="paragraph"><div class="title">When to turn on global queuing?</div><p>You should turn on global queuing if one of your web applications may have
|
1124
1211
|
long-running requests.</p></div>
|
1125
|
-
<div class="
|
1126
|
-
<div class="
|
1212
|
+
<div class="paragraph"><p>For example suppose that:</p></div>
|
1213
|
+
<div class="ulist"><ul>
|
1127
1214
|
<li>
|
1128
1215
|
<p>
|
1129
1216
|
global queuing is turned off.
|
@@ -1131,13 +1218,13 @@ global queuing is turned off.
|
|
1131
1218
|
</li>
|
1132
1219
|
<li>
|
1133
1220
|
<p>
|
1134
|
-
we
|
1221
|
+
we’re currently in a state where all backend processes have 3 requests in
|
1135
1222
|
their queue, except for a single backend process, which has 1 request in its
|
1136
1223
|
queue.
|
1137
1224
|
</p>
|
1138
1225
|
</li>
|
1139
1226
|
</ul></div>
|
1140
|
-
<div class="
|
1227
|
+
<div class="paragraph"><p>The situation looks like this:</p></div>
|
1141
1228
|
<div class="listingblock">
|
1142
1229
|
<div class="content">
|
1143
1230
|
<pre><tt>Backend process A: [* ] (1 request in queue)
|
@@ -1145,9 +1232,9 @@ Backend process B: [*** ] (3 requests in queue)
|
|
1145
1232
|
Backend process C: [*** ] (3 requests in queue)
|
1146
1233
|
Backend process D: [*** ] (3 requests in queue)</tt></pre>
|
1147
1234
|
</div></div>
|
1148
|
-
<div class="
|
1149
|
-
<div class="
|
1150
|
-
now have 2 items in its queue. We
|
1235
|
+
<div class="paragraph"><p>Each process is currently serving short-running requests.</p></div>
|
1236
|
+
<div class="paragraph"><p>Phusion Passenger will forward the next request to backend process A. A will
|
1237
|
+
now have 2 items in its queue. We’ll mark this new request with an X:</p></div>
|
1151
1238
|
<div class="listingblock">
|
1152
1239
|
<div class="content">
|
1153
1240
|
<pre><tt>Backend process A: [*X ] (2 request in queue)
|
@@ -1155,8 +1242,8 @@ Backend process B: [*** ] (3 requests in queue)
|
|
1155
1242
|
Backend process C: [*** ] (3 requests in queue)
|
1156
1243
|
Backend process D: [*** ] (3 requests in queue)</tt></pre>
|
1157
1244
|
</div></div>
|
1158
|
-
<div class="
|
1159
|
-
HTTP request - let
|
1245
|
+
<div class="paragraph"><p>Assuming that B, C and D still aren’t done with their current request, the next
|
1246
|
+
HTTP request - let’s call this Y - will be forwarded to backend process A as
|
1160
1247
|
well, because it has the least number of items in its queue:</p></div>
|
1161
1248
|
<div class="listingblock">
|
1162
1249
|
<div class="content">
|
@@ -1165,43 +1252,254 @@ Backend process B: [*** ] (3 requests in queue)
|
|
1165
1252
|
Backend process C: [*** ] (3 requests in queue)
|
1166
1253
|
Backend process D: [*** ] (3 requests in queue)</tt></pre>
|
1167
1254
|
</div></div>
|
1168
|
-
<div class="
|
1169
|
-
complete, then we
|
1255
|
+
<div class="paragraph"><p>But if request X happens to be a long-running request that needs 60 seconds to
|
1256
|
+
complete, then we’ll have a problem. Y won’t be processed for at least 60
|
1170
1257
|
seconds. It would have been a better idea if Y was forward to processes B, C or
|
1171
1258
|
D instead, because they only have short-living requests in their queues.</p></div>
|
1172
|
-
<div class="
|
1259
|
+
<div class="paragraph"><p>This problem will be avoided entirely if you turn global queuing on. With global
|
1173
1260
|
queuing, all backend processes will share the same queue. The first backend
|
1174
1261
|
process that becomes available will take from the queue, and so this
|
1175
1262
|
“queuing-behind-long-running-request” problem will never occur.</p></div>
|
1176
|
-
<div class="
|
1177
|
-
depending on how fast/slow your web application is), which is why it
|
1263
|
+
<div class="paragraph"><p>Turning global queuing off will yield a minor performance improvement (about 5%,
|
1264
|
+
depending on how fast/slow your web application is), which is why it’s off by
|
1178
1265
|
default.</p></div>
|
1179
|
-
<h3 id="PassengerUserSwitching">5.
|
1180
|
-
<div class="
|
1181
|
-
<div class="
|
1266
|
+
<h3 id="PassengerUserSwitching">5.6. PassengerUserSwitching <on|off></h3><div style="clear:left"></div>
|
1267
|
+
<div class="paragraph"><p>Whether to enable <a href="#user_switching">user switching support</a>.</p></div>
|
1268
|
+
<div class="paragraph"><p>This option may only occur once, in the global server configuration.
|
1182
1269
|
The default value is <em>on</em>.</p></div>
|
1183
|
-
<h3 id="PassengerDefaultUser">5.
|
1184
|
-
<div class="
|
1270
|
+
<h3 id="PassengerDefaultUser">5.7. PassengerDefaultUser <username></h3><div style="clear:left"></div>
|
1271
|
+
<div class="paragraph"><p>Passenger enables <a href="#user_switching">user switching support</a> by default.
|
1185
1272
|
This configuration option allows one to specify which user Rails/Rack
|
1186
1273
|
applications must run as, if user switching fails or is disabled.</p></div>
|
1187
|
-
<div class="
|
1274
|
+
<div class="paragraph"><p>This option may only occur once, in the global server configuration.
|
1188
1275
|
The default value is <em>nobody</em>.</p></div>
|
1189
|
-
<h3 id="
|
1190
|
-
<
|
1191
|
-
|
1276
|
+
<h3 id="PassengerHighPerformance">5.8. PassengerHighPerformance <on|off></h3><div style="clear:left"></div>
|
1277
|
+
<div class="paragraph"><p>By default, Phusion Passenger is compatible with mod_rewrite and most other
|
1278
|
+
Apache modules. However, a lot of effort is required in order to be compatible.
|
1279
|
+
If you turn <em>PassengerHighPerformance</em> to <em>on</em>, then Phusion Passenger will be
|
1280
|
+
a little faster, in return for reduced compatibility with other Apache modules.</p></div>
|
1281
|
+
<div class="paragraph"><p>In places where <em>PassengerHighPerformance</em> is turned on, mod_rewrite rules will
|
1282
|
+
likely not work. mod_autoindex (the module which displays a directory index)
|
1283
|
+
will also not work. Other Apache modules may or may not work, depending on what
|
1284
|
+
they exactly do. We recommend you to find out how other modules behave in high
|
1285
|
+
performance mode via testing.</p></div>
|
1286
|
+
<div class="paragraph"><p>This option is <strong>not</strong> an all-or-nothing global option: you can enable high
|
1287
|
+
performance mode for certain virtual hosts or certain URLs only.
|
1288
|
+
The <em>PassengerHighPerformance</em> option may occur in the following places:</p></div>
|
1289
|
+
<div class="ulist"><ul>
|
1290
|
+
<li>
|
1291
|
+
<p>
|
1292
|
+
In the global server configuration.
|
1293
|
+
</p>
|
1294
|
+
</li>
|
1295
|
+
<li>
|
1296
|
+
<p>
|
1297
|
+
In a virtual host configuration block.
|
1298
|
+
</p>
|
1299
|
+
</li>
|
1300
|
+
<li>
|
1301
|
+
<p>
|
1302
|
+
In a <tt><Directory></tt> or <tt><Location></tt> block.
|
1303
|
+
</p>
|
1304
|
+
</li>
|
1305
|
+
<li>
|
1306
|
+
<p>
|
1307
|
+
In <em>.htaccess</em>.
|
1308
|
+
</p>
|
1309
|
+
</li>
|
1310
|
+
</ul></div>
|
1311
|
+
<div class="paragraph"><p>In each place, it may be specified at most once. The default value is <em>off</em>,
|
1312
|
+
so high performance mode is disabled by default, and you have to explicitly
|
1313
|
+
enable it.</p></div>
|
1314
|
+
<div class="paragraph"><div class="title">When to enable high performance mode?</div><p>If you do not use mod_rewrite or other Apache modules then it might make
|
1315
|
+
sense to enable high performance mode.</p></div>
|
1316
|
+
<div class="paragraph"><p>It’s likely that some of your applications depend on mod_rewrite or other
|
1317
|
+
Apache modules, while some do not. In that case you can enable high performance
|
1318
|
+
for only those applications that don’t use other Apache modules. For example:</p></div>
|
1319
|
+
<div class="listingblock">
|
1320
|
+
<div class="content">
|
1321
|
+
<pre><tt><VirtualHost *:80>
|
1322
|
+
ServerName www.foo.com
|
1323
|
+
DocumentRoot /apps/foo/public
|
1324
|
+
.... mod_rewrite rules or options for other Apache modules here ...
|
1325
|
+
</VirtualHost>
|
1326
|
+
|
1327
|
+
<VirtualHost *:80>
|
1328
|
+
ServerName www.bar.com
|
1329
|
+
DocumentRoot /apps/bar/public
|
1330
|
+
PassengerHighPerformance on
|
1331
|
+
</VirtualHost></tt></pre>
|
1332
|
+
</div></div>
|
1333
|
+
<div class="paragraph"><p>In the above example, high performance mode is only enabled for www.bar.com.
|
1334
|
+
It is disabled for everything else.</p></div>
|
1335
|
+
<div class="paragraph"><p>If your application generally depends on mod_rewrite or other Apache modules,
|
1336
|
+
but a certain URL that’s accessed often doesn’t depend on those other modules,
|
1337
|
+
then you can enable high performance mode for a certain URL only. For example:</p></div>
|
1338
|
+
<div class="listingblock">
|
1339
|
+
<div class="content">
|
1340
|
+
<pre><tt><VirtualHost *:80>
|
1341
|
+
ServerName www.foo.com
|
1342
|
+
DocumentRoot /apps/foo/public
|
1343
|
+
.... mod_rewrite rules or options for other Apache modules here ...
|
1344
|
+
|
1345
|
+
<Location /chatroom/ajax_update_poll>
|
1346
|
+
PassengerHighPerformance on
|
1347
|
+
</Location>
|
1348
|
+
</VirtualHost></tt></pre>
|
1349
|
+
</div></div>
|
1350
|
+
<div class="paragraph"><p>This enables high performance mode for
|
1351
|
+
<a href="http://www.foo.com/chatroom/ajax_update_poll">http://www.foo.com/chatroom/ajax_update_poll</a> only.</p></div>
|
1352
|
+
<h3 id="_passengerenabled_lt_on_off_gt">5.9. PassengerEnabled <on|off></h3><div style="clear:left"></div>
|
1353
|
+
<div class="paragraph"><p>You can set this option to <em>off</em> to completely disable Phusion Passenger for
|
1354
|
+
a certain location. This is useful if, for example, you want to integrate a PHP
|
1355
|
+
application into the same virtual host as a Rails application.</p></div>
|
1356
|
+
<div class="paragraph"><p>Suppose that you have a Rails application in <em>/apps/foo</em>. Suppose that you’ve
|
1357
|
+
dropped Wordpress — a blogging application written in PHP — in
|
1358
|
+
<em>/apps/foo/public/wordpress</em>. You can then configure Phusion Passenger as
|
1359
|
+
follows:</p></div>
|
1360
|
+
<div class="listingblock">
|
1361
|
+
<div class="content">
|
1362
|
+
<pre><tt><VirtualHost *:80>
|
1363
|
+
ServerName www.foo.com
|
1364
|
+
DocumentRoot /apps/foo/public
|
1365
|
+
<Location /wordpress>
|
1366
|
+
PassengerEnabled off
|
1367
|
+
AllowOverride all # <-- Makes Wordpress's .htaccess file work.
|
1368
|
+
</Location>
|
1369
|
+
</VirtualHost></tt></pre>
|
1370
|
+
</div></div>
|
1371
|
+
<div class="paragraph"><p>This way, Phusion Passenger will not interfere with Wordpress.</p></div>
|
1372
|
+
<div class="paragraph"><p><em>PassengerEnabled</em> may occur in the following places:</p></div>
|
1373
|
+
<div class="ulist"><ul>
|
1374
|
+
<li>
|
1375
|
+
<p>
|
1376
|
+
In the global server configuration.
|
1377
|
+
</p>
|
1378
|
+
</li>
|
1379
|
+
<li>
|
1380
|
+
<p>
|
1381
|
+
In a virtual host configuration block.
|
1382
|
+
</p>
|
1383
|
+
</li>
|
1384
|
+
<li>
|
1385
|
+
<p>
|
1386
|
+
In a <tt><Directory></tt> or <tt><Location></tt> block.
|
1387
|
+
</p>
|
1388
|
+
</li>
|
1389
|
+
<li>
|
1390
|
+
<p>
|
1391
|
+
In <em>.htaccess</em>.
|
1392
|
+
</p>
|
1393
|
+
</li>
|
1394
|
+
</ul></div>
|
1395
|
+
<div class="paragraph"><p>In each place, it may be specified at most once. The default value is <em>on</em>.</p></div>
|
1396
|
+
<h3 id="_passengertempdir_lt_directory_gt">5.10. PassengerTempDir <directory></h3><div style="clear:left"></div>
|
1397
|
+
<div class="paragraph"><p>Specifies the directory that Phusion Passenger should use for storing temporary
|
1398
|
+
files. This includes things such as Unix socket files, buffered file uploads,
|
1399
|
+
etc.</p></div>
|
1400
|
+
<div class="paragraph"><p>This option may be specified once, in the global server configuration. The
|
1401
|
+
default temp directory that Phusion Passenger uses is <em>/tmp</em>.</p></div>
|
1402
|
+
<div class="paragraph"><p>This option is especially useful if Apache is not allowed to write to /tmp
|
1403
|
+
(which is the case on some systems with strict SELinux policies) or if the
|
1404
|
+
partition that /tmp lives on doesn’t have enough disk space.</p></div>
|
1405
|
+
<div class="paragraph"><div class="title">Command line tools</div><p>Some Phusion Passenger command line administration tools, such as
|
1406
|
+
<tt>passenger-status</tt>, must know what Phusion Passenger’s temp directory is
|
1407
|
+
in order to function properly. You can pass the directory through the
|
1408
|
+
<tt>PASSENGER_TMPDIR</tt> environment variable, or the <tt>TMPDIR</tt> environment variable
|
1409
|
+
(the former will be used if both are specified).</p></div>
|
1410
|
+
<div class="paragraph"><p>For example, if you set <em>PassengerTempDir</em> to <em>/my_temp_dir</em>, then invoke
|
1411
|
+
<tt>passenger-status</tt> after you’ve set the <tt>PASSENGER_TMPDIR</tt> or <tt>TMPDIR</tt>
|
1412
|
+
environment variable, like this:</p></div>
|
1413
|
+
<div class="listingblock">
|
1414
|
+
<div class="content">
|
1415
|
+
<pre><tt>export PASSENGER_TMPDIR=/my_temp-dir
|
1416
|
+
sudo -E passenger-status
|
1417
|
+
# The -E option tells 'sudo' to preserve environment variables.</tt></pre>
|
1418
|
+
</div></div>
|
1419
|
+
<h3 id="_passengerrestartdir_lt_directory_gt">5.11. PassengerRestartDir <directory></h3><div style="clear:left"></div>
|
1420
|
+
<div class="paragraph"><p>As described in the deployment chapters of this document, Phusion Passenger
|
1421
|
+
checks the file <em>tmp/restart.txt</em> in the applications'
|
1422
|
+
<a href="#application_root">root directory</a> for restarting applications. Sometimes it
|
1423
|
+
may be desirable for Phusion Passenger to look in a different directory instead,
|
1424
|
+
for example for security reasons (see below). This option allows you to
|
1425
|
+
customize the directory in which <em>restart.txt</em> is searched for.</p></div>
|
1426
|
+
<div class="paragraph"><p>You may specify <em>PassengerRestartDir</em> in the following places:</p></div>
|
1427
|
+
<div class="ulist"><ul>
|
1428
|
+
<li>
|
1429
|
+
<p>
|
1430
|
+
In the global server configuration.
|
1431
|
+
</p>
|
1432
|
+
</li>
|
1433
|
+
<li>
|
1434
|
+
<p>
|
1435
|
+
In a virtual host configuration block.
|
1436
|
+
</p>
|
1437
|
+
</li>
|
1438
|
+
<li>
|
1439
|
+
<p>
|
1440
|
+
In a <tt><Directory></tt> or <tt><Location></tt> block.
|
1441
|
+
</p>
|
1442
|
+
</li>
|
1443
|
+
<li>
|
1444
|
+
<p>
|
1445
|
+
In <em>.htaccess</em>, if <tt>AllowOverrides Options</tt> is enabled.
|
1446
|
+
</p>
|
1447
|
+
</li>
|
1448
|
+
</ul></div>
|
1449
|
+
<div class="paragraph"><p>In each place, it may be specified at most once.</p></div>
|
1450
|
+
<div class="paragraph"><p>You can either set it to an absolute directory, or to a directory relative to
|
1451
|
+
the <a href="#application_root">application root</a>. Examples:</p></div>
|
1452
|
+
<div class="listingblock">
|
1453
|
+
<div class="content">
|
1454
|
+
<pre><tt><VirtualHost *:80>
|
1455
|
+
ServerName www.foo.com
|
1456
|
+
# Phusion Passenger will check for /apps/foo/public/tmp/restart.txt
|
1457
|
+
DocumentRoot /apps/foo/public
|
1458
|
+
</VirtualHost>
|
1459
|
+
|
1460
|
+
<VirtualHost *:80>
|
1461
|
+
ServerName www.bar.com
|
1462
|
+
DocumentRoot /apps/bar/public
|
1463
|
+
# An absolute filename is given; Phusion Passenger will
|
1464
|
+
# check for /restart_files/bar/restart.txt
|
1465
|
+
PassengerRestartDir /restart_files/bar
|
1466
|
+
</VirtualHost>
|
1467
|
+
|
1468
|
+
<VirtualHost *:80>
|
1469
|
+
ServerName www.baz.com
|
1470
|
+
DocumentRoot /apps/baz/public
|
1471
|
+
# A relative filename is given; Phusion Passenger will
|
1472
|
+
# check for /apps/baz/restart_files/restart.txt
|
1473
|
+
#
|
1474
|
+
# Note that this directory is relative to the APPLICATION ROOT, *not*
|
1475
|
+
# the value of DocumentRoot!
|
1476
|
+
PassengerRestartDir restart_files
|
1477
|
+
</VirtualHost></tt></pre>
|
1478
|
+
</div></div>
|
1479
|
+
<div class="paragraph"><div class="title">What are the security reasons for wanting to customize PassengerRestartDir?</div><p>Touching restart.txt will cause Phusion Passenger to restart the application.
|
1480
|
+
So anybody who can touch restart.txt can effectively cause a Denial-of-Service
|
1481
|
+
attack by touching restart.txt over and over. If your web server or one of your
|
1482
|
+
web applications has the permission to touch restart.txt, and one of them has a
|
1483
|
+
security flaw which allows an attacker to touch restart.txt, then that will
|
1484
|
+
allow the attacker to cause a Denial-of-Service.</p></div>
|
1485
|
+
<div class="paragraph"><p>You can prevent this from happening by pointing PassengerRestartDir to a
|
1486
|
+
directory that’s readable by Apache, but only writable by administrators.</p></div>
|
1487
|
+
<h3 id="_resource_control_and_optimization_options">5.12. Resource control and optimization options</h3><div style="clear:left"></div>
|
1488
|
+
<h4 id="_passengermaxpoolsize_lt_integer_gt">5.12.1. PassengerMaxPoolSize <integer></h4>
|
1489
|
+
<div class="paragraph"><p>The maximum number of Ruby on Rails or Rack application instances that may
|
1192
1490
|
be simultaneously active. A larger number results in higher memory usage,
|
1193
1491
|
but improved ability to handle concurrent HTTP clients.</p></div>
|
1194
|
-
<div class="
|
1492
|
+
<div class="paragraph"><p>The optimal value depends on your system’s hardware and the server’s average
|
1195
1493
|
load. You should experiment with different values. But generally speaking,
|
1196
1494
|
the value should be at least equal to the number of CPUs (or CPU cores) that
|
1197
1495
|
you have. If your system has 2 GB of RAM, then we recommend a value of <em>30</em>.
|
1198
1496
|
If your system is a Virtual Private Server (VPS) and has about 256 MB RAM, and
|
1199
1497
|
is also running other services such as MySQL, then we recommend a value of <em>2</em>.</p></div>
|
1200
|
-
<div class="
|
1498
|
+
<div class="paragraph"><p>If you find that your server is unable to handle the load on your Rails/Rack websites
|
1201
1499
|
(i.e. running out of memory) then you should lower this value. (Though if your
|
1202
1500
|
sites are really that popular, then you should strongly consider upgrading your
|
1203
1501
|
hardware or getting more servers.)</p></div>
|
1204
|
-
<div class="
|
1502
|
+
<div class="paragraph"><p>This option may only occur once, in the global server configuration.
|
1205
1503
|
The default value is <em>6</em>.</p></div>
|
1206
1504
|
<div class="admonitionblock">
|
1207
1505
|
<table><tr>
|
@@ -1209,40 +1507,142 @@ The default value is <em>6</em>.</p></div>
|
|
1209
1507
|
<img src="./images/icons/tip.png" alt="Tip" />
|
1210
1508
|
</td>
|
1211
1509
|
<td class="content">We strongly recommend you to <a href="#reducing_memory_usage">use Ruby Enterprise Edition</a>. This allows you to reduce the memory usage of your Ruby on Rails applications
|
1212
|
-
by about 33%. And it
|
1510
|
+
by about 33%. And it’s not hard to install.</td>
|
1213
1511
|
</tr></table>
|
1214
1512
|
</div>
|
1215
|
-
<h4 id="_passengermaxinstancesperapp_lt_integer_gt">5.
|
1216
|
-
<div class="
|
1513
|
+
<h4 id="_passengermaxinstancesperapp_lt_integer_gt">5.12.2. PassengerMaxInstancesPerApp <integer></h4>
|
1514
|
+
<div class="paragraph"><p>The maximum number of application instances that may be simultaneously active
|
1217
1515
|
for a single application. This helps to make sure that a single application
|
1218
1516
|
will not occupy all available slots in the application pool.</p></div>
|
1219
|
-
<div class="
|
1517
|
+
<div class="paragraph"><p>This value must be less than <a href="#PassengerMaxPoolSize">PassengerMaxPoolSize</a>. A value of 0
|
1220
1518
|
means that there is no limit placed on the number of instances a single application
|
1221
1519
|
may use, i.e. only the global limit of <a href="#PassengerMaxPoolSize">PassengerMaxPoolSize</a>
|
1222
1520
|
will be enforced.</p></div>
|
1223
|
-
<div class="
|
1521
|
+
<div class="paragraph"><p>This option may only occur once, in the global server configuration.
|
1224
1522
|
The default value is <em>0</em>.</p></div>
|
1225
|
-
<h4 id="PassengerPoolIdleTime">5.
|
1226
|
-
<div class="
|
1227
|
-
if an application instance hasn
|
1523
|
+
<h4 id="PassengerPoolIdleTime">5.12.3. PassengerPoolIdleTime <integer></h4>
|
1524
|
+
<div class="paragraph"><p>The maximum number of seconds that an application instance may be idle. That is,
|
1525
|
+
if an application instance hasn’t received any traffic after the given number of
|
1228
1526
|
seconds, then it will be shutdown in order to conserve memory.</p></div>
|
1229
|
-
<div class="
|
1527
|
+
<div class="paragraph"><p>Decreasing this value means that applications will have to be spawned
|
1230
1528
|
more often. Since spawning is a relatively slow operation, some visitors may
|
1231
1529
|
notice a small delay when they visit your Rails/Rack website. However, it will also
|
1232
1530
|
free up resources used by applications more quickly.</p></div>
|
1233
|
-
<div class="
|
1531
|
+
<div class="paragraph"><p>The optimal value depends on the average time that a visitor spends on a single
|
1234
1532
|
Rails/Rack web page. We recommend a value of <tt>2 * x</tt>, where <tt>x</tt> is the average
|
1235
1533
|
number of seconds that a visitor spends on a single Rails/Rack web page. But your
|
1236
1534
|
mileage may vary.</p></div>
|
1237
|
-
<div class="
|
1535
|
+
<div class="paragraph"><p>When this value is set to <em>0</em>, application instances will not be shutdown unless
|
1536
|
+
it’s really necessary, i.e. when Phusion Passenger is out of worker processes
|
1537
|
+
for a given application and one of the inactive application instances needs to
|
1538
|
+
make place for another application instance. Setting the value to 0 is
|
1539
|
+
recommended if you’re on a non-shared host that’s only running a few
|
1540
|
+
applications, each which must be available at all times.</p></div>
|
1541
|
+
<div class="paragraph"><p>This option may only occur once, in the global server configuration.
|
1238
1542
|
The default value is <em>300</em>.</p></div>
|
1239
|
-
<
|
1240
|
-
<
|
1241
|
-
|
1543
|
+
<h4 id="PassengerMaxRequests">5.12.4. PassengerMaxRequests <integer></h4>
|
1544
|
+
<div class="paragraph"><p>The maximum number of requests an application instance will process. After
|
1545
|
+
serving that many requests, the application instance will be shut down and
|
1546
|
+
Phusion Passenger will restart it. A value of 0 means that there is no maximum:
|
1547
|
+
an application instance will thus be shut down when its idle timeout has been
|
1548
|
+
reached.</p></div>
|
1549
|
+
<div class="paragraph"><p>This option is useful if your application is leaking memory. By shutting
|
1550
|
+
it down after a certain number of requests, all of its memory is guaranteed
|
1551
|
+
to be freed by the operating system.</p></div>
|
1552
|
+
<div class="paragraph"><p>This option may occur in the following places:</p></div>
|
1553
|
+
<div class="ulist"><ul>
|
1554
|
+
<li>
|
1555
|
+
<p>
|
1556
|
+
In the global server configuration.
|
1557
|
+
</p>
|
1558
|
+
</li>
|
1559
|
+
<li>
|
1560
|
+
<p>
|
1561
|
+
In a virtual host configuration block.
|
1562
|
+
</p>
|
1563
|
+
</li>
|
1564
|
+
<li>
|
1565
|
+
<p>
|
1566
|
+
In a <tt><Directory></tt> or <tt><Location></tt> block.
|
1567
|
+
</p>
|
1568
|
+
</li>
|
1569
|
+
<li>
|
1570
|
+
<p>
|
1571
|
+
In <em>.htaccess</em>, if <tt>AllowOverride Limits</tt> is on.
|
1572
|
+
</p>
|
1573
|
+
</li>
|
1574
|
+
</ul></div>
|
1575
|
+
<div class="paragraph"><p>In each place, it may be specified at most once. The default value is <em>0</em>.</p></div>
|
1576
|
+
<div class="admonitionblock">
|
1577
|
+
<table><tr>
|
1578
|
+
<td class="icon">
|
1579
|
+
<img src="./images/icons/caution.png" alt="Caution" />
|
1580
|
+
</td>
|
1581
|
+
<td class="content">
|
1582
|
+
<div class="paragraph"><p>The <a href="#PassengerMaxRequests">PassengerMaxRequests</a> directive should be considered
|
1583
|
+
as a workaround for misbehaving applications. It is advised that you fix the
|
1584
|
+
problem in your application rather than relying on these directives as a
|
1585
|
+
measure to avoid memory leaks.</p></div>
|
1586
|
+
</td>
|
1587
|
+
</tr></table>
|
1588
|
+
</div>
|
1589
|
+
<h4 id="_passengerstatthrottlerate_lt_integer_gt">5.12.5. PassengerStatThrottleRate <integer></h4>
|
1590
|
+
<div class="paragraph"><p>By default, Phusion Passenger performs several filesystem checks (or, in
|
1591
|
+
programmers jargon, <em>stat() calls</em>) each time a request is processed:</p></div>
|
1592
|
+
<div class="ulist"><ul>
|
1593
|
+
<li>
|
1594
|
+
<p>
|
1595
|
+
It checks whether <em>config/environment.rb</em>, <em>config.ru</em> or <em>passenger_wsgi.py</em>
|
1596
|
+
is present, in order to autodetect Rails, Rack and WSGI applications.
|
1597
|
+
</p>
|
1598
|
+
</li>
|
1599
|
+
<li>
|
1600
|
+
<p>
|
1601
|
+
It checks whether <em>restart.txt</em> has changed or whether <em>always_restart.txt</em>
|
1602
|
+
exists, in order to determine whether the application should be restarted.
|
1603
|
+
</p>
|
1604
|
+
</li>
|
1605
|
+
</ul></div>
|
1606
|
+
<div class="paragraph"><p>On some systems where disk I/O is expensive, e.g. systems where the harddisk is
|
1607
|
+
already being heavily loaded, or systems where applications are stored on NFS
|
1608
|
+
shares, these filesystem checks can incur a lot of overhead.</p></div>
|
1609
|
+
<div class="paragraph"><p>You can decrease or almost entirely eliminate this overhead by setting
|
1610
|
+
<em>PassengerStatThrottleRate</em>. Setting this option to a value of <em>x</em> means that
|
1611
|
+
the above list of filesystem checks will be performed at most once every <em>x</em>
|
1612
|
+
seconds. Setting it to a value of <em>0</em> means that no throttling will take place,
|
1613
|
+
or in other words, that the above list of filesystem checks will be performed on
|
1614
|
+
every request.</p></div>
|
1615
|
+
<div class="paragraph"><p>This option may occur in the following places:</p></div>
|
1616
|
+
<div class="ulist"><ul>
|
1617
|
+
<li>
|
1618
|
+
<p>
|
1619
|
+
In the global server configuration.
|
1620
|
+
</p>
|
1621
|
+
</li>
|
1622
|
+
<li>
|
1623
|
+
<p>
|
1624
|
+
In a virtual host configuration block.
|
1625
|
+
</p>
|
1626
|
+
</li>
|
1627
|
+
<li>
|
1628
|
+
<p>
|
1629
|
+
In a <tt><Directory></tt> or <tt><Location></tt> block.
|
1630
|
+
</p>
|
1631
|
+
</li>
|
1632
|
+
<li>
|
1633
|
+
<p>
|
1634
|
+
In <em>.htaccess</em>, if <tt>AllowOverride Limits</tt> is on.
|
1635
|
+
</p>
|
1636
|
+
</li>
|
1637
|
+
</ul></div>
|
1638
|
+
<div class="paragraph"><p>In each place, it may be specified at most once. The default value is <em>0</em>.</p></div>
|
1639
|
+
<h3 id="_ruby_on_rails_specific_options">5.13. Ruby on Rails-specific options</h3><div style="clear:left"></div>
|
1640
|
+
<h4 id="_railsautodetect_lt_on_off_gt">5.13.1. RailsAutoDetect <on|off></h4>
|
1641
|
+
<div class="paragraph"><p>Whether Phusion Passenger should automatically detect whether a virtual host’s
|
1242
1642
|
document root is a Ruby on Rails application. The default is <em>on</em>.</p></div>
|
1243
|
-
<div class="
|
1643
|
+
<div class="paragraph"><p>This option may occur in the global server configuration or in a virtual host
|
1244
1644
|
configuration block.</p></div>
|
1245
|
-
<div class="
|
1645
|
+
<div class="paragraph"><p>For example, consider the following configuration:</p></div>
|
1246
1646
|
<div class="listingblock">
|
1247
1647
|
<div class="content">
|
1248
1648
|
<pre><tt>RailsAutoDetect off
|
@@ -1251,10 +1651,10 @@ configuration block.</p></div>
|
|
1251
1651
|
DocumentRoot /webapps/mycook/public
|
1252
1652
|
</VirtualHost></tt></pre>
|
1253
1653
|
</div></div>
|
1254
|
-
<div class="
|
1654
|
+
<div class="paragraph"><p>If one goes to <em>http://www.mycook.com/</em>, the visitor will see the contents of
|
1255
1655
|
the <em>/webapps/mycook/public</em> folder, instead of the output of the Ruby on Rails
|
1256
1656
|
application.</p></div>
|
1257
|
-
<div class="
|
1657
|
+
<div class="paragraph"><p>It is possible to explicitly specify that the host is a Ruby on Rails
|
1258
1658
|
application by using the <a href="#RailsBaseURI">RailsBaseURI</a> configuration option:</p></div>
|
1259
1659
|
<div class="listingblock">
|
1260
1660
|
<div class="content">
|
@@ -1265,23 +1665,61 @@ application by using the <a href="#RailsBaseURI">RailsBaseURI</a> configuration
|
|
1265
1665
|
RailsBaseURI / # This line has been added.
|
1266
1666
|
</VirtualHost></tt></pre>
|
1267
1667
|
</div></div>
|
1268
|
-
<h4 id="RailsBaseURI">5.
|
1269
|
-
<div class="
|
1668
|
+
<h4 id="RailsBaseURI">5.13.2. RailsBaseURI <uri></h4>
|
1669
|
+
<div class="paragraph"><p>Used to specify that the given URI is a Rails application. See
|
1270
1670
|
<a href="#deploying_rails_to_sub_uri">Deploying Rails to a sub URI</a> for an example.</p></div>
|
1271
|
-
<div class="
|
1671
|
+
<div class="paragraph"><p>It is allowed to specify this option multiple times. Do this to deploy multiple
|
1272
1672
|
Rails applications in different sub-URIs under the same virtual host.</p></div>
|
1273
|
-
<div class="
|
1274
|
-
|
1275
|
-
<
|
1276
|
-
<
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1280
|
-
<
|
1281
|
-
<
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1673
|
+
<div class="paragraph"><p>This option may occur in the following places:</p></div>
|
1674
|
+
<div class="ulist"><ul>
|
1675
|
+
<li>
|
1676
|
+
<p>
|
1677
|
+
In the global server configuration.
|
1678
|
+
</p>
|
1679
|
+
</li>
|
1680
|
+
<li>
|
1681
|
+
<p>
|
1682
|
+
In a virtual host configuration block.
|
1683
|
+
</p>
|
1684
|
+
</li>
|
1685
|
+
<li>
|
1686
|
+
<p>
|
1687
|
+
In a <tt><Directory></tt> or <tt><Location></tt> block.
|
1688
|
+
</p>
|
1689
|
+
</li>
|
1690
|
+
<li>
|
1691
|
+
<p>
|
1692
|
+
In <em>.htaccess</em>, if <tt>AllowOverride Options</tt> is on.
|
1693
|
+
</p>
|
1694
|
+
</li>
|
1695
|
+
</ul></div>
|
1696
|
+
<h4 id="rails_env">5.13.3. RailsEnv <string></h4>
|
1697
|
+
<div class="paragraph"><p>This option allows one to specify the default <tt>RAILS_ENV</tt> value.</p></div>
|
1698
|
+
<div class="paragraph"><p>This option may occur in the following places:</p></div>
|
1699
|
+
<div class="ulist"><ul>
|
1700
|
+
<li>
|
1701
|
+
<p>
|
1702
|
+
In the global server configuration.
|
1703
|
+
</p>
|
1704
|
+
</li>
|
1705
|
+
<li>
|
1706
|
+
<p>
|
1707
|
+
In a virtual host configuration block.
|
1708
|
+
</p>
|
1709
|
+
</li>
|
1710
|
+
<li>
|
1711
|
+
<p>
|
1712
|
+
In a <tt><Directory></tt> or <tt><Location></tt> block.
|
1713
|
+
</p>
|
1714
|
+
</li>
|
1715
|
+
<li>
|
1716
|
+
<p>
|
1717
|
+
In <em>.htaccess</em>, if <tt>AllowOverride Options</tt> is on.
|
1718
|
+
</p>
|
1719
|
+
</li>
|
1720
|
+
</ul></div>
|
1721
|
+
<div class="paragraph"><p>In each place, it may be specified at most once. The default value is <em>production</em>.</p></div>
|
1722
|
+
<h4 id="RailsSpawnMethod">5.13.4. RailsSpawnMethod <string></h4>
|
1285
1723
|
<div class="admonitionblock">
|
1286
1724
|
<table><tr>
|
1287
1725
|
<td class="icon">
|
@@ -1289,64 +1727,128 @@ configuration block. The default value is <em>production</em>.</p></div>
|
|
1289
1727
|
</td>
|
1290
1728
|
<td class="content">
|
1291
1729
|
<div class="title">"What spawn method should I use?"</div>
|
1292
|
-
<div class="
|
1293
|
-
understand it, as it
|
1730
|
+
<div class="paragraph"><p>This subsection attempts to describe spawn methods, but it’s okay if you don’t (want to)
|
1731
|
+
understand it, as it’s mostly a technical detail. You can basically follow this rule of thumb:</p></div>
|
1294
1732
|
<div class="sidebarblock">
|
1295
1733
|
<div class="sidebar-content">
|
1296
|
-
<div class="
|
1297
|
-
<tt>RailsSpawnMethod</tt> to <em>conservative</em>. Otherwise, leave it at <em>smart</em> (the default).</p></div>
|
1734
|
+
<div class="paragraph"><p>If your application works on Mongrel, but not on Phusion Passenger, then set
|
1735
|
+
<tt>RailsSpawnMethod</tt> to <em>conservative</em>. Otherwise, leave it at <em>smart-lv2</em> (the default).</p></div>
|
1298
1736
|
</div></div>
|
1299
|
-
<div class="
|
1300
|
-
many benefits.</p></div>
|
1737
|
+
<div class="paragraph"><p>However, we do recommend you to try to understand it. The <em>smart</em> and <em>smart-lv2</em> spawn
|
1738
|
+
methods bring many benefits.</p></div>
|
1301
1739
|
</td>
|
1302
1740
|
</tr></table>
|
1303
1741
|
</div>
|
1304
|
-
<div class="
|
1742
|
+
<div class="paragraph"><p>Internally, Phusion Passenger spawns multiple Ruby on Rails processes in order to handle
|
1305
1743
|
requests. But there are multiple ways with which processes can be spawned, each having
|
1306
1744
|
its own set of pros and cons. Supported spawn methods are:</p></div>
|
1307
|
-
<div class="
|
1308
|
-
<dt>
|
1745
|
+
<div class="dlist"><dl>
|
1746
|
+
<dt class="hdlist1">
|
1309
1747
|
<em>smart</em>
|
1310
1748
|
</dt>
|
1311
1749
|
<dd>
|
1312
1750
|
<p>
|
1313
1751
|
When this spawn method is used, Phusion Passenger will attempt to cache Ruby on Rails
|
1314
|
-
framework code and application code for a limited period of time.
|
1752
|
+
framework code and application code for a limited period of time. Please read
|
1753
|
+
<a href="#spawning_methods_explained">Spawning methods explained</a> for a more detailed
|
1754
|
+
explanation of what smart spawning exactly does.
|
1315
1755
|
</p>
|
1316
|
-
<div class="
|
1756
|
+
<div class="paragraph"><p><strong>Pros:</strong>
|
1317
1757
|
This can significantly decrease spawn time (by as much as 90%). And, when Ruby Enterprise
|
1318
1758
|
Edition is used, <a href="#reducing_memory_usage">memory usage can be reduced by 33% on average</a>.</p></div>
|
1319
|
-
<div class="
|
1759
|
+
<div class="paragraph"><p><strong>Cons:</strong>
|
1320
1760
|
Some Ruby on Rails applications and libraries are not compatible with smart spawning.
|
1321
|
-
If that
|
1761
|
+
If that’s the case for your application, then you should use <em>conservative</em> as
|
1322
1762
|
spawning method.</p></div>
|
1323
1763
|
</dd>
|
1324
|
-
<dt>
|
1764
|
+
<dt class="hdlist1">
|
1765
|
+
<em>smart-lv2</em>
|
1766
|
+
</dt>
|
1767
|
+
<dd>
|
1768
|
+
<p>
|
1769
|
+
This spawning method is similar to <em>smart</em> but it skips the framework spawner
|
1770
|
+
and uses the application spawner directly. This means the framework code is not
|
1771
|
+
cached between multiple applications, although it is still cached within
|
1772
|
+
instances of the same application. Please read
|
1773
|
+
<a href="#spawning_methods_explained">Spawning methods explained</a> for a more detailed
|
1774
|
+
explanation of what smart-lv2 spawning exactly does.
|
1775
|
+
</p>
|
1776
|
+
<div class="paragraph"><p><strong>Pros:</strong> It is compatible with a larger number of applications when compared to
|
1777
|
+
the <em>smart</em> method, and still performs some caching.</p></div>
|
1778
|
+
<div class="paragraph"><p><strong>Cons:</strong> It is slower than smart spawning if you have many applications which
|
1779
|
+
use the same framework version. It is therefore advised that shared hosts use the
|
1780
|
+
<em>smart</em> method instead.</p></div>
|
1781
|
+
</dd>
|
1782
|
+
<dt class="hdlist1">
|
1325
1783
|
<em>conservative</em>
|
1326
1784
|
</dt>
|
1327
1785
|
<dd>
|
1328
1786
|
<p>
|
1329
|
-
This spawning method is similar to the one used in Mongrel Cluster. It does not
|
1330
|
-
any code caching at all.
|
1787
|
+
This spawning method is similar to the one used in Mongrel Cluster. It does not
|
1788
|
+
perform any code caching at all. Please read
|
1789
|
+
<a href="#spawning_methods_explained">Spawning methods explained</a> for a more detailed
|
1790
|
+
explanation of what conservative spawning exactly does.
|
1331
1791
|
</p>
|
1332
|
-
<div class="
|
1792
|
+
<div class="paragraph"><p><strong>Pros:</strong>
|
1333
1793
|
Conservative spawning is guaranteed to be compatible with all Rails applications
|
1334
1794
|
and libraries.</p></div>
|
1335
|
-
<div class="
|
1795
|
+
<div class="paragraph"><p><strong>Cons:</strong>
|
1336
1796
|
Much slower than smart spawning. Every spawn action will be equally slow, though no slower than
|
1337
1797
|
the startup time of a single server in Mongrel Cluster. Conservative spawning will also
|
1338
|
-
render <a href="#reducing_memory_usage">Ruby Enterprise Edition
|
1798
|
+
render <a href="#reducing_memory_usage">Ruby Enterprise Edition’s memory reduction technology</a> useless.</p></div>
|
1339
1799
|
</dd>
|
1340
1800
|
</dl></div>
|
1341
|
-
<div class="
|
1342
|
-
|
1343
|
-
<
|
1344
|
-
<
|
1345
|
-
|
1801
|
+
<div class="paragraph"><p>This option may occur in the following places:</p></div>
|
1802
|
+
<div class="ulist"><ul>
|
1803
|
+
<li>
|
1804
|
+
<p>
|
1805
|
+
In the global server configuration.
|
1806
|
+
</p>
|
1807
|
+
</li>
|
1808
|
+
<li>
|
1809
|
+
<p>
|
1810
|
+
In a virtual host configuration block.
|
1811
|
+
</p>
|
1812
|
+
</li>
|
1813
|
+
</ul></div>
|
1814
|
+
<div class="paragraph"><p>In each place, it may be specified at most once. The default value is <em>smart-lv2</em>.</p></div>
|
1815
|
+
<h4 id="_railsframeworkspawneridletime_lt_integer_gt">5.13.5. RailsFrameworkSpawnerIdleTime <integer></h4>
|
1816
|
+
<div class="paragraph"><p>The FrameworkSpawner server (explained in <a href="#spawning_methods_explained">Spawning methods explained</a>) has an idle timeout, just like the backend processes spawned by
|
1817
|
+
Phusion Passenger do. That is, it will automatically shutdown if it hasn’t done
|
1818
|
+
anything for a given period.</p></div>
|
1819
|
+
<div class="paragraph"><p>This option allows you to set the FrameworkSpawner server’s idle timeout, in
|
1820
|
+
seconds. A value of <em>0</em> means that it should never idle timeout.</p></div>
|
1821
|
+
<div class="paragraph"><p>Setting a higher value will mean that the FrameworkSpawner server is kept around
|
1822
|
+
longer, which may slightly increase memory usage. But as long as the
|
1823
|
+
FrameworkSpawner server is running, the time to spawn a Ruby on Rails backend
|
1824
|
+
process only takes about 40% of the time that is normally needed, assuming that
|
1825
|
+
you’re using the <em>smart</em> <a href="#RailsSpawnMethod">spawning method</a>. So if your
|
1826
|
+
system has enough memory, is it recommended that you set this option to a high
|
1827
|
+
value or to <em>0</em>.</p></div>
|
1828
|
+
<div class="paragraph"><p>This option may only occur in the global server configuration, and may occur at
|
1829
|
+
most once. The default value is <em>1800</em> (30 minutes).</p></div>
|
1830
|
+
<h4 id="_railsappspawneridletime_lt_integer_gt">5.13.6. RailsAppSpawnerIdleTime <integer></h4>
|
1831
|
+
<div class="paragraph"><p>The ApplicationSpawner server (explained in <a href="#spawning_methods_explained">Spawning methods explained</a>) has an idle timeout, just like the backend processes spawned by
|
1832
|
+
Phusion Passenger do. That is, it will automatically shutdown if it hasn’t done
|
1833
|
+
anything for a given period.</p></div>
|
1834
|
+
<div class="paragraph"><p>This option allows you to set the ApplicationSpawner server’s idle timeout, in
|
1835
|
+
seconds. A value of <em>0</em> means that it should never idle timeout.</p></div>
|
1836
|
+
<div class="paragraph"><p>Setting a higher value will mean that the ApplicationSpawner server is kept around
|
1837
|
+
longer, which may slightly increase memory usage. But as long as the
|
1838
|
+
ApplicationSpawner server is running, the time to spawn a Ruby on Rails backend
|
1839
|
+
process only takes about 10% of the time that is normally needed, assuming that
|
1840
|
+
you’re using the <em>smart</em> or <em>smart-lv2</em> <a href="#RailsSpawnMethod">spawning method</a>. So if your
|
1841
|
+
system has enough memory, is it recommended that you set this option to a high
|
1842
|
+
value or to <em>0</em>.</p></div>
|
1843
|
+
<div class="paragraph"><p>This option may only occur in the global server configuration, and may occur at
|
1844
|
+
most once. The default value is <em>600</em> (10 minutes).</p></div>
|
1845
|
+
<h3 id="_rack_specific_options">5.14. Rack-specific options</h3><div style="clear:left"></div>
|
1846
|
+
<h4 id="_rackautodetect_lt_on_off_gt">5.14.1. RackAutoDetect <on|off></h4>
|
1847
|
+
<div class="paragraph"><p>Whether Phusion Passenger should automatically detect whether a virtual host’s
|
1346
1848
|
document root is a Rack application. The default is <em>on</em>.</p></div>
|
1347
|
-
<div class="
|
1849
|
+
<div class="paragraph"><p>This option may occur in the global server configuration or in a virtual host
|
1348
1850
|
configuration block.</p></div>
|
1349
|
-
<div class="
|
1851
|
+
<div class="paragraph"><p>For example, consider the following configuration:</p></div>
|
1350
1852
|
<div class="listingblock">
|
1351
1853
|
<div class="content">
|
1352
1854
|
<pre><tt>RackAutoDetect off
|
@@ -1355,10 +1857,10 @@ configuration block.</p></div>
|
|
1355
1857
|
DocumentRoot /webapps/my_rack_app/public
|
1356
1858
|
</VirtualHost></tt></pre>
|
1357
1859
|
</div></div>
|
1358
|
-
<div class="
|
1860
|
+
<div class="paragraph"><p>If one goes to <em>http://www.rackapp.com/</em>, the visitor will see the contents of
|
1359
1861
|
the <em>/webapps/my_rack_app/public</em> folder, instead of the output of the Rack
|
1360
1862
|
application.</p></div>
|
1361
|
-
<div class="
|
1863
|
+
<div class="paragraph"><p>It is possible to explicitly specify that the host is a Rack
|
1362
1864
|
application by using the <a href="#RackBaseURI">RackBaseURI</a> configuration option:</p></div>
|
1363
1865
|
<div class="listingblock">
|
1364
1866
|
<div class="content">
|
@@ -1369,37 +1871,82 @@ application by using the <a href="#RackBaseURI">RackBaseURI</a> configuration op
|
|
1369
1871
|
RackBaseURI / # This line was added
|
1370
1872
|
</VirtualHost></tt></pre>
|
1371
1873
|
</div></div>
|
1372
|
-
<h4 id="RackBaseURI">5.
|
1373
|
-
<div class="
|
1874
|
+
<h4 id="RackBaseURI">5.14.2. RackBaseURI <uri></h4>
|
1875
|
+
<div class="paragraph"><p>Used to specify that the given URI is a Rack application. See
|
1374
1876
|
<a href="#deploying_rack_to_sub_uri">Deploying Rack to a sub URI</a> for an example.</p></div>
|
1375
|
-
<div class="
|
1877
|
+
<div class="paragraph"><p>It is allowed to specify this option multiple times. Do this to deploy multiple
|
1376
1878
|
Rack applications in different sub-URIs under the same virtual host.</p></div>
|
1377
|
-
<div class="
|
1378
|
-
|
1379
|
-
<
|
1380
|
-
<
|
1879
|
+
<div class="paragraph"><p>This option may occur in the following places:</p></div>
|
1880
|
+
<div class="ulist"><ul>
|
1881
|
+
<li>
|
1882
|
+
<p>
|
1883
|
+
In the global server configuration.
|
1884
|
+
</p>
|
1885
|
+
</li>
|
1886
|
+
<li>
|
1887
|
+
<p>
|
1888
|
+
In a virtual host configuration block.
|
1889
|
+
</p>
|
1890
|
+
</li>
|
1891
|
+
<li>
|
1892
|
+
<p>
|
1893
|
+
In a <tt><Directory></tt> or <tt><Location></tt> block.
|
1894
|
+
</p>
|
1895
|
+
</li>
|
1896
|
+
<li>
|
1897
|
+
<p>
|
1898
|
+
In <em>.htaccess</em>, if <tt>AllowOverride Options</tt> is on.
|
1899
|
+
</p>
|
1900
|
+
</li>
|
1901
|
+
</ul></div>
|
1902
|
+
<h4 id="rack_env">5.14.3. RackEnv <string></h4>
|
1903
|
+
<div class="paragraph"><p>The given value will be accessible in Rack applications in the <tt>RACK_ENV</tt>
|
1381
1904
|
environment variable. This allows one to define the environment in which
|
1382
1905
|
Rack applications are run, very similar to <tt>RAILS_ENV</tt>.</p></div>
|
1383
|
-
<div class="
|
1384
|
-
|
1385
|
-
<
|
1386
|
-
<
|
1906
|
+
<div class="paragraph"><p>This option may occur in the following places:</p></div>
|
1907
|
+
<div class="ulist"><ul>
|
1908
|
+
<li>
|
1909
|
+
<p>
|
1910
|
+
In the global server configuration.
|
1911
|
+
</p>
|
1912
|
+
</li>
|
1913
|
+
<li>
|
1914
|
+
<p>
|
1915
|
+
In a virtual host configuration block.
|
1916
|
+
</p>
|
1917
|
+
</li>
|
1918
|
+
<li>
|
1919
|
+
<p>
|
1920
|
+
In a <tt><Directory></tt> or <tt><Location></tt> block.
|
1921
|
+
</p>
|
1922
|
+
</li>
|
1923
|
+
<li>
|
1924
|
+
<p>
|
1925
|
+
In <em>.htaccess</em>, if <tt>AllowOverride Options</tt> is on.
|
1926
|
+
</p>
|
1927
|
+
</li>
|
1928
|
+
</ul></div>
|
1929
|
+
<div class="paragraph"><p>In each place, it may be specified at most once. The default value is <em>production</em>.</p></div>
|
1930
|
+
<h3 id="_deprecated_options">5.15. Deprecated options</h3><div style="clear:left"></div>
|
1931
|
+
<div class="paragraph"><p>The following options have been deprecated, but are still supported for backwards
|
1387
1932
|
compatibility reasons.</p></div>
|
1388
|
-
<h4 id="_railsruby">5.
|
1389
|
-
<div class="
|
1390
|
-
<h4 id="_railsuserswitching">5.
|
1391
|
-
<div class="
|
1392
|
-
<h4 id="_railsdefaultuser">5.
|
1393
|
-
<div class="
|
1933
|
+
<h4 id="_railsruby">5.15.1. RailsRuby</h4>
|
1934
|
+
<div class="paragraph"><p>Deprecated in favor of <a href="#PassengerRuby">PassengerRuby</a>.</p></div>
|
1935
|
+
<h4 id="_railsuserswitching">5.15.2. RailsUserSwitching</h4>
|
1936
|
+
<div class="paragraph"><p>Deprecated in favor of <a href="#PassengerUserSwitching">PassengerUserSwitching</a>.</p></div>
|
1937
|
+
<h4 id="_railsdefaultuser">5.15.3. RailsDefaultUser</h4>
|
1938
|
+
<div class="paragraph"><p>Deprecated in favor of <a href="#PassengerDefaultUser">PassengerDefaultUser</a>.</p></div>
|
1939
|
+
<h4 id="_railsallowmodrewrite">5.15.4. RailsAllowModRewrite</h4>
|
1940
|
+
<div class="paragraph"><p>This option doesn’t do anything anymore in recent versions of Phusion Passenger.</p></div>
|
1394
1941
|
</div>
|
1395
1942
|
<h2 id="_troubleshooting">6. Troubleshooting</h2>
|
1396
1943
|
<div class="sectionbody">
|
1397
1944
|
<h3 id="_operating_system_specific_problems">6.1. Operating system-specific problems</h3><div style="clear:left"></div>
|
1398
|
-
<h4 id="
|
1945
|
+
<h4 id="_macos_x_the_installer_cannot_locate_mamp_8217_s_apache">6.1.1. MacOS X: The installer cannot locate MAMP’s Apache</h4>
|
1399
1946
|
<div class="sidebarblock">
|
1400
1947
|
<div class="sidebar-content">
|
1401
1948
|
<div class="sidebar-title">Symptoms</div>
|
1402
|
-
<div class="
|
1949
|
+
<div class="paragraph"><p>The installer finds Apache 2 development headers at <tt>/Applications/MAMP/Library/bin/apxs</tt>.
|
1403
1950
|
However, Apache cannot be found. The installer also outputs the following error:</p></div>
|
1404
1951
|
<div class="listingblock">
|
1405
1952
|
<div class="content">
|
@@ -1407,26 +1954,26 @@ However, Apache cannot be found. The installer also outputs the following error:
|
|
1407
1954
|
No such file or directory at /Applications/MAMP/Library/bin/apxs line 218.</tt></pre>
|
1408
1955
|
</div></div>
|
1409
1956
|
</div></div>
|
1410
|
-
<div class="
|
1957
|
+
<div class="paragraph"><p>Your MAMP installation seems to be broken. In particular, <em>config_vars.mk</em> is missing.
|
1411
1958
|
Please read <a href="http://forum.mamp.info/viewtopic.php?t=1866">this forum topic</a> to learn how
|
1412
1959
|
to fix this problem.</p></div>
|
1413
|
-
<div class="
|
1960
|
+
<div class="paragraph"><p>See also <a href="http://code.google.com/p/phusion-passenger/issues/detail?id=12">this bug report</a>.</p></div>
|
1414
1961
|
<h3 id="_problems_during_installation">6.2. Problems during installation</h3><div style="clear:left"></div>
|
1415
|
-
<h4 id="installing_ruby_dev">6.2.1. Ruby development headers aren
|
1962
|
+
<h4 id="installing_ruby_dev">6.2.1. Ruby development headers aren’t installed</h4>
|
1416
1963
|
<div class="sidebarblock">
|
1417
1964
|
<div class="sidebar-content">
|
1418
1965
|
<div class="sidebar-title">Symptoms</div>
|
1419
|
-
<div class="
|
1420
|
-
<div class="
|
1966
|
+
<div class="paragraph"><p>Installing Phusion Passenger fails because of one of the following errors:</p></div>
|
1967
|
+
<div class="ulist"><ul>
|
1421
1968
|
<li>
|
1422
1969
|
<p>
|
1423
1970
|
The Phusion Passenger installer tells you that the Ruby development headers
|
1424
|
-
aren
|
1971
|
+
aren’t installed.
|
1425
1972
|
</p>
|
1426
1973
|
</li>
|
1427
1974
|
<li>
|
1428
1975
|
<p>
|
1429
|
-
The error message “<em>no such file to load
|
1976
|
+
The error message “<em>no such file to load — mkmf”</em> occurs.
|
1430
1977
|
</p>
|
1431
1978
|
</li>
|
1432
1979
|
<li>
|
@@ -1436,13 +1983,13 @@ The error message “<em>ruby.h: No such file or directory”</em> occur
|
|
1436
1983
|
</li>
|
1437
1984
|
</ul></div>
|
1438
1985
|
</div></div>
|
1439
|
-
<div class="
|
1986
|
+
<div class="paragraph"><p>Phusion Passenger makes use of a native extension, so the Ruby development headers
|
1440
1987
|
must be installed. On most Linux systems, Ruby and the Ruby development headers
|
1441
1988
|
are contained in separate packages, so having Ruby installed does not
|
1442
1989
|
automatically imply having the development headers installed.</p></div>
|
1443
|
-
<div class="
|
1444
|
-
<div class="
|
1445
|
-
<dt>
|
1990
|
+
<div class="paragraph"><p>Here’s how you can install the development headers:</p></div>
|
1991
|
+
<div class="dlist"><dl>
|
1992
|
+
<dt class="hdlist1">
|
1446
1993
|
Ubuntu/Debian
|
1447
1994
|
</dt>
|
1448
1995
|
<dd>
|
@@ -1454,7 +2001,7 @@ Ubuntu/Debian
|
|
1454
2001
|
<pre><tt>sudo apt-get install ruby1.8-dev</tt></pre>
|
1455
2002
|
</div></div>
|
1456
2003
|
</dd>
|
1457
|
-
<dt>
|
2004
|
+
<dt class="hdlist1">
|
1458
2005
|
Fedora/CentOS/RHEL
|
1459
2006
|
</dt>
|
1460
2007
|
<dd>
|
@@ -1466,7 +2013,7 @@ Fedora/CentOS/RHEL
|
|
1466
2013
|
<pre><tt>su -c 'yum install ruby-devel'</tt></pre>
|
1467
2014
|
</div></div>
|
1468
2015
|
</dd>
|
1469
|
-
<dt>
|
2016
|
+
<dt class="hdlist1">
|
1470
2017
|
FreeBSD
|
1471
2018
|
</dt>
|
1472
2019
|
<dd>
|
@@ -1475,7 +2022,7 @@ FreeBSD
|
|
1475
2022
|
please install Ruby from source.
|
1476
2023
|
</p>
|
1477
2024
|
</dd>
|
1478
|
-
<dt>
|
2025
|
+
<dt class="hdlist1">
|
1479
2026
|
MacOS X
|
1480
2027
|
</dt>
|
1481
2028
|
<dd>
|
@@ -1483,12 +2030,12 @@ MacOS X
|
|
1483
2030
|
Please install Ruby from source.
|
1484
2031
|
</p>
|
1485
2032
|
</dd>
|
1486
|
-
<dt>
|
2033
|
+
<dt class="hdlist1">
|
1487
2034
|
Other operating systems
|
1488
2035
|
</dt>
|
1489
2036
|
<dd>
|
1490
2037
|
<p>
|
1491
|
-
Please consult your operating system
|
2038
|
+
Please consult your operating system’s native package database.
|
1492
2039
|
There should be a package containing the Ruby development headers.
|
1493
2040
|
If that fails, please install Ruby from source.
|
1494
2041
|
</p>
|
@@ -1499,34 +2046,34 @@ Other operating systems
|
|
1499
2046
|
<td class="icon">
|
1500
2047
|
<img src="./images/icons/note.png" alt="Note" />
|
1501
2048
|
</td>
|
1502
|
-
<td class="content">If you
|
2049
|
+
<td class="content">If you’ve installed a new Ruby version (i.e. your system now contains
|
1503
2050
|
multiple Ruby installations), then you will need to tell Phusion Passenger
|
1504
2051
|
which Ruby installation you want to use. Please read
|
1505
2052
|
<a href="#specifying_ruby_installation">Specifying the correct Ruby installation</a>.</td>
|
1506
2053
|
</tr></table>
|
1507
2054
|
</div>
|
1508
|
-
<h4 id="
|
2055
|
+
<h4 id="_apache_development_headers_aren_8217_t_installed">6.2.2. Apache development headers aren’t installed</h4>
|
1509
2056
|
<div class="sidebarblock">
|
1510
2057
|
<div class="sidebar-content">
|
1511
2058
|
<div class="sidebar-title">Symptoms</div>
|
1512
|
-
<div class="
|
1513
|
-
<div class="
|
2059
|
+
<div class="paragraph"><p>Installing Phusion Passenger fails because of one of the following errors:</p></div>
|
2060
|
+
<div class="ulist"><ul>
|
1514
2061
|
<li>
|
1515
2062
|
<p>
|
1516
|
-
The installer says that the Apache development headers aren
|
2063
|
+
The installer says that the Apache development headers aren’t installed.
|
1517
2064
|
</p>
|
1518
2065
|
</li>
|
1519
2066
|
<li>
|
1520
2067
|
<p>
|
1521
2068
|
The error message “<em>httpd.h: No such file or directory”</em> occurs.
|
1522
2069
|
</p>
|
1523
|
-
<div class="
|
2070
|
+
<div class="paragraph"><p>(Instead of <em>httpd.h</em>, the message might also be <em>http_config.h</em> or something
|
1524
2071
|
else similar to <em>http_*.h</em>.)</p></div>
|
1525
2072
|
</li>
|
1526
2073
|
</ul></div>
|
1527
2074
|
</div></div>
|
1528
|
-
<div class="
|
1529
|
-
<dt>
|
2075
|
+
<div class="dlist"><dl>
|
2076
|
+
<dt class="hdlist1">
|
1530
2077
|
Ubuntu
|
1531
2078
|
</dt>
|
1532
2079
|
<dd>
|
@@ -1538,7 +2085,7 @@ Ubuntu
|
|
1538
2085
|
<pre><tt>sudo apt-get install apache2-prefork-dev</tt></pre>
|
1539
2086
|
</div></div>
|
1540
2087
|
</dd>
|
1541
|
-
<dt>
|
2088
|
+
<dt class="hdlist1">
|
1542
2089
|
Debian
|
1543
2090
|
</dt>
|
1544
2091
|
<dd>
|
@@ -1550,7 +2097,7 @@ Debian
|
|
1550
2097
|
<pre><tt>sudo apt-get install apache2-dev</tt></pre>
|
1551
2098
|
</div></div>
|
1552
2099
|
</dd>
|
1553
|
-
<dt>
|
2100
|
+
<dt class="hdlist1">
|
1554
2101
|
Fedora/CentOS/RHEL
|
1555
2102
|
</dt>
|
1556
2103
|
<dd>
|
@@ -1562,7 +2109,7 @@ Fedora/CentOS/RHEL
|
|
1562
2109
|
<pre><tt>su -c 'yum install httpd-devel'</tt></pre>
|
1563
2110
|
</div></div>
|
1564
2111
|
</dd>
|
1565
|
-
<dt>
|
2112
|
+
<dt class="hdlist1">
|
1566
2113
|
FreeBSD
|
1567
2114
|
</dt>
|
1568
2115
|
<dd>
|
@@ -1571,7 +2118,7 @@ FreeBSD
|
|
1571
2118
|
please install Apache from source.
|
1572
2119
|
</p>
|
1573
2120
|
</dd>
|
1574
|
-
<dt>
|
2121
|
+
<dt class="hdlist1">
|
1575
2122
|
MacOS X
|
1576
2123
|
</dt>
|
1577
2124
|
<dd>
|
@@ -1579,26 +2126,26 @@ MacOS X
|
|
1579
2126
|
Please install Apache from source.
|
1580
2127
|
</p>
|
1581
2128
|
</dd>
|
1582
|
-
<dt>
|
2129
|
+
<dt class="hdlist1">
|
1583
2130
|
Other operating systems
|
1584
2131
|
</dt>
|
1585
2132
|
<dd>
|
1586
2133
|
<p>
|
1587
|
-
Please consult your operating system
|
2134
|
+
Please consult your operating system’s native package database.
|
1588
2135
|
There should be a package containing the Apache development headers.
|
1589
2136
|
If that fails, please install Apache from source.
|
1590
2137
|
</p>
|
1591
2138
|
</dd>
|
1592
2139
|
</dl></div>
|
1593
|
-
<h4 id="
|
2140
|
+
<h4 id="_apr_development_headers_aren_8217_t_installed">6.2.3. APR development headers aren’t installed</h4>
|
1594
2141
|
<div class="sidebarblock">
|
1595
2142
|
<div class="sidebar-content">
|
1596
2143
|
<div class="sidebar-title">Symptoms</div>
|
1597
|
-
<div class="
|
1598
|
-
<div class="
|
2144
|
+
<div class="paragraph"><p>Installing Phusion Passenger fails because one of the following errors:</p></div>
|
2145
|
+
<div class="ulist"><ul>
|
1599
2146
|
<li>
|
1600
2147
|
<p>
|
1601
|
-
The installer tells you that APR development headers aren
|
2148
|
+
The installer tells you that APR development headers aren’t installed.
|
1602
2149
|
</p>
|
1603
2150
|
</li>
|
1604
2151
|
<li>
|
@@ -1613,8 +2160,8 @@ The error message “<em>apr_strings.h: No such file or directory”</em
|
|
1613
2160
|
</li>
|
1614
2161
|
</ul></div>
|
1615
2162
|
</div></div>
|
1616
|
-
<div class="
|
1617
|
-
<dt>
|
2163
|
+
<div class="dlist"><dl>
|
2164
|
+
<dt class="hdlist1">
|
1618
2165
|
Ubuntu
|
1619
2166
|
</dt>
|
1620
2167
|
<dd>
|
@@ -1626,7 +2173,7 @@ Ubuntu
|
|
1626
2173
|
<pre><tt>sudo apt-get install libapr1-dev</tt></pre>
|
1627
2174
|
</div></div>
|
1628
2175
|
</dd>
|
1629
|
-
<dt>
|
2176
|
+
<dt class="hdlist1">
|
1630
2177
|
Debian
|
1631
2178
|
</dt>
|
1632
2179
|
<dd>
|
@@ -1638,7 +2185,7 @@ Debian
|
|
1638
2185
|
<pre><tt>sudo apt-get install libapr1-dev</tt></pre>
|
1639
2186
|
</div></div>
|
1640
2187
|
</dd>
|
1641
|
-
<dt>
|
2188
|
+
<dt class="hdlist1">
|
1642
2189
|
Fedora/CentOS/RHEL
|
1643
2190
|
</dt>
|
1644
2191
|
<dd>
|
@@ -1650,30 +2197,30 @@ Fedora/CentOS/RHEL
|
|
1650
2197
|
<pre><tt>su -c 'yum install apr-devel'</tt></pre>
|
1651
2198
|
</div></div>
|
1652
2199
|
</dd>
|
1653
|
-
<dt>
|
2200
|
+
<dt class="hdlist1">
|
1654
2201
|
Other Linux distributions
|
1655
2202
|
</dt>
|
1656
2203
|
<dd>
|
1657
2204
|
<p>
|
1658
|
-
Please consult your distribution
|
2205
|
+
Please consult your distribution’s package database. There should be a
|
1659
2206
|
package which provides APR development headers.
|
1660
2207
|
</p>
|
1661
2208
|
</dd>
|
1662
|
-
<dt>
|
2209
|
+
<dt class="hdlist1">
|
1663
2210
|
Other operating systems
|
1664
2211
|
</dt>
|
1665
2212
|
<dd>
|
1666
2213
|
<p>
|
1667
|
-
The APR development are bundled with Apache. If the APR headers aren
|
1668
|
-
then it probably means that they have been removed after Apache
|
2214
|
+
The APR development are bundled with Apache. If the APR headers aren’t,
|
2215
|
+
then it probably means that they have been removed after Apache’s been
|
1669
2216
|
installed. Please reinstall Apache to get back the APR headers.
|
1670
2217
|
</p>
|
1671
2218
|
</dd>
|
1672
2219
|
</dl></div>
|
1673
2220
|
<h4 id="_phusion_passenger_is_using_the_wrong_apache_during_installation">6.2.4. Phusion Passenger is using the wrong Apache during installation</h4>
|
1674
|
-
<div class="
|
2221
|
+
<div class="paragraph"><p>Please <a href="#specifying_correct_apache_install">Specifying the correct Apache installation</a>, and re-run the Phusion Passenger installer.</p></div>
|
1675
2222
|
<h4 id="_phusion_passenger_is_using_the_wrong_ruby_during_installation">6.2.5. Phusion Passenger is using the wrong Ruby during installation</h4>
|
1676
|
-
<div class="
|
2223
|
+
<div class="paragraph"><p>Please <a href="#specifying_ruby_installation">Specifying the correct Ruby installation</a>, and re-run the Phusion Passenger installer.</p></div>
|
1677
2224
|
<h3 id="_problems_after_installation">6.3. Problems after installation</h3><div style="clear:left"></div>
|
1678
2225
|
<div class="admonitionblock">
|
1679
2226
|
<table><tr>
|
@@ -1682,31 +2229,31 @@ Other operating systems
|
|
1682
2229
|
</td>
|
1683
2230
|
<td class="content">
|
1684
2231
|
<div class="title">The golden tip: read your Apache error logs!</div>
|
1685
|
-
<div class="
|
1686
|
-
you
|
2232
|
+
<div class="paragraph"><p><em>mod_passenger</em> will write all errors to the Apache error log. So if
|
2233
|
+
you’re experiencing post-installation problems, please look
|
1687
2234
|
inside the Apache error logs. It will tell you what exactly went wrong.</p></div>
|
1688
2235
|
</td>
|
1689
2236
|
</tr></table>
|
1690
2237
|
</div>
|
1691
2238
|
<h4 id="_my_rails_application_works_on_mongrel_but_not_on_phusion_passenger">6.3.1. My Rails application works on Mongrel, but not on Phusion Passenger</h4>
|
1692
|
-
<div class="
|
2239
|
+
<div class="paragraph"><p>Please try setting <a href="#RailsSpawnMethod">RailsSpawnMethod</a> to <em>conservative</em>.</p></div>
|
1693
2240
|
<h4 id="_phusion_passenger_has_been_compiled_against_the_wrong_apache_installation">6.3.2. Phusion Passenger has been compiled against the wrong Apache installation</h4>
|
1694
2241
|
<div class="sidebarblock">
|
1695
2242
|
<div class="sidebar-content">
|
1696
2243
|
<div class="sidebar-title">Symptoms</div>
|
1697
|
-
<div class="
|
2244
|
+
<div class="paragraph"><p>Apache crashes during startup (after being daemonized). The Apache error log
|
1698
2245
|
says “<em>seg fault or similar nasty error detected in the parent process”</em>.</p></div>
|
1699
2246
|
</div></div>
|
1700
|
-
<div class="
|
2247
|
+
<div class="paragraph"><p>This problem is most likely to occur on MacOS X. Most OS X users have multiple
|
1701
2248
|
Apache installations on their system.</p></div>
|
1702
|
-
<div class="
|
2249
|
+
<div class="paragraph"><p>To solve this problem, please <a href="#specifying_correct_apache_install">specify the correct Apache installation</a>, and <a href="#install_passenger">reinstall Phusion Passenger</a>.</p></div>
|
1703
2250
|
<h4 id="_i_get_a_304_forbidden_error">6.3.3. I get a "304 Forbidden" error</h4>
|
1704
|
-
<div class="
|
1705
|
-
<h4 id="
|
1706
|
-
<div class="
|
1707
|
-
go through the Rails stack. There are two reasons why Apache doesn
|
2251
|
+
<div class="paragraph"><p>See next subsection.</p></div>
|
2252
|
+
<h4 id="_static_assets_such_as_images_and_stylesheets_aren_8217_t_being_displayed">6.3.4. Static assets such as images and stylesheets aren’t being displayed</h4>
|
2253
|
+
<div class="paragraph"><p>Static assets are accelerated, i.e. they are served directly by Apache and do not
|
2254
|
+
go through the Rails stack. There are two reasons why Apache doesn’t serve static
|
1708
2255
|
assets correctly:</p></div>
|
1709
|
-
<div class="olist"><ol>
|
2256
|
+
<div class="olist arabic"><ol class="arabic">
|
1710
2257
|
<li>
|
1711
2258
|
<p>
|
1712
2259
|
Your Apache configuration is too strict, and does not allow HTTP clients to
|
@@ -1722,44 +2269,44 @@ Your Apache configuration is too strict, and does not allow HTTP clients to
|
|
1722
2269
|
Allow from all
|
1723
2270
|
</Directory></tt></pre>
|
1724
2271
|
</div></div>
|
1725
|
-
<div class="
|
2272
|
+
<div class="paragraph"><p>See also <a href="http://groups.google.com/group/phusion-passenger/browse_thread/thread/9699a639a87f85f4/b9d71a03bf2670a5">this discussion</a>.</p></div>
|
1726
2273
|
</li>
|
1727
2274
|
<li>
|
1728
2275
|
<p>
|
1729
|
-
The Apache process doesn
|
1730
|
-
Please make sure that the Rails application
|
2276
|
+
The Apache process doesn’t have permission to access your Rails application’s folder.
|
2277
|
+
Please make sure that the Rails application’s folder, as well as all of its parent folders,
|
1731
2278
|
have the correct permissions and/or ownerships.
|
1732
2279
|
</p>
|
1733
2280
|
</li>
|
1734
2281
|
</ol></div>
|
1735
2282
|
<h4 id="_the_apache_error_log_says_that_the_spawn_manager_script_does_not_exist_or_that_it_does_not_have_permission_to_execute_it">6.3.5. The Apache error log says that the spawn manager script does not exist, or that it does not have permission to execute it</h4>
|
1736
|
-
<div class="
|
1737
|
-
then this problem is most likely caused by the fact that you
|
2283
|
+
<div class="paragraph"><p>If you are sure that the <em>PassengerRoot</em> configuration option is set correctly,
|
2284
|
+
then this problem is most likely caused by the fact that you’re running Apache
|
1738
2285
|
with SELinux. On Fedora, CentOS and RedHat Enterprise Linux, Apache is locked
|
1739
2286
|
down by SELinux policies.</p></div>
|
1740
|
-
<div class="
|
2287
|
+
<div class="paragraph"><p>To solve this problem, you must set some permissions on the Phusion Passenger files
|
1741
2288
|
and folders, so that Apache can access them.</p></div>
|
1742
|
-
<div class="
|
2289
|
+
<div class="ulist"><ul>
|
1743
2290
|
<li>
|
1744
2291
|
<p>
|
1745
|
-
If you
|
1746
|
-
Phusion Passenger
|
2292
|
+
If you’ve installed Phusion Passenger via a gem, then run this command to determine
|
2293
|
+
Phusion Passenger’s root folder:
|
1747
2294
|
</p>
|
1748
2295
|
<div class="listingblock">
|
1749
2296
|
<div class="content">
|
1750
2297
|
<pre><tt>passenger-config --root</tt></pre>
|
1751
2298
|
</div></div>
|
1752
|
-
<div class="
|
2299
|
+
<div class="paragraph"><p>Next, run the following command:</p></div>
|
1753
2300
|
<div class="listingblock">
|
1754
2301
|
<div class="content">
|
1755
2302
|
<pre><tt>chcon -R -h -t httpd_sys_content_t /path-to-passenger-root</tt></pre>
|
1756
2303
|
</div></div>
|
1757
|
-
<div class="
|
1758
|
-
<tt>passenger-config
|
2304
|
+
<div class="paragraph"><p>where <em>/path-to-passenger-root</em> should be replaced with whatever
|
2305
|
+
<tt>passenger-config --root</tt> printed.</p></div>
|
1759
2306
|
</li>
|
1760
2307
|
<li>
|
1761
2308
|
<p>
|
1762
|
-
If you
|
2309
|
+
If you’ve installed Phusion Passenger via the source tarball, then run the following
|
1763
2310
|
command:
|
1764
2311
|
</p>
|
1765
2312
|
<div class="listingblock">
|
@@ -1768,18 +2315,18 @@ If you've installed Phusion Passenger via the source tarball, then run the follo
|
|
1768
2315
|
</div></div>
|
1769
2316
|
</li>
|
1770
2317
|
</ul></div>
|
1771
|
-
<div class="
|
1772
|
-
<h4 id="
|
1773
|
-
<div class="
|
2318
|
+
<div class="paragraph"><p>Once the permissions are fixed, restart Apache.</p></div>
|
2319
|
+
<h4 id="_the_rails_application_reports_that_it_8217_s_unable_to_start_because_of_a_permission_error">6.3.6. The Rails application reports that it’s unable to start because of a permission error</h4>
|
2320
|
+
<div class="paragraph"><p>Please check whether your Rails application’s folder has the correct
|
1774
2321
|
permissions. By default, Rails applications are started as the owner of the
|
1775
2322
|
file <em>config/environment.rb</em>, except if the file is owned by root. If the
|
1776
2323
|
file is owned by root, then the Rails application will be started as <em>nobody</em>
|
1777
|
-
(or as the user specify by <a href="#RailsDefaultUser">RailsDefaultUser</a>, if that
|
2324
|
+
(or as the user specify by <a href="#RailsDefaultUser">RailsDefaultUser</a>, if that’s
|
1778
2325
|
specified).</p></div>
|
1779
|
-
<div class="
|
1780
|
-
<h4 id="
|
1781
|
-
<div class="
|
1782
|
-
<div class="
|
2326
|
+
<div class="paragraph"><p>Please read <a href="#user_switching">User switching (security)</a> for details.</p></div>
|
2327
|
+
<h4 id="_my_rails_application_8217_s_log_file_is_not_being_written_to">6.3.7. My Rails application’s log file is not being written to</h4>
|
2328
|
+
<div class="paragraph"><p>There are a couple things that you should be aware of:</p></div>
|
2329
|
+
<div class="ulist"><ul>
|
1783
2330
|
<li>
|
1784
2331
|
<p>
|
1785
2332
|
By default, Phusion Passenger runs Rails applications in <em>production</em> mode,
|
@@ -1793,12 +2340,12 @@ By default, Phusion Passenger runs Rails applications as the owner of <em>enviro
|
|
1793
2340
|
So the log file can only be written to if that user has write permission to the
|
1794
2341
|
log file. Please <em>chmod</em> or <em>chown</em> your log file accordingly.
|
1795
2342
|
</p>
|
1796
|
-
<div class="
|
2343
|
+
<div class="paragraph"><p>See <a href="#User_switching">User switching (security)</a> for details.</p></div>
|
1797
2344
|
</li>
|
1798
2345
|
</ul></div>
|
1799
|
-
<div class="
|
2346
|
+
<div class="paragraph"><p>If you’re using a RedHat-derived Linux distribution (such as Fedora or CentOS)
|
1800
2347
|
then it is <a href="http://code.google.com/p/phusion-passenger/issues/detail?id=4">possible
|
1801
|
-
that SELinux is interfering</a>. RedHat
|
2348
|
+
that SELinux is interfering</a>. RedHat’s SELinux policy only allows Apache to read/write
|
1802
2349
|
directories that have the <em>httpd_sys_content_t</em> security context. Please run the
|
1803
2350
|
following command to give your Rails application folder that context:</p></div>
|
1804
2351
|
<div class="listingblock">
|
@@ -1806,46 +2353,24 @@ following command to give your Rails application folder that context:</p></div>
|
|
1806
2353
|
<pre><tt>chcon -R -h -t httpd_sys_content_t /path/to/your/rails/app</tt></pre>
|
1807
2354
|
</div></div>
|
1808
2355
|
<h3 id="conflicting_apache_modules">6.4. Conflicting Apache modules</h3><div style="clear:left"></div>
|
1809
|
-
<h4 id="
|
1810
|
-
<div class="
|
1811
|
-
|
1812
|
-
|
1813
|
-
not to use their features inside virtual hosts that contain a Rails
|
1814
|
-
application.</p></div>
|
1815
|
-
<div class="para"><p>By default, Phusion Passenger will override mod_rewrite rules on Rails hosts.
|
1816
|
-
This is because the default .htaccess, as provided by Ruby on Rails, redirects all
|
1817
|
-
requests to `dispatch.cgi' using mod_rewrite. This is a CGI application which
|
1818
|
-
loads the entire Ruby on Rails framework for every request, and thus is very
|
1819
|
-
slow. If we do not override mod_rewrite, then Ruby on Rails apps will be slow
|
1820
|
-
on Phusion Passenger by default — but we want a good out-of-the-box experience.</p></div>
|
1821
|
-
<div class="para"><p>Furthermore, the primary reason why people use mod_rewrite with Rails
|
1822
|
-
applications, is to accelerate page caching. Phusion Passenger supports page
|
1823
|
-
caching out-of-the-box, without mod_rewrite.</p></div>
|
1824
|
-
<div class="para"><p>It is not fully understood how mod_alias conflicts with Phusion Passenger, but we
|
1825
|
-
recommend you not to use it on Rails virtual hosts. mod_alias rules can result
|
1826
|
-
in surprising problems.</p></div>
|
1827
|
-
<div class="para"><p>If you really want to use mod_rewrite on Rails virtual hosts, then please set
|
1828
|
-
the <a href="#RailsAllowModRewrite">RailsAllowModRewrite</a> configuration option. But
|
1829
|
-
please note that you will have to delete Rails applications' default .htaccess
|
1830
|
-
file, or add rewrite rules to negate its effects.</p></div>
|
1831
|
-
<h4 id="_mod_userdir">6.4.2. mod_userdir</h4>
|
1832
|
-
<div class="para"><p><em>mod_userdir</em> is not compatible with Phusion Passenger at the moment.</p></div>
|
1833
|
-
<h4 id="_virtualdocumentroot">6.4.3. VirtualDocumentRoot</h4>
|
1834
|
-
<div class="para"><p>VirtualDocumentRoot is not compatible with Phusion Passenger at the moment.</p></div>
|
2356
|
+
<h4 id="_mod_userdir">6.4.1. mod_userdir</h4>
|
2357
|
+
<div class="paragraph"><p><em>mod_userdir</em> is not compatible with Phusion Passenger at the moment.</p></div>
|
2358
|
+
<h4 id="_virtualdocumentroot">6.4.2. VirtualDocumentRoot</h4>
|
2359
|
+
<div class="paragraph"><p>VirtualDocumentRoot is not compatible with Phusion Passenger at the moment.</p></div>
|
1835
2360
|
</div>
|
1836
2361
|
<h2 id="_analysis_and_system_maintenance_tools">7. Analysis and system maintenance tools</h2>
|
1837
2362
|
<div class="sectionbody">
|
1838
|
-
<div class="
|
2363
|
+
<div class="paragraph"><p>Phusion Passenger provides a set of tools, which are useful for system analysis,
|
1839
2364
|
maintenance and troubleshooting.</p></div>
|
1840
2365
|
<h3 id="_inspecting_memory_usage">7.1. Inspecting memory usage</h3><div style="clear:left"></div>
|
1841
|
-
<div class="
|
2366
|
+
<div class="paragraph"><p>Process inspection tools such as <tt>ps</tt> and <tt>top</tt> are useful, but they
|
1842
2367
|
<a href="http://groups.google.com/group/phusion-passenger/msg/1fd1c233456d3180">rarely show the correct memory usage</a>.
|
1843
2368
|
The real memory usage is usually lower than what <tt>ps</tt> and <tt>top</tt> report.</p></div>
|
1844
|
-
<div class="
|
2369
|
+
<div class="paragraph"><p>There are many technical reasons why this is so, but an explanation is beyond
|
1845
2370
|
the scope of this Users Guide. We kindly refer the interested reader to
|
1846
2371
|
operating systems literature about <em>virtual memory</em> and <em>copy-on-write</em>.</p></div>
|
1847
|
-
<div class="
|
1848
|
-
and Apache
|
2372
|
+
<div class="paragraph"><p>The tool <tt>passenger-memory-stats</tt> allows one to easily analyze Phusion Passenger’s
|
2373
|
+
and Apache’s real memory usage. For example:</p></div>
|
1849
2374
|
<div class="listingblock">
|
1850
2375
|
<div class="content">
|
1851
2376
|
<pre><tt>[bash@localhost root]# passenger-memory-stats
|
@@ -1873,7 +2398,7 @@ PID Threads VMSize Private Name
|
|
1873
2398
|
### Processes: 4
|
1874
2399
|
### Total private dirty RSS: 27.76 M</tt></pre>
|
1875
2400
|
</div></div>
|
1876
|
-
<div class="
|
2401
|
+
<div class="paragraph"><p>The <em>Private</em> or <em>private dirty RSS</em> field shows the <strong>real</strong> memory usage of processes. Here,
|
1877
2402
|
we see that all the Apache worker processes only take less than 1 MB memory each.
|
1878
2403
|
This is a lot less than the 50 MB-ish memory usage as shown in the <em>VMSize</em> column
|
1879
2404
|
(which is what a lot of people think is the real memory usage, but is actually not).</p></div>
|
@@ -1882,12 +2407,12 @@ This is a lot less than the 50 MB-ish memory usage as shown in the <em>VMSize</e
|
|
1882
2407
|
<td class="icon">
|
1883
2408
|
<img src="./images/icons/note.png" alt="Note" />
|
1884
2409
|
</td>
|
1885
|
-
<td class="content">This tool only works on Linux. Unfortunately other operating systems don
|
2410
|
+
<td class="content">This tool only works on Linux. Unfortunately other operating systems don’t
|
1886
2411
|
provide facilities for determining processes' private dirty RSS.</td>
|
1887
2412
|
</tr></table>
|
1888
2413
|
</div>
|
1889
|
-
<h3 id="
|
1890
|
-
<div class="
|
2414
|
+
<h3 id="_inspecting_phusion_passenger_8217_s_internal_status">7.2. Inspecting Phusion Passenger’s internal status</h3><div style="clear:left"></div>
|
2415
|
+
<div class="paragraph"><p>One can inspect Phusion Passenger’s internal status with the tool <tt>passenger-status</tt>.
|
1891
2416
|
This tool must typically be run as root. For example:</p></div>
|
1892
2417
|
<div class="listingblock">
|
1893
2418
|
<div class="content">
|
@@ -1898,75 +2423,106 @@ count = 1
|
|
1898
2423
|
active = 0
|
1899
2424
|
inactive = 1
|
1900
2425
|
|
1901
|
-
-----------
|
2426
|
+
----------- Domains -----------
|
1902
2427
|
/var/www/projects/app1-foobar:
|
1903
|
-
PID: 9617 Sessions: 0</tt></pre>
|
2428
|
+
PID: 9617 Sessions: 0 Processed: 7 Uptime: 2m 23s</tt></pre>
|
1904
2429
|
</div></div>
|
1905
|
-
<div class="
|
1906
|
-
<div class="
|
1907
|
-
<
|
1908
|
-
<td class="hlist1">
|
2430
|
+
<div class="paragraph"><p>The <em>general information</em> section shows the following information:</p></div>
|
2431
|
+
<div class="dlist"><dl>
|
2432
|
+
<dt class="hdlist1">
|
1909
2433
|
max
|
1910
|
-
</
|
1911
|
-
<
|
2434
|
+
</dt>
|
2435
|
+
<dd>
|
2436
|
+
<p>
|
1912
2437
|
The maximum number of application instances that Phusion Passenger will
|
1913
2438
|
spawn. This equals the value given for <a href="#PassengerMaxPoolSize">PassengerMaxPoolSize</a>.
|
1914
|
-
</
|
1915
|
-
</
|
1916
|
-
<
|
1917
|
-
<td class="hlist1">
|
2439
|
+
</p>
|
2440
|
+
</dd>
|
2441
|
+
<dt class="hdlist1">
|
1918
2442
|
count
|
1919
|
-
</
|
1920
|
-
<
|
2443
|
+
</dt>
|
2444
|
+
<dd>
|
2445
|
+
<p>
|
1921
2446
|
The number of application instances that are currently alive. This value
|
1922
2447
|
is always less than or equal to <em>max</em>.
|
1923
|
-
</
|
1924
|
-
</
|
1925
|
-
<
|
1926
|
-
<td class="hlist1">
|
2448
|
+
</p>
|
2449
|
+
</dd>
|
2450
|
+
<dt class="hdlist1">
|
1927
2451
|
active
|
1928
|
-
</
|
1929
|
-
<
|
2452
|
+
</dt>
|
2453
|
+
<dd>
|
2454
|
+
<p>
|
1930
2455
|
The number of application instances that are currently processing
|
1931
2456
|
requests. This value is always less than or equal to <em>count</em>.
|
1932
|
-
</
|
1933
|
-
</
|
1934
|
-
<
|
1935
|
-
<td class="hlist1">
|
2457
|
+
</p>
|
2458
|
+
</dd>
|
2459
|
+
<dt class="hdlist1">
|
1936
2460
|
inactive
|
1937
|
-
</
|
1938
|
-
<
|
2461
|
+
</dt>
|
2462
|
+
<dd>
|
2463
|
+
<p>
|
1939
2464
|
The number of application instances that are currently <strong>not</strong> processing
|
1940
2465
|
requests, i.e. are idle. Idle application instances will be shutdown after a while,
|
1941
|
-
as can be specified with <a href="#PassengerPoolIdleTime">PassengerPoolIdleTime</a
|
1942
|
-
|
1943
|
-
</
|
1944
|
-
</
|
1945
|
-
</
|
1946
|
-
|
1947
|
-
|
1948
|
-
|
1949
|
-
<div class="
|
2466
|
+
as can be specified with <a href="#PassengerPoolIdleTime">PassengerPoolIdleTime</a> (unless this
|
2467
|
+
value is set to 0, in which case application instances are never shut down via idle
|
2468
|
+
time). The value of <em>inactive</em> equals <tt>count - active</tt>.
|
2469
|
+
</p>
|
2470
|
+
</dd>
|
2471
|
+
</dl></div>
|
2472
|
+
<div class="paragraph"><p>The <em>domains</em> section shows, for each application directory, information about running
|
2473
|
+
application instances:</p></div>
|
2474
|
+
<div class="dlist"><dl>
|
2475
|
+
<dt class="hdlist1">
|
2476
|
+
Sessions
|
2477
|
+
</dt>
|
2478
|
+
<dd>
|
2479
|
+
<p>
|
2480
|
+
Shows how many HTTP client are currently in the queue of that application
|
2481
|
+
Instance, waiting to be processed.
|
2482
|
+
</p>
|
2483
|
+
</dd>
|
2484
|
+
<dt class="hdlist1">
|
2485
|
+
Processed
|
2486
|
+
</dt>
|
2487
|
+
<dd>
|
2488
|
+
<p>
|
2489
|
+
Indicates how many requests the instance has served until now. <strong>Tip:</strong> it’s
|
2490
|
+
possible to limit this number with the <a href="#PassengerMaxRequests">PassengerMaxRequests</a>
|
2491
|
+
configuration directive.
|
2492
|
+
</p>
|
2493
|
+
</dd>
|
2494
|
+
<dt class="hdlist1">
|
2495
|
+
Uptime
|
2496
|
+
</dt>
|
2497
|
+
<dd>
|
2498
|
+
<p>
|
2499
|
+
Shows for how long the application instance has been running.
|
2500
|
+
</p>
|
2501
|
+
</dd>
|
2502
|
+
</dl></div>
|
2503
|
+
<div class="paragraph"><p>Since Phusion Passenger uses fair load balancing by default, the number of sessions for the
|
1950
2504
|
application instances should be fairly close to each other. For example, this is fairly
|
1951
2505
|
normal:</p></div>
|
1952
2506
|
<div class="listingblock">
|
1953
2507
|
<div class="content">
|
1954
|
-
<pre><tt> PID: 4281 Sessions: 2
|
1955
|
-
PID: 4268 Sessions: 0
|
1956
|
-
PID: 4265 Sessions: 1
|
1957
|
-
PID: 4275 Sessions: 1</tt></pre>
|
2508
|
+
<pre><tt> PID: 4281 Sessions: 2 Processed: 7 Uptime: 5m 11s
|
2509
|
+
PID: 4268 Sessions: 0 Processed: 5 Uptime: 4m 52s
|
2510
|
+
PID: 4265 Sessions: 1 Processed: 6 Uptime: 5m 38s
|
2511
|
+
PID: 4275 Sessions: 1 Processed: 7 Uptime: 3m 14s</tt></pre>
|
1958
2512
|
</div></div>
|
1959
|
-
<div class="
|
2513
|
+
<div class="paragraph"><p>But if you see a "spike", i.e. an application instance has an unusually high number of
|
1960
2514
|
sessions compared to the others, then there might be a problem:</p></div>
|
1961
2515
|
<div class="listingblock">
|
1962
2516
|
<div class="content">
|
1963
|
-
<pre><tt> PID: 4281 Sessions: 2
|
1964
|
-
PID: 17468 Sessions: 8
|
1965
|
-
PID: 4265 Sessions: 1
|
1966
|
-
PID: 4275 Sessions: 1
|
1967
|
-
|
1968
|
-
|
1969
|
-
|
2517
|
+
<pre><tt> PID: 4281 Sessions: 2 Processed: 7 Uptime: 5m 11s
|
2518
|
+
PID: 17468 Sessions: 8 <-+ Processed: 2 Uptime: 4m 47s
|
2519
|
+
PID: 4265 Sessions: 1 | Processed: 6 Uptime: 5m 38s
|
2520
|
+
PID: 4275 Sessions: 1 | Processed: 7 Uptime: 3m 14s
|
2521
|
+
|
|
2522
|
+
+---- "spike"</tt></pre>
|
2523
|
+
</div></div>
|
2524
|
+
<div class="paragraph"><p>Possible reasons why spikes can occur:</p></div>
|
2525
|
+
<div class="olist arabic"><ol class="arabic">
|
1970
2526
|
<li>
|
1971
2527
|
<p>
|
1972
2528
|
Your application is busy processing a request that takes a very long time.
|
@@ -1982,15 +2538,15 @@ Your application is frozen, i.e. has stopped responding. See
|
|
1982
2538
|
</li>
|
1983
2539
|
</ol></div>
|
1984
2540
|
<h3 id="debugging_frozen">7.3. Debugging frozen applications</h3><div style="clear:left"></div>
|
1985
|
-
<div class="
|
2541
|
+
<div class="paragraph"><p>If one of your application instances is frozen (stopped responding), then you
|
1986
2542
|
can figure out where it is frozen by killing it with <em>SIGABRT</em>. This will cause the
|
1987
2543
|
application to raise an exception, with a backtrace.</p></div>
|
1988
|
-
<div class="
|
2544
|
+
<div class="paragraph"><p>The exception (with full backtrace information) is normally logged into the Apache
|
1989
2545
|
error log. But if your application or if its web framework has its own exception logging
|
1990
|
-
routines, then exceptions might be logged into the application
|
2546
|
+
routines, then exceptions might be logged into the application’s log files instead.
|
1991
2547
|
This is the case with Ruby on Rails. So if you kill a Ruby on Rails application with
|
1992
|
-
<em>SIGABRT</em>, please check the application
|
1993
|
-
running it in a <em>production</em> environment). If you don
|
2548
|
+
<em>SIGABRT</em>, please check the application’s <em>production.log</em> first (assuming that you’re
|
2549
|
+
running it in a <em>production</em> environment). If you don’t see a backtrace there, check
|
1994
2550
|
the Apache error log.</p></div>
|
1995
2551
|
<div class="admonitionblock">
|
1996
2552
|
<table><tr>
|
@@ -2005,23 +2561,23 @@ will restart killed application instances, as if nothing bad happened.</td>
|
|
2005
2561
|
<h2 id="_tips">8. Tips</h2>
|
2006
2562
|
<div class="sectionbody">
|
2007
2563
|
<h3 id="user_switching">8.1. User switching (security)</h3><div style="clear:left"></div>
|
2008
|
-
<div class="
|
2564
|
+
<div class="paragraph"><p>There is a problem that plagues most PHP web hosts, namely the fact that all PHP
|
2009
2565
|
applications are run in the same user context as the web server. So for
|
2010
|
-
example, Joe
|
2566
|
+
example, Joe’s PHP application will be able to read Jane’s PHP application’s
|
2011
2567
|
passwords. This is obviously undesirable on many servers.</p></div>
|
2012
|
-
<div class="
|
2568
|
+
<div class="paragraph"><p>Phusion Passenger solves this problem by implementing <em>user switching</em>. A Rails
|
2013
2569
|
application is started as the owner of the file <em>config/environment.rb</em>,
|
2014
2570
|
and a Rack application is started as the owner of the file <em>config.ru</em>.
|
2015
2571
|
So if <em>/home/webapps/foo/config/environment.rb</em> is owned by <em>joe</em>, then Phusion
|
2016
2572
|
Passenger will launch the corresponding Rails application as <em>joe</em> as well.</p></div>
|
2017
|
-
<div class="
|
2573
|
+
<div class="paragraph"><p>This behavior is the default, and you don’t need to configure anything. But
|
2018
2574
|
there are things that you should keep in mind:</p></div>
|
2019
|
-
<div class="
|
2575
|
+
<div class="ulist"><ul>
|
2020
2576
|
<li>
|
2021
2577
|
<p>
|
2022
|
-
The owner of <em>environment.rb</em> must have read access to the Rails application
|
2023
|
-
folder, and read/write access to the Rails application
|
2024
|
-
Likewise, the owner of <em>config.ru</em> must have read access to the Rack application
|
2578
|
+
The owner of <em>environment.rb</em> must have read access to the Rails application’s
|
2579
|
+
folder, and read/write access to the Rails application’s <em>logs</em> folder.
|
2580
|
+
Likewise, the owner of <em>config.ru</em> must have read access to the Rack application’s
|
2025
2581
|
folder.
|
2026
2582
|
</p>
|
2027
2583
|
</li>
|
@@ -2040,17 +2596,17 @@ Under no circumstances will applications be run as <em>root</em>. If
|
|
2040
2596
|
</p>
|
2041
2597
|
</li>
|
2042
2598
|
</ul></div>
|
2043
|
-
<div class="
|
2599
|
+
<div class="paragraph"><p>User switching can be disabled with the
|
2044
2600
|
<a href="#PassengerUserSwitching">PassengerUserSwitching</a> option.</p></div>
|
2045
2601
|
<h3 id="reducing_memory_usage">8.2. Reducing memory consumption of Ruby on Rails applications by 33%</h3><div style="clear:left"></div>
|
2046
|
-
<div class="
|
2602
|
+
<div class="paragraph"><p>Is it possible to reduce memory consumption of your Rails applications by 33% on average,
|
2047
2603
|
by using <a href="http://www.rubyenterpriseedition.com/">Ruby Enterprise Edition</a>.
|
2048
2604
|
Please visit the website for details.</p></div>
|
2049
|
-
<div class="
|
2605
|
+
<div class="paragraph"><p>Note that this feature does not apply to Rack applications.</p></div>
|
2050
2606
|
<h3 id="capistrano">8.3. Capistrano recipe</h3><div style="clear:left"></div>
|
2051
|
-
<div class="
|
2607
|
+
<div class="paragraph"><p>Phusion Passenger can be combined with <a href="http://capify.org/">Capistrano</a>.
|
2052
2608
|
The following Capistrano recipe demonstrates Phusion Passenger support.
|
2053
|
-
It assumes that you
|
2609
|
+
It assumes that you’re using Git as version control system.</p></div>
|
2054
2610
|
<div class="listingblock">
|
2055
2611
|
<div class="content">
|
2056
2612
|
<pre><tt>set :application, "myapp"
|
@@ -2065,48 +2621,48 @@ role :web, domain
|
|
2065
2621
|
role :db, domain, :primary => true
|
2066
2622
|
|
2067
2623
|
namespace :deploy do
|
2624
|
+
task :start, :roles => :app do
|
2625
|
+
run "touch #{current_release}/tmp/restart.txt"
|
2626
|
+
end
|
2627
|
+
|
2628
|
+
task :stop, :roles => :app do
|
2629
|
+
# Do nothing.
|
2630
|
+
end
|
2631
|
+
|
2068
2632
|
desc "Restart Application"
|
2069
2633
|
task :restart, :roles => :app do
|
2070
|
-
run "touch #{
|
2634
|
+
run "touch #{current_release}/tmp/restart.txt"
|
2071
2635
|
end
|
2072
2636
|
end</tt></pre>
|
2073
2637
|
</div></div>
|
2074
|
-
<div class="
|
2075
|
-
<
|
2076
|
-
<
|
2077
|
-
<img src="./images/icons/note.png" alt="Note" />
|
2078
|
-
</td>
|
2079
|
-
<td class="content">
|
2080
|
-
<div class="para"><p>You may notice that for each deploy, a new spawner server is
|
2081
|
-
created (it'll show up in <tt>passenger-memory-stats</tt>). Indeed, Capistrano will deploy
|
2082
|
-
to a path ending with <em>/current</em> (ie : <em>/var/www/yourapp/current</em>), so that you don't
|
2638
|
+
<div class="paragraph"><p>You may notice that after each deploy, a new spawner server is
|
2639
|
+
created (it’ll show up in <tt>passenger-memory-stats</tt>). Indeed, Capistrano will deploy
|
2640
|
+
to a path ending with <em>/current</em> (ie : <em>/u/apps/yourapp/current</em>), so that you don’t
|
2083
2641
|
have to care about revisions in your virtual host configuration. This <em>/current</em> directory
|
2084
2642
|
is a symlink to the current revision deployed (<em>/path_to_app/releases/date_of_the_release</em>).
|
2085
|
-
|
2086
|
-
|
2643
|
+
Phusion Passenger recognizes applications by their full canonical path, so after
|
2644
|
+
deploying a new version, Phusion Passenger will think that the new version is
|
2645
|
+
a totally different application, thereby creating a new spawner server:</p></div>
|
2087
2646
|
<div class="listingblock">
|
2088
2647
|
<div class="content">
|
2089
|
-
<pre><tt>1001 30291 [...] Passenger ApplicationSpawner: /
|
2090
|
-
1001 31371 [...] Passenger ApplicationSpawner: /
|
2648
|
+
<pre><tt>1001 30291 [...] Passenger ApplicationSpawner: /u/apps/my_app/releases/20080509104413
|
2649
|
+
1001 31371 [...] Passenger ApplicationSpawner: /u/apps/my_app/releases/20080509104632</tt></pre>
|
2091
2650
|
</div></div>
|
2092
|
-
<div class="
|
2093
|
-
timeout (10 minutes), so you will not run out of memory.</p></div>
|
2094
|
-
<div class="
|
2651
|
+
<div class="paragraph"><p>Don’t worry about this. The (old) spawner server will terminate itself after its
|
2652
|
+
timeout period (10 minutes by default), so you will not run out of memory.</p></div>
|
2653
|
+
<div class="paragraph"><p>If you really want to release the spawner server’s memory immediately, then you can add a command
|
2095
2654
|
to your Capistrano script to terminate the Passenger spawn server after each deploy. That
|
2096
2655
|
command is as follows:</p></div>
|
2097
2656
|
<div class="listingblock">
|
2098
2657
|
<div class="content">
|
2099
2658
|
<pre><tt>kill $( passenger-memory-stats | grep 'Passenger spawn server' | awk '{ print $1 }' )</tt></pre>
|
2100
2659
|
</div></div>
|
2101
|
-
<div class="
|
2660
|
+
<div class="paragraph"><p>Killing the spawn server is completely safe, because Phusion Passenger will restart the
|
2102
2661
|
spawn server if it has been terminated.</p></div>
|
2103
|
-
</td>
|
2104
|
-
</tr></table>
|
2105
|
-
</div>
|
2106
2662
|
<h3 id="_moving_phusion_passenger_to_a_different_directory">8.4. Moving Phusion Passenger to a different directory</h3><div style="clear:left"></div>
|
2107
|
-
<div class="
|
2663
|
+
<div class="paragraph"><p>It is possible to relocate the Phusion Passenger files to a different directory. It
|
2108
2664
|
involves two steps:</p></div>
|
2109
|
-
<div class="olist"><ol>
|
2665
|
+
<div class="olist arabic"><ol class="arabic">
|
2110
2666
|
<li>
|
2111
2667
|
<p>
|
2112
2668
|
Moving the directory.
|
@@ -2118,9 +2674,9 @@ Updating the “PassengerRoot” configuration option in Apache.
|
|
2118
2674
|
</p>
|
2119
2675
|
</li>
|
2120
2676
|
</ol></div>
|
2121
|
-
<div class="
|
2677
|
+
<div class="paragraph"><p>For example, if Phusion Passenger is located in <em>/opt/passenger/</em>, and you’d like to
|
2122
2678
|
move it to <em>/usr/local/passenger/</em>, then do this:</p></div>
|
2123
|
-
<div class="olist"><ol>
|
2679
|
+
<div class="olist arabic"><ol class="arabic">
|
2124
2680
|
<li>
|
2125
2681
|
<p>
|
2126
2682
|
Run the following command:
|
@@ -2141,45 +2697,426 @@ Edit your Apache configuration file, and set:
|
|
2141
2697
|
</li>
|
2142
2698
|
</ol></div>
|
2143
2699
|
<h3 id="_installing_multiple_ruby_on_rails_versions">8.5. Installing multiple Ruby on Rails versions</h3><div style="clear:left"></div>
|
2144
|
-
<div class="
|
2700
|
+
<div class="paragraph"><p>Each Ruby on Rails applications that are going to be deployed may require a
|
2145
2701
|
specific Ruby on Rails version. You can install a specific version with
|
2146
2702
|
this command:</p></div>
|
2147
2703
|
<div class="listingblock">
|
2148
2704
|
<div class="content">
|
2149
2705
|
<pre><tt>gem install rails -v X.X.X</tt></pre>
|
2150
2706
|
</div></div>
|
2151
|
-
<div class="
|
2152
|
-
<div class="
|
2707
|
+
<div class="paragraph"><p>where <em>X.X.X</em> is the version number of Ruby on Rails.</p></div>
|
2708
|
+
<div class="paragraph"><p>All of these versions will exist in parallel, and will not conflict with each
|
2153
2709
|
other. Phusion Passenger will automatically make use of the correct version.</p></div>
|
2154
2710
|
<h3 id="_x_sendfile_support">8.6. X-Sendfile support</h3><div style="clear:left"></div>
|
2155
|
-
<div class="
|
2711
|
+
<div class="paragraph"><p>Phusion Passenger does not provide X-Sendfile support by itself. Please install
|
2156
2712
|
<a href="http://tn123.ath.cx/mod_xsendfile/">mod_xsendfile</a> for X-Sendfile support.</p></div>
|
2157
2713
|
<h3 id="_upload_progress">8.7. Upload progress</h3><div style="clear:left"></div>
|
2158
|
-
<div class="
|
2159
|
-
try drogus
|
2714
|
+
<div class="paragraph"><p>Phusion Passenger does not provide upload progress support by itself. Please
|
2715
|
+
try drogus’s <a href="http://github.com/drogus/apache-upload-progress-module/tree/master">
|
2160
2716
|
Apache upload progress module</a> instead.</p></div>
|
2717
|
+
<h3 id="_making_the_application_restart_after_each_request">8.8. Making the application restart after each request</h3><div style="clear:left"></div>
|
2718
|
+
<div class="paragraph"><p>In some situations it might be desirable to restart the web application after
|
2719
|
+
each request, for example when developing a non-Rails application that doesn’t
|
2720
|
+
support code reloading, or when developing a web framework.</p></div>
|
2721
|
+
<div class="paragraph"><p>To achieve this, simply create the file <em>tmp/always_restart.txt</em> in your
|
2722
|
+
application’s root folder. Unlike <em>restart.txt</em>, Phusion Passenger does not
|
2723
|
+
check for this file’s timestamp: Phusion Passenger will always restart the
|
2724
|
+
application, as long as <em>always_restart.txt</em> exists.</p></div>
|
2725
|
+
<div class="admonitionblock">
|
2726
|
+
<table><tr>
|
2727
|
+
<td class="icon">
|
2728
|
+
<img src="./images/icons/note.png" alt="Note" />
|
2729
|
+
</td>
|
2730
|
+
<td class="content">If you’re just developing a Rails application then you probably don’t need
|
2731
|
+
this feature. If you set <em>RailsEnv development</em> in your Apache configuration,
|
2732
|
+
then Rails will automatically reload your application code after each request.
|
2733
|
+
<em>always_restart.txt</em> is only useful if you’re working on Ruby on Rails itself,
|
2734
|
+
or when you’re not developing a Rails application and your web framework
|
2735
|
+
does not support code reloading.</td>
|
2736
|
+
</tr></table>
|
2737
|
+
</div>
|
2161
2738
|
</div>
|
2162
2739
|
<h2 id="_appendix_a_about_this_document">9. Appendix A: About this document</h2>
|
2163
2740
|
<div class="sectionbody">
|
2164
|
-
<div class="
|
2741
|
+
<div class="paragraph"><p>The text of this document is licensed under the
|
2165
2742
|
<a href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons
|
2166
2743
|
Attribution-Share Alike 3.0 Unported License</a>.</p></div>
|
2167
|
-
<div class="
|
2744
|
+
<div class="paragraph"><p><span class="image">
|
2168
2745
|
<a class="image" href="http://creativecommons.org/licenses/by-sa/3.0/">
|
2169
2746
|
<img src="images/by_sa.png" alt="images/by_sa.png" />
|
2170
2747
|
</a>
|
2171
2748
|
</span></p></div>
|
2172
|
-
<div class="
|
2173
|
-
<div class="
|
2749
|
+
<div class="paragraph"><p>Phusion Passenger is brought to you by <a href="http://www.phusion.nl/">Phusion</a>.</p></div>
|
2750
|
+
<div class="paragraph"><p><span class="image">
|
2174
2751
|
<a class="image" href="http://www.phusion.nl/">
|
2175
2752
|
<img src="images/phusion_banner.png" alt="images/phusion_banner.png" />
|
2176
2753
|
</a>
|
2177
2754
|
</span></p></div>
|
2178
|
-
<div class="
|
2755
|
+
<div class="paragraph"><p>Phusion Passenger is a trademark of Hongli Lai & Ninh Bui.</p></div>
|
2756
|
+
</div>
|
2757
|
+
<h2 id="_appendix_b_terminology">10. Appendix B: Terminology</h2>
|
2758
|
+
<div class="sectionbody">
|
2759
|
+
<h3 id="application_root">10.1. Application root</h3><div style="clear:left"></div>
|
2760
|
+
<div class="paragraph"><p>The root directory of an application that’s served by Phusion Passenger.</p></div>
|
2761
|
+
<div class="paragraph"><p>In case of Ruby on Rails applications, this is the directory that contains
|
2762
|
+
<em>Rakefile</em>, <em>app/</em>, <em>config/</em>, <em>public/</em>, etc. In other words, the directory
|
2763
|
+
pointed to by <tt>RAILS_ROOT</tt>. For example, take the following directory structure:</p></div>
|
2764
|
+
<div class="listingblock">
|
2765
|
+
<div class="content">
|
2766
|
+
<pre><tt>/apps/foo/ <------ This is the Rails application's application root!
|
2767
|
+
|
|
2768
|
+
+- app/
|
2769
|
+
| |
|
2770
|
+
| +- controllers/
|
2771
|
+
| |
|
2772
|
+
| +- models/
|
2773
|
+
| |
|
2774
|
+
| +- views/
|
2775
|
+
|
|
2776
|
+
+- config/
|
2777
|
+
| |
|
2778
|
+
| +- environment.rb
|
2779
|
+
| |
|
2780
|
+
| +- ...
|
2781
|
+
|
|
2782
|
+
+- public/
|
2783
|
+
| |
|
2784
|
+
| +- ...
|
2785
|
+
|
|
2786
|
+
+- ...</tt></pre>
|
2787
|
+
</div></div>
|
2788
|
+
<div class="paragraph"><p>In case of Rack applications, this is the directory that contains <em>config.ru</em>.
|
2789
|
+
For example, take the following directory structure:</p></div>
|
2790
|
+
<div class="listingblock">
|
2791
|
+
<div class="content">
|
2792
|
+
<pre><tt>/apps/bar/ <----- This is the Rack application's application root!
|
2793
|
+
|
|
2794
|
+
+- public/
|
2795
|
+
| |
|
2796
|
+
| +- ...
|
2797
|
+
|
|
2798
|
+
+- config.ru
|
2799
|
+
|
|
2800
|
+
+- ...</tt></pre>
|
2801
|
+
</div></div>
|
2802
|
+
<div class="paragraph"><p>In case of Python (WSGI) applications, this is the directory that contains
|
2803
|
+
<em>passenger_wsgi.py</em>. For example, take the following directory structure:</p></div>
|
2804
|
+
<div class="listingblock">
|
2805
|
+
<div class="content">
|
2806
|
+
<pre><tt>/apps/baz/ <----- This is the WSGI application's application root!
|
2807
|
+
|
|
2808
|
+
+- public/
|
2809
|
+
| |
|
2810
|
+
| +- ...
|
2811
|
+
|
|
2812
|
+
+- passenger_wsgi.py
|
2813
|
+
|
|
2814
|
+
+- ...</tt></pre>
|
2815
|
+
</div></div>
|
2816
|
+
</div>
|
2817
|
+
<h2 id="spawning_methods_explained">11. Appendix C: Spawning methods explained</h2>
|
2818
|
+
<div class="sectionbody">
|
2819
|
+
<div class="paragraph"><p>At its core, Phusion Passenger is an HTTP proxy and process manager. It spawns
|
2820
|
+
Ruby on Rails/Rack/WSGI worker processes (which may also be referred to as
|
2821
|
+
<em>backend processes</em>), and forwards incoming HTTP request to one of the worker
|
2822
|
+
processes.</p></div>
|
2823
|
+
<div class="paragraph"><p>While this may sound simple, there’s not just one way to spawn worker processes.
|
2824
|
+
Let’s go over the different spawning methods. For simplicity’s sake, let’s
|
2825
|
+
assume that we’re only talking about Ruby on Rails applications.</p></div>
|
2826
|
+
<h3 id="_the_most_straightforward_and_traditional_way_conservative_spawning">11.1. The most straightforward and traditional way: conservative spawning</h3><div style="clear:left"></div>
|
2827
|
+
<div class="paragraph"><p>Phusion Passenger could create a new Ruby process, which will then load the
|
2828
|
+
Rails application along with the entire Rails framework. This process will then
|
2829
|
+
enter an request handling main loop.</p></div>
|
2830
|
+
<div class="paragraph"><p>This is the most straightforward way to spawn worker processes. If you’re
|
2831
|
+
familiar with the Mongrel application server, then this approach is exactly
|
2832
|
+
what mongrel_cluster performs: it creates N worker processes, each which loads
|
2833
|
+
a full copy of the Rails application and the Rails framework in memory. The Thin
|
2834
|
+
application server employs pretty much the same approach.</p></div>
|
2835
|
+
<div class="paragraph"><p>Note that Phusion Passenger’s version of conservative spawning differs slightly
|
2836
|
+
from mongrel_cluster. Mongrel_cluster creates entirely new Ruby processes. In
|
2837
|
+
programmers jargon, mongrel_cluster creates new Ruby processes by forking the
|
2838
|
+
current process and exec()-ing a new Ruby interpreter. Phusion Passenger on the
|
2839
|
+
other hand creates processes that reuse the already loaded Ruby interpreter. In
|
2840
|
+
programmers jargon, Phusion Passenger calls fork(), but not exec().</p></div>
|
2841
|
+
<h3 id="_the_smart_spawning_method">11.2. The smart spawning method</h3><div style="clear:left"></div>
|
2842
|
+
<div class="admonitionblock">
|
2843
|
+
<table><tr>
|
2844
|
+
<td class="icon">
|
2845
|
+
<img src="./images/icons/note.png" alt="Note" />
|
2846
|
+
</td>
|
2847
|
+
<td class="content">Smart spawning is only available for Ruby on Rails applications, not for
|
2848
|
+
Rack applications or WSGI applications.</td>
|
2849
|
+
</tr></table>
|
2850
|
+
</div>
|
2851
|
+
<div class="paragraph"><p>While conservative spawning works well, it’s not as efficient as it could be
|
2852
|
+
because each worker process has its own private copy of the Rails application
|
2853
|
+
as well as the Rails framework. This wastes memory as well as startup time.</p></div>
|
2854
|
+
<div class="paragraph"><p><span class="image">
|
2855
|
+
<img src="images/conservative_spawning.png" alt="Worker processes and conservative spawning" title="Worker processes and conservative spawning" />
|
2856
|
+
</span><br />
|
2857
|
+
<em>Figure: Worker processes and conservative spawning. Each worker process has its
|
2858
|
+
own private copy of the application code and Rails framework code.</em></p></div>
|
2859
|
+
<div class="paragraph"><p>It is possible to make the different worker processes share the memory occupied
|
2860
|
+
by application and Rails framework code, by utilizing so-called
|
2861
|
+
copy-on-write semantics of the virtual memory system on modern operating
|
2862
|
+
systems. As a side effect, the startup time is also reduced. This is technique
|
2863
|
+
is exploited by Phusion Passenger’s <em>smart</em> and <em>smart-lv2</em> spawn methods.</p></div>
|
2864
|
+
<h4 id="_how_it_works">11.2.1. How it works</h4>
|
2865
|
+
<div class="paragraph"><p>When the <em>smart-lv2</em> spawn method is being used, Phusion Passenger will first
|
2866
|
+
create a so-called <em>ApplicationSpawner server</em> process. This process loads the
|
2867
|
+
entire Rails application along with the Rails framework, by loading
|
2868
|
+
<em>environment.rb</em>. Then, whenever Phusion Passenger needs a new worker process,
|
2869
|
+
it will instruct the ApplicationSpawner server to do so. The ApplicationSpawner
|
2870
|
+
server will create a worker new process
|
2871
|
+
that reuses the already loaded Rails application/framework. Creating a worker
|
2872
|
+
process through an already running ApplicationSpawner server is very fast, about
|
2873
|
+
10 times faster than loading the Rails application/framework from scratch. If
|
2874
|
+
the Ruby interpreter is copy-on-write friendly (that is, if you’re running
|
2875
|
+
<a href="#reducing_memory_usage">Ruby Enterprise Edition</a>) then all created worker
|
2876
|
+
processes will share as much common
|
2877
|
+
memory as possible. That is, they will all share the same application and Rails
|
2878
|
+
framework code.</p></div>
|
2879
|
+
<div class="paragraph"><p><span class="image">
|
2880
|
+
<img src="images/smart-lv2.png" alt="images/smart-lv2.png" />
|
2881
|
+
</span><br />
|
2882
|
+
<em>Figure: Worker processes and the smart-lv2 spawn method. All worker processes,
|
2883
|
+
as well as the ApplicationSpawner, share the same application code and Rails
|
2884
|
+
framework code.</em></p></div>
|
2885
|
+
<div class="paragraph"><p>The <em>smart</em> spawn method goes even further, by caching the Rails framework in
|
2886
|
+
another process called the <em>FrameworkSpawner server</em>. This process only loads
|
2887
|
+
the Rails framework, not the application. When a FrameworkSpawner server is
|
2888
|
+
instructed to create a new worker process, it will create a new
|
2889
|
+
ApplicationSpawner to which the instruction will be delegated. All those
|
2890
|
+
ApplicationSpawner servers, as well as all worker processes created by those
|
2891
|
+
ApplicationSpawner servers, will share the same Rails framework code.</p></div>
|
2892
|
+
<div class="paragraph"><p>The <em>smart-lv2</em> method allows different worker processes that belong to the same
|
2893
|
+
application to share memory. The <em>smart</em> method allows different worker
|
2894
|
+
processes - that happen to use the same Rails version - to share memory, even if
|
2895
|
+
they don’t belong to the same application.</p></div>
|
2896
|
+
<div class="paragraph"><p>Notes:</p></div>
|
2897
|
+
<div class="ulist"><ul>
|
2898
|
+
<li>
|
2899
|
+
<p>
|
2900
|
+
Vendored Rails frameworks cannot be shared by different applications, even if
|
2901
|
+
both vendored Rails frameworks are the same version. So for efficiency reasons
|
2902
|
+
we don’t recommend vendoring Rails.
|
2903
|
+
</p>
|
2904
|
+
</li>
|
2905
|
+
<li>
|
2906
|
+
<p>
|
2907
|
+
ApplicationSpawner and FrameworkSpawner servers have an idle timeout just
|
2908
|
+
like worker processes. If an ApplicationSpawner/FrameworkSpawner server hasn’t
|
2909
|
+
been instructed to do anything for a while, it will be shutdown in order to
|
2910
|
+
conserve memory. This idle timeout is configurable.
|
2911
|
+
</p>
|
2912
|
+
</li>
|
2913
|
+
</ul></div>
|
2914
|
+
<h4 id="_summary_of_benefits">11.2.2. Summary of benefits</h4>
|
2915
|
+
<div class="paragraph"><p>Suppose that Phusion Passenger needs a new worker process for an application
|
2916
|
+
that uses Rails 2.2.1.</p></div>
|
2917
|
+
<div class="ulist"><ul>
|
2918
|
+
<li>
|
2919
|
+
<p>
|
2920
|
+
If the <em>smart-lv2</em> spawning method is used, and an ApplicationSpawner server
|
2921
|
+
for this application is already running, then worker process creation time is
|
2922
|
+
about 10 times faster than conservative spawning. This worker process will also
|
2923
|
+
share application and Rails framework code memory with the ApplicationSpawner
|
2924
|
+
server and the worker processes that had been spawned by this ApplicationSpawner
|
2925
|
+
server.
|
2926
|
+
</p>
|
2927
|
+
</li>
|
2928
|
+
<li>
|
2929
|
+
<p>
|
2930
|
+
If the <em>smart</em> spawning method is used, and a FrameworkSpawner server for
|
2931
|
+
Rails 2.2.1 is already running, but no ApplicationSpawner server for this
|
2932
|
+
application is running, then worker process creation time is about 2 times
|
2933
|
+
faster than conservative spawning. If there is an ApplicationSpawner server
|
2934
|
+
for this application running, then worker process creation time is about 10
|
2935
|
+
times faster. This worker process will also share application and Rails
|
2936
|
+
framework code memory with the ApplicationSpawner and FrameworkSpawner
|
2937
|
+
servers.
|
2938
|
+
</p>
|
2939
|
+
</li>
|
2940
|
+
</ul></div>
|
2941
|
+
<div class="paragraph"><p>You could compare ApplicationSpawner and FrameworkSpawner servers with stem
|
2942
|
+
cells, that have the ability to quickly change into more specific cells (worker
|
2943
|
+
process).</p></div>
|
2944
|
+
<div class="paragraph"><p>In practice, the smart spawning methods could mean a memory saving of about 33%,
|
2945
|
+
assuming that your Ruby interpreter is <a href="#reducing_memory_usage">copy-on-write friendly</a>.</p></div>
|
2946
|
+
<div class="paragraph"><p>Of course, smart spawning is not without gotchas. But if you understand the
|
2947
|
+
gotchas you can easily reap the benefits of smart spawning.</p></div>
|
2948
|
+
<h3 id="_smart_spawning_gotcha_1_unintential_file_descriptor_sharing">11.3. Smart spawning gotcha #1: unintential file descriptor sharing</h3><div style="clear:left"></div>
|
2949
|
+
<div class="paragraph"><p>Because worker processes are created by forking from an ApplicationSpawner
|
2950
|
+
server, it will share all file descriptors that are opened by the
|
2951
|
+
ApplicationSpawner server. (This is part of the semantics of the Unix
|
2952
|
+
<em>fork()</em> system call. You might want to Google it if you’re not familiar with
|
2953
|
+
it.) A file descriptor is a handle which can be an opened file, an opened socket
|
2954
|
+
connection, a pipe, etc. If different worker processes write to such a file
|
2955
|
+
descriptor at the same time, then their write calls will be interleaved, which
|
2956
|
+
may potentially cause problems.</p></div>
|
2957
|
+
<div class="paragraph"><p>The problem commonly involves socket connections that are unintentially being
|
2958
|
+
shared. You can fix it by closing and reestablishing the connection when Phusion
|
2959
|
+
Passenger is creating a new worker process. Phusion Passenger provides the API
|
2960
|
+
call <tt>PhusionPassenger.on_event(:starting_worker_process)</tt> to do so. So you
|
2961
|
+
could insert the following code in your <em>environment.rb</em>:</p></div>
|
2962
|
+
<div class="listingblock">
|
2963
|
+
<div class="content"><!-- Generator: GNU source-highlight 2.4
|
2964
|
+
by Lorenzo Bettini
|
2965
|
+
http://www.lorenzobettini.it
|
2966
|
+
http://www.gnu.org/software/src-highlite -->
|
2967
|
+
<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">if</span></span> <span style="font-weight: bold"><span style="color: #0000FF">defined</span></span><span style="color: #990000">?(</span>PhusionPassenger<span style="color: #990000">)</span>
|
2968
|
+
PhusionPassenger<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">on_event</span></span><span style="color: #990000">(:</span>starting_worker_process<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">do</span></span> <span style="color: #990000">|</span>forked<span style="color: #990000">|</span>
|
2969
|
+
<span style="font-weight: bold"><span style="color: #0000FF">if</span></span> forked
|
2970
|
+
<span style="font-style: italic"><span style="color: #9A1900"># We're in smart spawning mode.</span></span>
|
2971
|
+
<span style="color: #990000">...</span> code to reestablish socket connections here <span style="color: #990000">...</span>
|
2972
|
+
<span style="font-weight: bold"><span style="color: #0000FF">else</span></span>
|
2973
|
+
<span style="font-style: italic"><span style="color: #9A1900"># We're in conservative spawning mode. We don't need to do anything.</span></span>
|
2974
|
+
<span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
|
2975
|
+
<span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
|
2976
|
+
<span style="font-weight: bold"><span style="color: #0000FF">end</span></span></tt></pre></div></div>
|
2977
|
+
<div class="paragraph"><p>Note that Phusion Passenger automatically reestablishes the connection to the
|
2978
|
+
database upon creating a new worker process, which is why you normally do not
|
2979
|
+
encounter any database issues when using smart spawning mode.</p></div>
|
2980
|
+
<h4 id="_example_1_memcached_connection_sharing_harmful">11.3.1. Example 1: Memcached connection sharing (harmful)</h4>
|
2981
|
+
<div class="paragraph"><p>Suppose we have a Rails application that connects to a Memcached server in
|
2982
|
+
<em>environment.rb</em>. This causes the ApplicationSpawner to have a socket connection
|
2983
|
+
(file descriptor) to the Memcached server, as shown in the following figure:</p></div>
|
2984
|
+
<div class="literalblock">
|
2985
|
+
<div class="content">
|
2986
|
+
<pre><tt>+--------------------+
|
2987
|
+
| ApplicationSpawner |-----------[Memcached server]
|
2988
|
+
+--------------------+</tt></pre>
|
2989
|
+
</div></div>
|
2990
|
+
<div class="paragraph"><p>Phusion Passenger then proceeds with creating a new Rails worker process, which
|
2991
|
+
is to process incoming HTTP requests. The result will look like this:</p></div>
|
2992
|
+
<div class="literalblock">
|
2993
|
+
<div class="content">
|
2994
|
+
<pre><tt>+--------------------+
|
2995
|
+
| ApplicationSpawner |------+----[Memcached server]
|
2996
|
+
+--------------------+ |
|
2997
|
+
|
|
2998
|
+
+--------------------+ |
|
2999
|
+
| Worker process 1 |-----/
|
3000
|
+
+--------------------+</tt></pre>
|
3001
|
+
</div></div>
|
3002
|
+
<div class="paragraph"><p>Since a <em>fork()</em> makes a (virtual) complete copy of a process, all its file
|
3003
|
+
descriptors will be copied as well. What we see here is that ApplicationSpawner
|
3004
|
+
and Worker process 1 both share the same connection to Memcached.</p></div>
|
3005
|
+
<div class="paragraph"><p>Now supposed that your site gets Slashdotted and Phusion Passenger needs to
|
3006
|
+
spawn another worker process. It does so by forking ApplicationSpawner. The
|
3007
|
+
result is now as follows:</p></div>
|
3008
|
+
<div class="literalblock">
|
3009
|
+
<div class="content">
|
3010
|
+
<pre><tt>+--------------------+
|
3011
|
+
| ApplicationSpawner |------+----[Memcached server]
|
3012
|
+
+--------------------+ |
|
3013
|
+
|
|
3014
|
+
+--------------------+ |
|
3015
|
+
| Worker process 1 |-----/|
|
3016
|
+
+--------------------+ |
|
3017
|
+
|
|
3018
|
+
+--------------------+ |
|
3019
|
+
| Worker process 2 |-----/
|
3020
|
+
+--------------------+</tt></pre>
|
3021
|
+
</div></div>
|
3022
|
+
<div class="paragraph"><p>As you can see, Worker process 1 and Worker process 2 have the same Memcache
|
3023
|
+
connection.</p></div>
|
3024
|
+
<div class="paragraph"><p>Suppose that users Joe and Jane visit your website at the same time. Joe’s
|
3025
|
+
request is handled by Worker process 1, and Jane’s request is handled by Worker
|
3026
|
+
process 2. Both worker processes want to fetch something from Memcached. Suppose
|
3027
|
+
that in order to do that, both handlers need to send a "FETCH" command to Memcached.</p></div>
|
3028
|
+
<div class="paragraph"><p>But suppose that, after worker process 1 having only sent "FE", a context switch
|
3029
|
+
occurs, and worker process 2 starts sending a "FETCH" command to Memcached as
|
3030
|
+
well. If worker process 2 succeeds in sending only one bye, <em>F</em>, then Memcached
|
3031
|
+
will receive a command which begins with "FEF", a command that it does not
|
3032
|
+
recognize. In other words: the data from both handlers get interleaved. And thus
|
3033
|
+
Memcached is forced to handle this as an error.</p></div>
|
3034
|
+
<div class="paragraph"><p>This problem can be solved by reestablishing the connection to Memcached after forking:</p></div>
|
3035
|
+
<div class="literalblock">
|
3036
|
+
<div class="content">
|
3037
|
+
<pre><tt>+--------------------+
|
3038
|
+
| ApplicationSpawner |------+----[Memcached server]
|
3039
|
+
+--------------------+ | |
|
3040
|
+
| |
|
3041
|
+
+--------------------+ | |
|
3042
|
+
| Worker process 1 |-----/| |
|
3043
|
+
+--------------------+ | | <--- created this
|
3044
|
+
X | new
|
3045
|
+
| connection
|
3046
|
+
X <-- closed this |
|
3047
|
+
+--------------------+ | old |
|
3048
|
+
| Worker process 2 |-----/ connection |
|
3049
|
+
+--------------------+ |
|
3050
|
+
| |
|
3051
|
+
+-------------------------------------+</tt></pre>
|
3052
|
+
</div></div>
|
3053
|
+
<div class="paragraph"><p>Worker process 2 now has its own, separate communication channel with Memcached.
|
3054
|
+
The code in <em>environment.rb</em> looks like this:</p></div>
|
3055
|
+
<div class="listingblock">
|
3056
|
+
<div class="content"><!-- Generator: GNU source-highlight 2.4
|
3057
|
+
by Lorenzo Bettini
|
3058
|
+
http://www.lorenzobettini.it
|
3059
|
+
http://www.gnu.org/software/src-highlite -->
|
3060
|
+
<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">if</span></span> <span style="font-weight: bold"><span style="color: #0000FF">defined</span></span><span style="color: #990000">?(</span>PhusionPassenger<span style="color: #990000">)</span>
|
3061
|
+
PhusionPassenger<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">on_event</span></span><span style="color: #990000">(:</span>starting_worker_process<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">do</span></span> <span style="color: #990000">|</span>forked<span style="color: #990000">|</span>
|
3062
|
+
<span style="font-weight: bold"><span style="color: #0000FF">if</span></span> forked
|
3063
|
+
<span style="font-style: italic"><span style="color: #9A1900"># We're in smart spawning mode.</span></span>
|
3064
|
+
reestablish_connection_to_memcached
|
3065
|
+
<span style="font-weight: bold"><span style="color: #0000FF">else</span></span>
|
3066
|
+
<span style="font-style: italic"><span style="color: #9A1900"># We're in conservative spawning mode. We don't need to do anything.</span></span>
|
3067
|
+
<span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
|
3068
|
+
<span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
|
3069
|
+
<span style="font-weight: bold"><span style="color: #0000FF">end</span></span></tt></pre></div></div>
|
3070
|
+
<h4 id="_example_2_log_file_sharing_not_harmful">11.3.2. Example 2: Log file sharing (not harmful)</h4>
|
3071
|
+
<div class="paragraph"><p>There are also cases in which unintential file descriptor sharing is not harmful.
|
3072
|
+
One such case is log file file descriptor sharing. Even if two processes write
|
3073
|
+
to the log file at the same time, the worst thing that can happen is that the
|
3074
|
+
data in the log file is interleaved.</p></div>
|
3075
|
+
<div class="paragraph"><p>To guarantee that the data written to the log file is never interleaved, you
|
3076
|
+
must synchronize write access via an inter-process synchronization mechanism,
|
3077
|
+
such as file locks. Reopening the log file, like you would have done in the
|
3078
|
+
Memcached example, doesn’t help.</p></div>
|
3079
|
+
<h3 id="_smart_spawning_gotcha_2_the_need_to_revive_threads">11.4. Smart spawning gotcha #2: the need to revive threads</h3><div style="clear:left"></div>
|
3080
|
+
<div class="paragraph"><p>Another part of the <em>fork()</em> system call’s semantics is the fact that threads
|
3081
|
+
disappear after a fork call. So if you’ve created any threads in environment.rb,
|
3082
|
+
then those threads will no longer be running in newly created worker process.
|
3083
|
+
You need to revive them when a new worker process is created. Use the
|
3084
|
+
<tt>:starting_worker_process</tt> event that Phusion Passenger provides, like this:</p></div>
|
3085
|
+
<div class="listingblock">
|
3086
|
+
<div class="content"><!-- Generator: GNU source-highlight 2.4
|
3087
|
+
by Lorenzo Bettini
|
3088
|
+
http://www.lorenzobettini.it
|
3089
|
+
http://www.gnu.org/software/src-highlite -->
|
3090
|
+
<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">if</span></span> <span style="font-weight: bold"><span style="color: #0000FF">defined</span></span><span style="color: #990000">?(</span>PhusionPassenger<span style="color: #990000">)</span>
|
3091
|
+
PhusionPassenger<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">on_event</span></span><span style="color: #990000">(:</span>starting_worker_process<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">do</span></span> <span style="color: #990000">|</span>forked<span style="color: #990000">|</span>
|
3092
|
+
<span style="font-weight: bold"><span style="color: #0000FF">if</span></span> forked
|
3093
|
+
<span style="font-style: italic"><span style="color: #9A1900"># We're in smart spawning mode.</span></span>
|
3094
|
+
<span style="color: #990000">...</span> code to revive threads here <span style="color: #990000">...</span>
|
3095
|
+
<span style="font-weight: bold"><span style="color: #0000FF">else</span></span>
|
3096
|
+
<span style="font-style: italic"><span style="color: #9A1900"># We're in conservative spawning mode. We don't need to do anything.</span></span>
|
3097
|
+
<span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
|
3098
|
+
<span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
|
3099
|
+
<span style="font-weight: bold"><span style="color: #0000FF">end</span></span></tt></pre></div></div>
|
3100
|
+
<h3 id="_smart_spawning_gotcha_3_code_load_order">11.5. Smart spawning gotcha #3: code load order</h3><div style="clear:left"></div>
|
3101
|
+
<div class="paragraph"><p>This gotcha is only applicable to the <em>smart</em> spawn method, not the <em>smart-lv2</em>
|
3102
|
+
spawn method.</p></div>
|
3103
|
+
<div class="paragraph"><p>If your application expects the Rails framework to be not loaded during the
|
3104
|
+
beginning of <em>environment.rb</em>, then it can cause problems when an
|
3105
|
+
ApplicationSpawner is created from a FrameworkSpawner, which already has the
|
3106
|
+
Rails framework loaded. The most common case is when applications try to patch
|
3107
|
+
Rails by dropping a modified file that has the same name as Rails’s own file,
|
3108
|
+
in a path that comes earlier in the Ruby search path.</p></div>
|
3109
|
+
<div class="paragraph"><p>For example, suppose that we have an application which has a patched version
|
3110
|
+
of <em>active_record/base.rb</em> located in <em>RAILS_ROOT/lib/patches</em>, and
|
3111
|
+
<em>RAILS_ROOT/lib/patches</em> comes first in the Ruby load path. When conservative
|
3112
|
+
spawning is used, the patched version of <em>base.rb</em> is properly loaded. When
|
3113
|
+
<em>smart</em> (not <em>smart-lv2</em>) spawning is used, the original <em>base.rb</em> is used
|
3114
|
+
because it was already loaded, so a subsequent <tt>require "active_record/base"</tt>
|
3115
|
+
has no effect.</p></div>
|
2179
3116
|
</div>
|
2180
3117
|
<div id="footer">
|
2181
3118
|
<div id="footer-text">
|
2182
|
-
Last updated
|
3119
|
+
Last updated 2009-03-13 17:14:24 CEST
|
2183
3120
|
</div>
|
2184
3121
|
</div>
|
2185
3122
|
</body>
|