passenger 2.2.2 → 2.2.3

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.

Files changed (254) hide show
  1. data/DEVELOPERS.TXT +13 -3
  2. data/Rakefile +42 -33
  3. data/bin/passenger-install-apache2-module +1 -2
  4. data/bin/passenger-install-nginx-module +7 -19
  5. data/bin/passenger-status +64 -15
  6. data/bin/passenger-stress-test +2 -2
  7. data/doc/ApplicationPool algorithm.txt +26 -22
  8. data/doc/Users guide Apache.html +374 -149
  9. data/doc/Users guide Apache.txt +318 -51
  10. data/doc/Users guide Nginx.html +13 -13
  11. data/doc/Users guide Nginx.txt +7 -2
  12. data/doc/cxxapi/Bucket_8h-source.html +62 -25
  13. data/doc/cxxapi/Configuration_8h-source.html +343 -326
  14. data/doc/cxxapi/DirectoryMapper_8h-source.html +12 -12
  15. data/doc/cxxapi/Hooks_8h-source.html +1 -1
  16. data/doc/cxxapi/annotated.html +1 -1
  17. data/doc/cxxapi/classHooks-members.html +1 -1
  18. data/doc/cxxapi/classHooks.html +1 -1
  19. data/doc/cxxapi/classPassenger_1_1DirectoryMapper-members.html +2 -2
  20. data/doc/cxxapi/classPassenger_1_1DirectoryMapper.html +9 -9
  21. data/doc/cxxapi/classes.html +1 -1
  22. data/doc/cxxapi/definitions_8h-source.html +1 -1
  23. data/doc/cxxapi/files.html +1 -1
  24. data/doc/cxxapi/functions.html +2 -2
  25. data/doc/cxxapi/functions_func.html +2 -2
  26. data/doc/cxxapi/graph_legend.html +1 -1
  27. data/doc/cxxapi/group__Configuration.html +1 -1
  28. data/doc/cxxapi/group__Core.html +1 -1
  29. data/doc/cxxapi/group__Hooks.html +1 -1
  30. data/doc/cxxapi/group__Support.html +1 -1
  31. data/doc/cxxapi/main.html +1 -1
  32. data/doc/cxxapi/modules.html +1 -1
  33. data/doc/rdoc/classes/ConditionVariable.html +194 -0
  34. data/doc/rdoc/classes/Exception.html +120 -0
  35. data/doc/rdoc/classes/GC.html +113 -0
  36. data/doc/rdoc/classes/IO.html +169 -0
  37. data/doc/rdoc/classes/PhusionPassenger.html +238 -0
  38. data/doc/rdoc/classes/PhusionPassenger/AbstractInstaller.html +153 -0
  39. data/doc/rdoc/classes/PhusionPassenger/AbstractRequestHandler.html +517 -0
  40. data/doc/rdoc/classes/PhusionPassenger/AbstractServer.html +719 -0
  41. data/doc/rdoc/classes/PhusionPassenger/AbstractServer/ServerAlreadyStarted.html +97 -0
  42. data/doc/rdoc/classes/PhusionPassenger/AbstractServer/ServerError.html +96 -0
  43. data/doc/rdoc/classes/PhusionPassenger/AbstractServer/ServerNotStarted.html +97 -0
  44. data/doc/rdoc/classes/PhusionPassenger/AbstractServer/UnknownMessage.html +96 -0
  45. data/doc/rdoc/classes/PhusionPassenger/AbstractServerCollection.html +598 -0
  46. data/doc/rdoc/classes/PhusionPassenger/AdminTools.html +140 -0
  47. data/doc/rdoc/classes/PhusionPassenger/AdminTools/ControlProcess.html +317 -0
  48. data/doc/rdoc/classes/PhusionPassenger/AdminTools/ControlProcess/Instance.html +138 -0
  49. data/doc/rdoc/classes/PhusionPassenger/AppInitError.html +154 -0
  50. data/doc/rdoc/classes/PhusionPassenger/Application.html +283 -0
  51. data/doc/rdoc/classes/PhusionPassenger/ConsoleTextTemplate.html +172 -0
  52. data/doc/rdoc/classes/PhusionPassenger/FrameworkInitError.html +145 -0
  53. data/doc/rdoc/classes/PhusionPassenger/HTMLTemplate.html +175 -0
  54. data/doc/rdoc/classes/PhusionPassenger/InitializationError.html +141 -0
  55. data/doc/rdoc/classes/PhusionPassenger/InvalidPath.html +92 -0
  56. data/doc/rdoc/classes/PhusionPassenger/MessageChannel.html +489 -0
  57. data/doc/rdoc/classes/PhusionPassenger/NativeSupport.html +350 -0
  58. data/doc/rdoc/classes/PhusionPassenger/Rack.html +91 -0
  59. data/doc/rdoc/classes/PhusionPassenger/Rack/ApplicationSpawner.html +188 -0
  60. data/doc/rdoc/classes/PhusionPassenger/Rack/RequestHandler.html +194 -0
  61. data/doc/rdoc/classes/PhusionPassenger/Railz.html +95 -0
  62. data/doc/rdoc/classes/PhusionPassenger/Railz/ApplicationSpawner.html +442 -0
  63. data/doc/rdoc/classes/PhusionPassenger/Railz/ApplicationSpawner/Error.html +98 -0
  64. data/doc/rdoc/classes/PhusionPassenger/Railz/CGIFixed.html +200 -0
  65. data/doc/rdoc/classes/PhusionPassenger/Railz/FrameworkSpawner.html +436 -0
  66. data/doc/rdoc/classes/PhusionPassenger/Railz/FrameworkSpawner/Error.html +98 -0
  67. data/doc/rdoc/classes/PhusionPassenger/Railz/RequestHandler.html +155 -0
  68. data/doc/rdoc/classes/PhusionPassenger/SpawnManager.html +402 -0
  69. data/doc/rdoc/classes/PhusionPassenger/UnknownError.html +125 -0
  70. data/doc/rdoc/classes/PhusionPassenger/Utils.html +805 -0
  71. data/doc/rdoc/classes/PhusionPassenger/VersionNotFound.html +140 -0
  72. data/doc/rdoc/classes/PhusionPassenger/WSGI.html +89 -0
  73. data/doc/rdoc/classes/PhusionPassenger/WSGI/ApplicationSpawner.html +188 -0
  74. data/doc/rdoc/classes/PlatformInfo.html +831 -0
  75. data/doc/rdoc/classes/RakeExtensions.html +197 -0
  76. data/doc/rdoc/classes/Signal.html +131 -0
  77. data/doc/rdoc/created.rid +1 -0
  78. data/doc/rdoc/files/DEVELOPERS_TXT.html +255 -0
  79. data/doc/rdoc/files/README.html +157 -0
  80. data/doc/rdoc/files/ext/phusion_passenger/native_support_c.html +92 -0
  81. data/doc/rdoc/files/lib/phusion_passenger/abstract_installer_rb.html +129 -0
  82. data/doc/rdoc/files/lib/phusion_passenger/abstract_request_handler_rb.html +131 -0
  83. data/doc/rdoc/files/lib/phusion_passenger/abstract_server_collection_rb.html +126 -0
  84. data/doc/rdoc/files/lib/phusion_passenger/abstract_server_rb.html +130 -0
  85. data/doc/rdoc/files/lib/phusion_passenger/admin_tools/control_process_rb.html +130 -0
  86. data/doc/rdoc/files/lib/phusion_passenger/admin_tools_rb.html +122 -0
  87. data/doc/rdoc/files/lib/phusion_passenger/application_rb.html +127 -0
  88. data/doc/rdoc/files/lib/phusion_passenger/console_text_template_rb.html +126 -0
  89. data/doc/rdoc/files/lib/phusion_passenger/constants_rb.html +122 -0
  90. data/doc/rdoc/files/lib/phusion_passenger/dependencies_rb.html +134 -0
  91. data/doc/rdoc/files/lib/phusion_passenger/events_rb.html +122 -0
  92. data/doc/rdoc/files/lib/phusion_passenger/exceptions_rb.html +122 -0
  93. data/doc/rdoc/files/lib/phusion_passenger/html_template_rb.html +126 -0
  94. data/doc/rdoc/files/lib/phusion_passenger/message_channel_rb.html +122 -0
  95. data/doc/rdoc/files/lib/phusion_passenger/packaging_rb.html +122 -0
  96. data/doc/rdoc/files/lib/phusion_passenger/platform_info_rb.html +127 -0
  97. data/doc/rdoc/files/lib/phusion_passenger/rack/application_spawner_rb.html +133 -0
  98. data/doc/rdoc/files/lib/phusion_passenger/rack/request_handler_rb.html +127 -0
  99. data/doc/rdoc/files/lib/phusion_passenger/railz/application_spawner_rb.html +143 -0
  100. data/doc/rdoc/files/lib/phusion_passenger/railz/cgi_fixed_rb.html +126 -0
  101. data/doc/rdoc/files/lib/phusion_passenger/railz/framework_spawner_rb.html +145 -0
  102. data/doc/rdoc/files/lib/phusion_passenger/railz/request_handler_rb.html +127 -0
  103. data/doc/rdoc/files/lib/phusion_passenger/simple_benchmarking_rb.html +122 -0
  104. data/doc/rdoc/files/lib/phusion_passenger/spawn_manager_rb.html +161 -0
  105. data/doc/rdoc/files/lib/phusion_passenger/utils_rb.html +175 -0
  106. data/doc/rdoc/files/lib/phusion_passenger/wsgi/application_spawner_rb.html +129 -0
  107. data/doc/rdoc/files/misc/rake/extensions_rb.html +130 -0
  108. data/doc/rdoc/fr_class_index.html +90 -0
  109. data/doc/rdoc/fr_file_index.html +76 -0
  110. data/doc/rdoc/fr_method_index.html +200 -0
  111. data/doc/rdoc/index.html +26 -0
  112. data/doc/rdoc/rdoc-style.css +187 -0
  113. data/doc/users_guide_snippets/rackup_specifications.txt +2 -8
  114. data/ext/apache2/Bucket.cpp +71 -38
  115. data/ext/apache2/Bucket.h +53 -16
  116. data/ext/apache2/Configuration.cpp +15 -0
  117. data/ext/apache2/Configuration.h +19 -2
  118. data/ext/apache2/DirectoryMapper.h +10 -10
  119. data/ext/apache2/Hooks.cpp +334 -74
  120. data/ext/boost/mpl/apply.hpp +5 -1
  121. data/ext/boost/mpl/apply_wrap.hpp +5 -2
  122. data/ext/boost/mpl/aux_/full_lambda.hpp +5 -1
  123. data/ext/boost/mpl/bind.hpp +5 -1
  124. data/ext/common/Application.h +11 -31
  125. data/ext/common/ApplicationPool.h +2 -1
  126. data/ext/common/ApplicationPoolServer.h +61 -20
  127. data/ext/common/ApplicationPoolServerExecutable.cpp +132 -4
  128. data/ext/common/ApplicationPoolStatusReporter.h +189 -65
  129. data/ext/common/Base64.cpp +143 -0
  130. data/ext/common/Base64.h +57 -0
  131. data/ext/common/CachedFileStat.cpp +25 -82
  132. data/ext/common/CachedFileStat.h +11 -125
  133. data/ext/common/CachedFileStat.hpp +243 -0
  134. data/ext/common/Exceptions.h +13 -0
  135. data/ext/common/FileChangeChecker.h +209 -0
  136. data/ext/common/Logging.h +3 -2
  137. data/ext/common/MessageChannel.h +10 -10
  138. data/ext/common/PoolOptions.h +72 -5
  139. data/ext/common/SpawnManager.h +11 -8
  140. data/ext/common/StandardApplicationPool.h +38 -39
  141. data/ext/common/StaticString.h +1 -0
  142. data/ext/common/StringListCreator.h +83 -0
  143. data/ext/common/SystemTime.h +3 -2
  144. data/ext/common/Timer.h +88 -0
  145. data/ext/common/Utils.cpp +161 -42
  146. data/ext/common/Utils.h +62 -31
  147. data/ext/common/Version.h +1 -1
  148. data/ext/nginx/Configuration.c +0 -4
  149. data/ext/nginx/ContentHandler.c +8 -6
  150. data/ext/nginx/HelperServer.cpp +45 -55
  151. data/ext/nginx/HttpStatusExtractor.h +4 -0
  152. data/ext/nginx/StaticContentHandler.c +25 -5
  153. data/ext/nginx/config +3 -0
  154. data/ext/nginx/ngx_http_passenger_module.c +72 -17
  155. data/ext/nginx/ngx_http_passenger_module.h +2 -2
  156. data/lib/phusion_passenger/abstract_request_handler.rb +15 -7
  157. data/lib/phusion_passenger/abstract_server.rb +16 -2
  158. data/lib/phusion_passenger/admin_tools/control_process.rb +36 -25
  159. data/lib/phusion_passenger/constants.rb +1 -1
  160. data/lib/phusion_passenger/dependencies.rb +10 -0
  161. data/lib/phusion_passenger/platform_info.rb +1 -1
  162. data/lib/phusion_passenger/rack/application_spawner.rb +21 -2
  163. data/lib/phusion_passenger/rack/request_handler.rb +10 -0
  164. data/lib/phusion_passenger/railz/application_spawner.rb +38 -2
  165. data/lib/phusion_passenger/railz/framework_spawner.rb +26 -28
  166. data/lib/phusion_passenger/railz/request_handler.rb +5 -1
  167. data/lib/phusion_passenger/spawn_manager.rb +6 -2
  168. data/lib/phusion_passenger/utils.rb +79 -27
  169. data/misc/rake/cplusplus.rb +5 -5
  170. data/test/ApplicationPoolServerTest.cpp +42 -0
  171. data/test/ApplicationPoolTest.cpp +255 -267
  172. data/test/Base64Test.cpp +48 -0
  173. data/test/CachedFileStatTest.cpp +243 -103
  174. data/test/FileChangeCheckerTest.cpp +331 -0
  175. data/test/PoolOptionsTest.cpp +80 -0
  176. data/test/UtilsTest.cpp +5 -17
  177. data/test/integration_tests/apache2_tests.rb +15 -4
  178. data/test/integration_tests/mycook_spec.rb +3 -4
  179. data/test/oxt/syscall_interruption_test.cpp +2 -14
  180. data/test/ruby/abstract_server_collection_spec.rb +1 -1
  181. data/test/ruby/abstract_server_spec.rb +35 -1
  182. data/test/ruby/rack/application_spawner_spec.rb +23 -6
  183. data/test/ruby/rails/application_spawner_spec.rb +6 -6
  184. data/test/ruby/rails/framework_spawner_spec.rb +6 -5
  185. data/test/ruby/rails/minimal_spawner_spec.rb +19 -0
  186. data/test/ruby/rails/spawner_error_handling_spec.rb +62 -7
  187. data/test/ruby/spawn_manager_spec.rb +10 -7
  188. data/test/ruby/spawn_server_spec.rb +1 -1
  189. data/test/ruby/utils_spec.rb +193 -20
  190. data/test/ruby/wsgi/application_spawner_spec.rb +3 -1
  191. data/test/stub/apache2/httpd.conf.erb +3 -0
  192. data/test/stub/rack/config.ru +1 -1
  193. data/test/stub/rails_apps/mycook/app/controllers/welcome_controller.rb +8 -0
  194. data/test/support/Support.cpp +84 -0
  195. data/test/support/Support.h +66 -8
  196. data/test/support/config.rb +14 -2
  197. data/test/support/test_helper.rb +5 -0
  198. data/vendor/rack-1.0.0-git/lib/rack/auth/openid.rb +123 -116
  199. data/vendor/rack-1.0.0-git/lib/rack/cascade.rb +17 -12
  200. data/vendor/rack-1.0.0-git/lib/rack/commonlogger.rb +34 -43
  201. data/vendor/rack-1.0.0-git/lib/rack/handler/cgi.rb +1 -1
  202. data/vendor/rack-1.0.0-git/lib/rack/handler/fastcgi.rb +1 -1
  203. data/vendor/rack-1.0.0-git/lib/rack/handler/lsws.rb +1 -1
  204. data/vendor/rack-1.0.0-git/lib/rack/handler/mongrel.rb +1 -1
  205. data/vendor/rack-1.0.0-git/lib/rack/handler/scgi.rb +1 -1
  206. data/vendor/rack-1.0.0-git/lib/rack/handler/webrick.rb +1 -1
  207. data/vendor/rack-1.0.0-git/lib/rack/mock.rb +4 -17
  208. data/vendor/rack-1.0.0-git/lib/rack/request.rb +3 -9
  209. data/vendor/rack-1.0.0-git/lib/rack/rewindable_input.rb +2 -0
  210. data/vendor/rack-1.0.0-git/lib/rack/utils.rb +38 -12
  211. metadata +231 -186
  212. data/ext/common/FileChecker.h +0 -112
  213. data/test/FileCheckerTest.cpp +0 -79
  214. data/test/stub/minimal-railsapp/README +0 -3
  215. data/test/stub/minimal-railsapp/config/application.rb +0 -0
  216. data/test/stub/minimal-railsapp/config/environment.rb +0 -3
  217. data/test/stub/minimal-railsapp/vendor/rails/actionmailer/lib/action_mailer.rb +0 -0
  218. data/test/stub/minimal-railsapp/vendor/rails/actionpack/lib/action_controller.rb +0 -10
  219. data/test/stub/minimal-railsapp/vendor/rails/actionpack/lib/action_pack.rb +0 -0
  220. data/test/stub/minimal-railsapp/vendor/rails/actionpack/lib/action_view.rb +0 -0
  221. data/test/stub/minimal-railsapp/vendor/rails/activerecord/lib/active_record.rb +0 -7
  222. data/test/stub/minimal-railsapp/vendor/rails/activeresource/lib/active_resource.rb +0 -0
  223. data/test/stub/minimal-railsapp/vendor/rails/activesupport/lib/active_support.rb +0 -17
  224. data/test/stub/minimal-railsapp/vendor/rails/activesupport/lib/active_support/whiny_nil.rb +0 -0
  225. data/test/stub/minimal-railsapp/vendor/rails/railties/lib/dispatcher.rb +0 -0
  226. data/test/stub/minimal-railsapp/vendor/rails/railties/lib/initializer.rb +0 -8
  227. data/test/stub/minimal-railsapp/vendor/rails/railties/lib/ruby_version_check.rb +0 -1
  228. data/test/stub/railsapp/app/controllers/application.rb +0 -12
  229. data/test/stub/railsapp/app/controllers/bar_controller.rb +0 -5
  230. data/test/stub/railsapp/app/controllers/bar_controller_1.txt +0 -5
  231. data/test/stub/railsapp/app/controllers/bar_controller_2.txt +0 -5
  232. data/test/stub/railsapp/app/controllers/foo_controller.rb +0 -9
  233. data/test/stub/railsapp/app/helpers/application_helper.rb +0 -3
  234. data/test/stub/railsapp/config/boot.rb +0 -108
  235. data/test/stub/railsapp/config/database.yml +0 -19
  236. data/test/stub/railsapp/config/environment.rb +0 -59
  237. data/test/stub/railsapp/config/environments/development.rb +0 -18
  238. data/test/stub/railsapp/config/environments/production.rb +0 -19
  239. data/test/stub/railsapp/config/initializers/inflections.rb +0 -10
  240. data/test/stub/railsapp/config/initializers/mime_types.rb +0 -5
  241. data/test/stub/railsapp/config/routes.rb +0 -35
  242. data/test/stub/railsapp/public/useless.txt +0 -1
  243. data/test/stub/railsapp2/app/controllers/application.rb +0 -12
  244. data/test/stub/railsapp2/app/controllers/foo_controller.rb +0 -5
  245. data/test/stub/railsapp2/app/helpers/application_helper.rb +0 -3
  246. data/test/stub/railsapp2/config/boot.rb +0 -108
  247. data/test/stub/railsapp2/config/database.yml +0 -19
  248. data/test/stub/railsapp2/config/environment.rb +0 -59
  249. data/test/stub/railsapp2/config/environments/development.rb +0 -18
  250. data/test/stub/railsapp2/config/environments/production.rb +0 -19
  251. data/test/stub/railsapp2/config/initializers/inflections.rb +0 -10
  252. data/test/stub/railsapp2/config/initializers/mime_types.rb +0 -5
  253. data/test/stub/railsapp2/config/routes.rb +0 -35
  254. data/test/stub/railsapp2/public/useless.txt +0 -1
@@ -0,0 +1,719 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+ <html>
6
+ <head>
7
+ <title>Class: PhusionPassenger::AbstractServer</title>
8
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
9
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
10
+
11
+ <script language="JavaScript" type="text/javascript">
12
+ // <![CDATA[
13
+
14
+ function toggleSource( id )
15
+ {
16
+ var elem
17
+ var link
18
+
19
+ if( document.getElementById )
20
+ {
21
+ elem = document.getElementById( id )
22
+ link = document.getElementById( "l_" + id )
23
+ }
24
+ else if ( document.all )
25
+ {
26
+ elem = eval( "document.all." + id )
27
+ link = eval( "document.all.l_" + id )
28
+ }
29
+ else
30
+ return false;
31
+
32
+ if( elem.style.display == "block" )
33
+ {
34
+ elem.style.display = "none"
35
+ link.innerHTML = "show source"
36
+ }
37
+ else
38
+ {
39
+ elem.style.display = "block"
40
+ link.innerHTML = "hide source"
41
+ }
42
+ }
43
+
44
+ function openCode( url )
45
+ {
46
+ window.open( url, "SOURCE_CODE", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=480,width=750" ).focus();
47
+ }
48
+ // ]]>
49
+ </script>
50
+ </head>
51
+
52
+ <body>
53
+ <table width="100%" border='0' cellpadding='0' cellspacing='0' class='banner'><tr>
54
+ <td class="file-title"><span class="file-title-prefix">Class</span><br />PhusionPassenger::AbstractServer</td>
55
+ <td align="right">
56
+ <table cellspacing="0" cellpadding="2">
57
+ <tr valign="top">
58
+ <td>In:</td>
59
+ <td>
60
+ <a href="../../files/lib/phusion_passenger/abstract_server_rb.html">lib/phusion_passenger/abstract_server.rb</a>
61
+ </td>
62
+ </tr>
63
+ <tr>
64
+ <td>Parent:</td>
65
+ <td>
66
+ Object
67
+ </td>
68
+ </tr>
69
+ </table>
70
+ </td>
71
+ </tr>
72
+ </table>
73
+ <!-- banner header -->
74
+
75
+ <div id="bodyContent">
76
+ <div id="content">
77
+
78
+ <div class="description"><p>
79
+ An abstract base class for a <a
80
+ href="AbstractServer.html#M000140">server</a>, with the following
81
+ properties:
82
+ </p>
83
+ <ul>
84
+ <li>The <a href="AbstractServer.html#M000140">server</a> has exactly one <a
85
+ href="AbstractServer.html#M000141">client</a>, and is connected to that <a
86
+ href="AbstractServer.html#M000141">client</a> at all times. The <a
87
+ href="AbstractServer.html#M000140">server</a> will quit when the connection
88
+ closes.
89
+
90
+ </li>
91
+ <li>The <a href="AbstractServer.html#M000140">server</a>&#8216;s main loop may
92
+ be run in a child process (and so is asynchronous from the main process).
93
+
94
+ </li>
95
+ <li>One can communicate with the <a
96
+ href="AbstractServer.html#M000140">server</a> through discrete messages (as
97
+ opposed to byte streams).
98
+
99
+ </li>
100
+ <li>The <a href="AbstractServer.html#M000140">server</a> can pass file
101
+ descriptors (<a href="../IO.html">IO</a> objects) back to the <a
102
+ href="AbstractServer.html#M000141">client</a>.
103
+
104
+ </li>
105
+ </ul>
106
+ <p>
107
+ A message is just an ordered list of strings. The first element in the
108
+ message is the _message name_.
109
+ </p>
110
+ <p>
111
+ The <a href="AbstractServer.html#M000140">server</a> will also reset all
112
+ signal handlers (in the child process). That is, it will respond to all
113
+ signals in the default manner. The only exception is SIGHUP, which is
114
+ ignored. One may define additional signal handlers using <a
115
+ href="AbstractServer.html#M000139">define_signal_handler</a>().
116
+ </p>
117
+ <p>
118
+ Before an <a href="AbstractServer.html">AbstractServer</a> can be used, it
119
+ must first be started by calling <a
120
+ href="AbstractServer.html#M000130">start</a>(). When it is no longer
121
+ needed, <a href="AbstractServer.html#M000132">stop</a>() should be called.
122
+ </p>
123
+ <p>
124
+ Here&#8216;s an example on using <a
125
+ href="AbstractServer.html">AbstractServer</a>:
126
+ </p>
127
+ <pre>
128
+ class MyServer &lt; PhusionPassenger::AbstractServer
129
+ def initialize
130
+ super()
131
+ define_message_handler(:hello, :handle_hello)
132
+ end
133
+
134
+ def hello(first_name, last_name)
135
+ send_to_server('hello', first_name, last_name)
136
+ reply, pointless_number = recv_from_server
137
+ puts &quot;The server said: #{reply}&quot;
138
+ puts &quot;In addition, it sent this pointless number: #{pointless_number}&quot;
139
+ end
140
+
141
+ private
142
+ def handle_hello(first_name, last_name)
143
+ send_to_client(&quot;Hello #{first_name} #{last_name}, how are you?&quot;, 1234)
144
+ end
145
+ end
146
+
147
+ server = MyServer.new
148
+ server.start
149
+ server.hello(&quot;Joe&quot;, &quot;Dalton&quot;)
150
+ server.stop
151
+ </pre>
152
+ </div>
153
+
154
+
155
+
156
+ <div class="sectiontitle">Methods</div>
157
+ <ul>
158
+ <li><a href="#M000135">before_fork</a></li>
159
+ <li><a href="#M000141">client</a></li>
160
+ <li><a href="#M000138">define_message_handler</a></li>
161
+ <li><a href="#M000139">define_signal_handler</a></li>
162
+ <li><a href="#M000143">fileno_of</a></li>
163
+ <li><a href="#M000137">finalize_server</a></li>
164
+ <li><a href="#M000136">initialize_server</a></li>
165
+ <li><a href="#M000129">new</a></li>
166
+ <li><a href="#M000142">quit_main</a></li>
167
+ <li><a href="#M000140">server</a></li>
168
+ <li><a href="#M000134">server_pid</a></li>
169
+ <li><a href="#M000130">start</a></li>
170
+ <li><a href="#M000131">start_synchronously</a></li>
171
+ <li><a href="#M000133">started?</a></li>
172
+ <li><a href="#M000132">stop</a></li>
173
+ </ul>
174
+
175
+ <div class="sectiontitle">Included Modules</div>
176
+ <ul>
177
+ <li><a href="Utils.html">Utils</a></li>
178
+ </ul>
179
+
180
+
181
+ <div class="sectiontitle">Classes and Modules</div>
182
+ Class <a href="AbstractServer/ServerAlreadyStarted.html" class="link">PhusionPassenger::AbstractServer::ServerAlreadyStarted</a><br />
183
+ Class <a href="AbstractServer/ServerError.html" class="link">PhusionPassenger::AbstractServer::ServerError</a><br />
184
+ Class <a href="AbstractServer/ServerNotStarted.html" class="link">PhusionPassenger::AbstractServer::ServerNotStarted</a><br />
185
+ Class <a href="AbstractServer/UnknownMessage.html" class="link">PhusionPassenger::AbstractServer::UnknownMessage</a><br />
186
+
187
+
188
+ <div class="sectiontitle">Constants</div>
189
+ <table border='0' cellpadding='5'>
190
+ <tr valign='top'>
191
+ <td class="attr-name">SERVER_TERMINATION_SIGNAL</td>
192
+ <td>=</td>
193
+ <td class="attr-value">&quot;SIGTERM&quot;</td>
194
+ </tr>
195
+ </table>
196
+
197
+ <div class="sectiontitle">Attributes</div>
198
+ <table border='0' cellpadding='5'>
199
+ <tr valign='top'>
200
+ <td class='attr-rw'>
201
+ [RW]
202
+ </td>
203
+ <td class='attr-name'>last_activity_time</td>
204
+ <td class='attr-desc'>
205
+ The last time when this <a href="AbstractServer.html">AbstractServer</a>
206
+ had processed a message.
207
+
208
+ </td>
209
+ </tr>
210
+ <tr valign='top'>
211
+ <td class='attr-rw'>
212
+ [RW]
213
+ </td>
214
+ <td class='attr-name'>max_idle_time</td>
215
+ <td class='attr-desc'>
216
+ The maximum time that this <a href="AbstractServer.html">AbstractServer</a>
217
+ may be idle. Used by <a
218
+ href="AbstractServerCollection.html">AbstractServerCollection</a> to
219
+ determine when this object should be cleaned up. nil or 0 indicate that
220
+ this object should never be idle cleaned.
221
+
222
+ </td>
223
+ </tr>
224
+ <tr valign='top'>
225
+ <td class='attr-rw'>
226
+ [RW]
227
+ </td>
228
+ <td class='attr-name'>next_cleaning_time</td>
229
+ <td class='attr-desc'>
230
+ Used by <a
231
+ href="AbstractServerCollection.html">AbstractServerCollection</a> to
232
+ remember when this <a href="AbstractServer.html">AbstractServer</a> should
233
+ be idle cleaned.
234
+
235
+ </td>
236
+ </tr>
237
+ </table>
238
+
239
+ <div class="sectiontitle">Public Class methods</div>
240
+ <div class="method">
241
+ <div class="title">
242
+ <a name="M000129"></a><b>new</b>()
243
+ </div>
244
+ <div class="sourcecode">
245
+ <p class="source-link">[ <a href="javascript:toggleSource('M000129_source')" id="l_M000129_source">show source</a> ]</p>
246
+ <div id="M000129_source" class="dyn-source">
247
+ <pre>
248
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/abstract_server.rb, line 108</span>
249
+ 108: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>
250
+ 109: <span class="ruby-ivar">@done</span> = <span class="ruby-keyword kw">false</span>
251
+ 110: <span class="ruby-ivar">@message_handlers</span> = {}
252
+ 111: <span class="ruby-ivar">@signal_handlers</span> = {}
253
+ 112: <span class="ruby-ivar">@orig_signal_handlers</span> = {}
254
+ 113: <span class="ruby-ivar">@last_activity_time</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
255
+ 114: <span class="ruby-keyword kw">end</span>
256
+ </pre>
257
+ </div>
258
+ </div>
259
+ </div>
260
+ <div class="sectiontitle">Public Instance methods</div>
261
+ <div class="method">
262
+ <div class="title">
263
+ <a name="M000134"></a><b>server_pid</b>()
264
+ </div>
265
+ <div class="description">
266
+ <p>
267
+ Return the PID of the started <a
268
+ href="AbstractServer.html#M000140">server</a>. This is only valid if <a
269
+ href="AbstractServer.html#M000130">start</a>() has been called.
270
+ </p>
271
+ </div>
272
+ <div class="sourcecode">
273
+ <p class="source-link">[ <a href="javascript:toggleSource('M000134_source')" id="l_M000134_source">show source</a> ]</p>
274
+ <div id="M000134_source" class="dyn-source">
275
+ <pre>
276
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/abstract_server.rb, line 243</span>
277
+ 243: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">server_pid</span>
278
+ 244: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@pid</span>
279
+ 245: <span class="ruby-keyword kw">end</span>
280
+ </pre>
281
+ </div>
282
+ </div>
283
+ </div>
284
+ <div class="method">
285
+ <div class="title">
286
+ <a name="M000130"></a><b>start</b>()
287
+ </div>
288
+ <div class="description">
289
+ <p>
290
+ Start the <a href="AbstractServer.html#M000140">server</a>. This method
291
+ does not block since the <a href="AbstractServer.html#M000140">server</a>
292
+ runs asynchronously from the current process.
293
+ </p>
294
+ <p>
295
+ You may only call this method if the <a
296
+ href="AbstractServer.html#M000140">server</a> is not already started.
297
+ Otherwise, a <a
298
+ href="AbstractServer/ServerAlreadyStarted.html">ServerAlreadyStarted</a>
299
+ will be raised.
300
+ </p>
301
+ <p>
302
+ Derived classes may raise additional exceptions.
303
+ </p>
304
+ </div>
305
+ <div class="sourcecode">
306
+ <p class="source-link">[ <a href="javascript:toggleSource('M000130_source')" id="l_M000130_source">show source</a> ]</p>
307
+ <div id="M000130_source" class="dyn-source">
308
+ <pre>
309
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/abstract_server.rb, line 123</span>
310
+ 123: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">start</span>
311
+ 124: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">started?</span>
312
+ 125: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ServerAlreadyStarted</span>, <span class="ruby-value str">&quot;Server is already started&quot;</span>
313
+ 126: <span class="ruby-keyword kw">end</span>
314
+ 127:
315
+ 128: <span class="ruby-ivar">@parent_socket</span>, <span class="ruby-ivar">@child_socket</span> = <span class="ruby-constant">UNIXSocket</span>.<span class="ruby-identifier">pair</span>
316
+ 129: <span class="ruby-identifier">before_fork</span>
317
+ 130: <span class="ruby-ivar">@pid</span> = <span class="ruby-identifier">fork</span>
318
+ 131: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@pid</span>.<span class="ruby-identifier">nil?</span>
319
+ 132: <span class="ruby-keyword kw">begin</span>
320
+ 133: <span class="ruby-constant">STDOUT</span>.<span class="ruby-identifier">sync</span> = <span class="ruby-keyword kw">true</span>
321
+ 134: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">sync</span> = <span class="ruby-keyword kw">true</span>
322
+ 135: <span class="ruby-ivar">@parent_socket</span>.<span class="ruby-identifier">close</span>
323
+ 136:
324
+ 137: <span class="ruby-comment cmt"># During Passenger's early days, we used to close file descriptors based</span>
325
+ 138: <span class="ruby-comment cmt"># on a white list of file descriptors. That proved to be way too fragile:</span>
326
+ 139: <span class="ruby-comment cmt"># too many file descriptors are being left open even though they shouldn't</span>
327
+ 140: <span class="ruby-comment cmt"># be. So now we close file descriptors based on a black list.</span>
328
+ 141: <span class="ruby-comment cmt">#</span>
329
+ 142: <span class="ruby-comment cmt"># Note that STDIN, STDOUT and STDERR may be temporarily set to</span>
330
+ 143: <span class="ruby-comment cmt"># different file descriptors than 0, 1 and 2, e.g. in unit tests.</span>
331
+ 144: <span class="ruby-comment cmt"># We don't want to close these either.</span>
332
+ 145: <span class="ruby-identifier">file_descriptors_to_leave_open</span> = [<span class="ruby-value">0</span>, <span class="ruby-value">1</span>, <span class="ruby-value">2</span>, <span class="ruby-ivar">@child_socket</span>.<span class="ruby-identifier">fileno</span>,
333
+ 146: <span class="ruby-identifier">fileno_of</span>(<span class="ruby-constant">STDIN</span>), <span class="ruby-identifier">fileno_of</span>(<span class="ruby-constant">STDOUT</span>), <span class="ruby-identifier">fileno_of</span>(<span class="ruby-constant">STDERR</span>)].<span class="ruby-identifier">compact</span>.<span class="ruby-identifier">uniq</span>
334
+ 147: <span class="ruby-constant">NativeSupport</span>.<span class="ruby-identifier">close_all_file_descriptors</span>(<span class="ruby-identifier">file_descriptors_to_leave_open</span>)
335
+ 148: <span class="ruby-comment cmt"># In addition to closing the file descriptors, one must also close</span>
336
+ 149: <span class="ruby-comment cmt"># the associated IO objects. This is to prevent IO.close from</span>
337
+ 150: <span class="ruby-comment cmt"># double-closing already closed file descriptors.</span>
338
+ 151: <span class="ruby-identifier">close_all_io_objects_for_fds</span>(<span class="ruby-identifier">file_descriptors_to_leave_open</span>)
339
+ 152:
340
+ 153: <span class="ruby-comment cmt"># At this point, RubyGems might have open file handles for which</span>
341
+ 154: <span class="ruby-comment cmt"># the associated file descriptors have just been closed. This can</span>
342
+ 155: <span class="ruby-comment cmt"># result in mysterious 'EBADFD' errors. So we force RubyGems to</span>
343
+ 156: <span class="ruby-comment cmt"># clear all open file handles.</span>
344
+ 157: <span class="ruby-constant">Gem</span>.<span class="ruby-identifier">clear_paths</span>
345
+ 158:
346
+ 159: <span class="ruby-comment cmt"># Reseed pseudo-random number generator for security reasons.</span>
347
+ 160: <span class="ruby-identifier">srand</span>
348
+ 161:
349
+ 162: <span class="ruby-identifier">start_synchronously</span>(<span class="ruby-ivar">@child_socket</span>)
350
+ 163: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Interrupt</span>
351
+ 164: <span class="ruby-comment cmt"># Do nothing.</span>
352
+ 165: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">SignalException</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">signal</span>
353
+ 166: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">signal</span>.<span class="ruby-identifier">message</span> <span class="ruby-operator">==</span> <span class="ruby-constant">SERVER_TERMINATION_SIGNAL</span>
354
+ 167: <span class="ruby-comment cmt"># Do nothing.</span>
355
+ 168: <span class="ruby-keyword kw">else</span>
356
+ 169: <span class="ruby-identifier">print_exception</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">signal</span>)
357
+ 170: <span class="ruby-keyword kw">end</span>
358
+ 171: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
359
+ 172: <span class="ruby-identifier">print_exception</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">e</span>)
360
+ 173: <span class="ruby-keyword kw">ensure</span>
361
+ 174: <span class="ruby-identifier">exit!</span>
362
+ 175: <span class="ruby-keyword kw">end</span>
363
+ 176: <span class="ruby-keyword kw">end</span>
364
+ 177: <span class="ruby-ivar">@child_socket</span>.<span class="ruby-identifier">close</span>
365
+ 178: <span class="ruby-ivar">@parent_channel</span> = <span class="ruby-constant">MessageChannel</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@parent_socket</span>)
366
+ 179: <span class="ruby-keyword kw">end</span>
367
+ </pre>
368
+ </div>
369
+ </div>
370
+ </div>
371
+ <div class="method">
372
+ <div class="title">
373
+ <a name="M000131"></a><b>start_synchronously</b>(socket)
374
+ </div>
375
+ <div class="description">
376
+ <p>
377
+ Start the <a href="AbstractServer.html#M000140">server</a>, but in the
378
+ current process instead of in a child process. This method blocks until the
379
+ <a href="AbstractServer.html#M000140">server</a>&#8216;s main loop has
380
+ ended.
381
+ </p>
382
+ <p>
383
+ <em>socket</em> is the socket that the <a
384
+ href="AbstractServer.html#M000140">server</a> should listen on. The <a
385
+ href="AbstractServer.html#M000140">server</a> main loop will end if the
386
+ socket has been closed.
387
+ </p>
388
+ <p>
389
+ All hooks will be called, except <a
390
+ href="AbstractServer.html#M000135">before_fork</a>().
391
+ </p>
392
+ </div>
393
+ <div class="sourcecode">
394
+ <p class="source-link">[ <a href="javascript:toggleSource('M000131_source')" id="l_M000131_source">show source</a> ]</p>
395
+ <div id="M000131_source" class="dyn-source">
396
+ <pre>
397
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/abstract_server.rb, line 188</span>
398
+ 188: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">start_synchronously</span>(<span class="ruby-identifier">socket</span>)
399
+ 189: <span class="ruby-ivar">@child_socket</span> = <span class="ruby-identifier">socket</span>
400
+ 190: <span class="ruby-ivar">@child_channel</span> = <span class="ruby-constant">MessageChannel</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">socket</span>)
401
+ 191: <span class="ruby-keyword kw">begin</span>
402
+ 192: <span class="ruby-identifier">reset_signal_handlers</span>
403
+ 193: <span class="ruby-identifier">initialize_server</span>
404
+ 194: <span class="ruby-keyword kw">begin</span>
405
+ 195: <span class="ruby-identifier">main_loop</span>
406
+ 196: <span class="ruby-keyword kw">ensure</span>
407
+ 197: <span class="ruby-identifier">finalize_server</span>
408
+ 198: <span class="ruby-keyword kw">end</span>
409
+ 199: <span class="ruby-keyword kw">ensure</span>
410
+ 200: <span class="ruby-identifier">revert_signal_handlers</span>
411
+ 201: <span class="ruby-keyword kw">end</span>
412
+ 202: <span class="ruby-keyword kw">end</span>
413
+ </pre>
414
+ </div>
415
+ </div>
416
+ </div>
417
+ <div class="method">
418
+ <div class="title">
419
+ <a name="M000133"></a><b>started?</b>()
420
+ </div>
421
+ <div class="description">
422
+ <p>
423
+ Return whether the <a href="AbstractServer.html#M000140">server</a> has
424
+ been started.
425
+ </p>
426
+ </div>
427
+ <div class="sourcecode">
428
+ <p class="source-link">[ <a href="javascript:toggleSource('M000133_source')" id="l_M000133_source">show source</a> ]</p>
429
+ <div id="M000133_source" class="dyn-source">
430
+ <pre>
431
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/abstract_server.rb, line 238</span>
432
+ 238: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">started?</span>
433
+ 239: <span class="ruby-keyword kw">return</span> <span class="ruby-operator">!</span><span class="ruby-ivar">@parent_channel</span>.<span class="ruby-identifier">nil?</span>
434
+ 240: <span class="ruby-keyword kw">end</span>
435
+ </pre>
436
+ </div>
437
+ </div>
438
+ </div>
439
+ <div class="method">
440
+ <div class="title">
441
+ <a name="M000132"></a><b>stop</b>()
442
+ </div>
443
+ <div class="description">
444
+ <p>
445
+ Stop the <a href="AbstractServer.html#M000140">server</a>. The <a
446
+ href="AbstractServer.html#M000140">server</a> will quit as soon as
447
+ possible. This method waits until the <a
448
+ href="AbstractServer.html#M000140">server</a> has been stopped.
449
+ </p>
450
+ <p>
451
+ When calling this method, the <a
452
+ href="AbstractServer.html#M000140">server</a> must already be started. If
453
+ not, a <a href="AbstractServer/ServerNotStarted.html">ServerNotStarted</a>
454
+ will be raised.
455
+ </p>
456
+ </div>
457
+ <div class="sourcecode">
458
+ <p class="source-link">[ <a href="javascript:toggleSource('M000132_source')" id="l_M000132_source">show source</a> ]</p>
459
+ <div id="M000132_source" class="dyn-source">
460
+ <pre>
461
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/abstract_server.rb, line 209</span>
462
+ 209: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stop</span>
463
+ 210: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">started?</span>
464
+ 211: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ServerNotStarted</span>, <span class="ruby-value str">&quot;Server is not started&quot;</span>
465
+ 212: <span class="ruby-keyword kw">end</span>
466
+ 213:
467
+ 214: <span class="ruby-ivar">@parent_socket</span>.<span class="ruby-identifier">close</span>
468
+ 215: <span class="ruby-ivar">@parent_channel</span> = <span class="ruby-keyword kw">nil</span>
469
+ 216:
470
+ 217: <span class="ruby-comment cmt"># Wait at most 3 seconds for server to exit. If it doesn't do that,</span>
471
+ 218: <span class="ruby-comment cmt"># we kill it. If that doesn't work either, we kill it forcefully with</span>
472
+ 219: <span class="ruby-comment cmt"># SIGKILL.</span>
473
+ 220: <span class="ruby-keyword kw">begin</span>
474
+ 221: <span class="ruby-constant">Timeout</span><span class="ruby-operator">::</span><span class="ruby-identifier">timeout</span>(<span class="ruby-value">3</span>) <span class="ruby-keyword kw">do</span>
475
+ 222: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">waitpid</span>(<span class="ruby-ivar">@pid</span>) <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
476
+ 223: <span class="ruby-keyword kw">end</span>
477
+ 224: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Timeout</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span>
478
+ 225: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">kill</span>(<span class="ruby-constant">SERVER_TERMINATION_SIGNAL</span>, <span class="ruby-ivar">@pid</span>) <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
479
+ 226: <span class="ruby-keyword kw">begin</span>
480
+ 227: <span class="ruby-constant">Timeout</span><span class="ruby-operator">::</span><span class="ruby-identifier">timeout</span>(<span class="ruby-value">3</span>) <span class="ruby-keyword kw">do</span>
481
+ 228: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">waitpid</span>(<span class="ruby-ivar">@pid</span>) <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
482
+ 229: <span class="ruby-keyword kw">end</span>
483
+ 230: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Timeout</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span>
484
+ 231: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">kill</span>(<span class="ruby-value str">'SIGKILL'</span>, <span class="ruby-ivar">@pid</span>) <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
485
+ 232: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">waitpid</span>(<span class="ruby-ivar">@pid</span>, <span class="ruby-constant">Process</span><span class="ruby-operator">::</span><span class="ruby-constant">WNOHANG</span>) <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
486
+ 233: <span class="ruby-keyword kw">end</span>
487
+ 234: <span class="ruby-keyword kw">end</span>
488
+ 235: <span class="ruby-keyword kw">end</span>
489
+ </pre>
490
+ </div>
491
+ </div>
492
+ </div>
493
+ <div class="sectiontitle">Protected Instance methods</div>
494
+ <div class="method">
495
+ <div class="title">
496
+ <a name="M000135"></a><b>before_fork</b>()
497
+ </div>
498
+ <div class="description">
499
+ <p>
500
+ A hook which is called when the <a
501
+ href="AbstractServer.html#M000140">server</a> is being started, just before
502
+ forking a <a href="AbstractServer.html#M000129">new</a> process. The
503
+ default implementation does nothing, this method is supposed to be
504
+ overrided by child classes.
505
+ </p>
506
+ </div>
507
+ <div class="sourcecode">
508
+ <p class="source-link">[ <a href="javascript:toggleSource('M000135_source')" id="l_M000135_source">show source</a> ]</p>
509
+ <div id="M000135_source" class="dyn-source">
510
+ <pre>
511
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/abstract_server.rb, line 250</span>
512
+ 250: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">before_fork</span>
513
+ 251: <span class="ruby-keyword kw">end</span>
514
+ </pre>
515
+ </div>
516
+ </div>
517
+ </div>
518
+ <div class="method">
519
+ <div class="title">
520
+ <a name="M000141"></a><b>client</b>()
521
+ </div>
522
+ <div class="description">
523
+ <p>
524
+ Return the communication channel with the <a
525
+ href="AbstractServer.html#M000141">client</a> (i.e. the parent process that
526
+ started the <a href="AbstractServer.html#M000140">server</a>). This is a <a
527
+ href="MessageChannel.html">MessageChannel</a> object.
528
+ </p>
529
+ </div>
530
+ <div class="sourcecode">
531
+ <p class="source-link">[ <a href="javascript:toggleSource('M000141_source')" id="l_M000141_source">show source</a> ]</p>
532
+ <div id="M000141_source" class="dyn-source">
533
+ <pre>
534
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/abstract_server.rb, line 295</span>
535
+ 295: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">client</span>
536
+ 296: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@child_channel</span>
537
+ 297: <span class="ruby-keyword kw">end</span>
538
+ </pre>
539
+ </div>
540
+ </div>
541
+ </div>
542
+ <div class="method">
543
+ <div class="title">
544
+ <a name="M000138"></a><b>define_message_handler</b>(message_name, handler)
545
+ </div>
546
+ <div class="description">
547
+ <p>
548
+ Define a handler for a message. <em>message_name</em> is the name of the
549
+ message to handle, and <em>handler</em> is the name of a method to be
550
+ called (this may either be a String or a Symbol).
551
+ </p>
552
+ <p>
553
+ A message is just a list of strings, and so <em>handler</em> will be called
554
+ with the message as its arguments, excluding the first element. See also
555
+ the example in the class description.
556
+ </p>
557
+ </div>
558
+ <div class="sourcecode">
559
+ <p class="source-link">[ <a href="javascript:toggleSource('M000138_source')" id="l_M000138_source">show source</a> ]</p>
560
+ <div id="M000138_source" class="dyn-source">
561
+ <pre>
562
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/abstract_server.rb, line 270</span>
563
+ 270: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">define_message_handler</span>(<span class="ruby-identifier">message_name</span>, <span class="ruby-identifier">handler</span>)
564
+ 271: <span class="ruby-ivar">@message_handlers</span>[<span class="ruby-identifier">message_name</span>.<span class="ruby-identifier">to_s</span>] = <span class="ruby-identifier">handler</span>
565
+ 272: <span class="ruby-keyword kw">end</span>
566
+ </pre>
567
+ </div>
568
+ </div>
569
+ </div>
570
+ <div class="method">
571
+ <div class="title">
572
+ <a name="M000139"></a><b>define_signal_handler</b>(signal, handler)
573
+ </div>
574
+ <div class="description">
575
+ <p>
576
+ Define a handler for a signal.
577
+ </p>
578
+ </div>
579
+ <div class="sourcecode">
580
+ <p class="source-link">[ <a href="javascript:toggleSource('M000139_source')" id="l_M000139_source">show source</a> ]</p>
581
+ <div id="M000139_source" class="dyn-source">
582
+ <pre>
583
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/abstract_server.rb, line 275</span>
584
+ 275: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">define_signal_handler</span>(<span class="ruby-identifier">signal</span>, <span class="ruby-identifier">handler</span>)
585
+ 276: <span class="ruby-ivar">@signal_handlers</span>[<span class="ruby-identifier">signal</span>.<span class="ruby-identifier">to_s</span>] = <span class="ruby-identifier">handler</span>
586
+ 277: <span class="ruby-keyword kw">end</span>
587
+ </pre>
588
+ </div>
589
+ </div>
590
+ </div>
591
+ <div class="method">
592
+ <div class="title">
593
+ <a name="M000143"></a><b>fileno_of</b>(io)
594
+ </div>
595
+ <div class="sourcecode">
596
+ <p class="source-link">[ <a href="javascript:toggleSource('M000143_source')" id="l_M000143_source">show source</a> ]</p>
597
+ <div id="M000143_source" class="dyn-source">
598
+ <pre>
599
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/abstract_server.rb, line 304</span>
600
+ 304: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">fileno_of</span>(<span class="ruby-identifier">io</span>)
601
+ 305: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">io</span>.<span class="ruby-identifier">fileno</span>
602
+ 306: <span class="ruby-keyword kw">rescue</span>
603
+ 307: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span>
604
+ 308: <span class="ruby-keyword kw">end</span>
605
+ </pre>
606
+ </div>
607
+ </div>
608
+ </div>
609
+ <div class="method">
610
+ <div class="title">
611
+ <a name="M000137"></a><b>finalize_server</b>()
612
+ </div>
613
+ <div class="description">
614
+ <p>
615
+ A hook which is called when the <a
616
+ href="AbstractServer.html#M000140">server</a> is being stopped. This is
617
+ called in the child process, after the main loop has been left. The default
618
+ implementation does nothing, this method is supposed to be overrided by
619
+ child classes.
620
+ </p>
621
+ </div>
622
+ <div class="sourcecode">
623
+ <p class="source-link">[ <a href="javascript:toggleSource('M000137_source')" id="l_M000137_source">show source</a> ]</p>
624
+ <div id="M000137_source" class="dyn-source">
625
+ <pre>
626
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/abstract_server.rb, line 262</span>
627
+ 262: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">finalize_server</span>
628
+ 263: <span class="ruby-keyword kw">end</span>
629
+ </pre>
630
+ </div>
631
+ </div>
632
+ </div>
633
+ <div class="method">
634
+ <div class="title">
635
+ <a name="M000136"></a><b>initialize_server</b>()
636
+ </div>
637
+ <div class="description">
638
+ <p>
639
+ A hook which is called when the <a
640
+ href="AbstractServer.html#M000140">server</a> is being started. This is
641
+ called in the child process, before the main loop is entered. The default
642
+ implementation does nothing, this method is supposed to be overrided by
643
+ child classes.
644
+ </p>
645
+ </div>
646
+ <div class="sourcecode">
647
+ <p class="source-link">[ <a href="javascript:toggleSource('M000136_source')" id="l_M000136_source">show source</a> ]</p>
648
+ <div id="M000136_source" class="dyn-source">
649
+ <pre>
650
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/abstract_server.rb, line 256</span>
651
+ 256: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize_server</span>
652
+ 257: <span class="ruby-keyword kw">end</span>
653
+ </pre>
654
+ </div>
655
+ </div>
656
+ </div>
657
+ <div class="method">
658
+ <div class="title">
659
+ <a name="M000142"></a><b>quit_main</b>()
660
+ </div>
661
+ <div class="description">
662
+ <p>
663
+ Tell the main loop to <a href="AbstractServer.html#M000132">stop</a> as
664
+ soon as possible.
665
+ </p>
666
+ </div>
667
+ <div class="sourcecode">
668
+ <p class="source-link">[ <a href="javascript:toggleSource('M000142_source')" id="l_M000142_source">show source</a> ]</p>
669
+ <div id="M000142_source" class="dyn-source">
670
+ <pre>
671
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/abstract_server.rb, line 300</span>
672
+ 300: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">quit_main</span>
673
+ 301: <span class="ruby-ivar">@done</span> = <span class="ruby-keyword kw">true</span>
674
+ 302: <span class="ruby-keyword kw">end</span>
675
+ </pre>
676
+ </div>
677
+ </div>
678
+ </div>
679
+ <div class="method">
680
+ <div class="title">
681
+ <a name="M000140"></a><b>server</b>()
682
+ </div>
683
+ <div class="description">
684
+ <p>
685
+ Return the communication channel with the <a
686
+ href="AbstractServer.html#M000140">server</a>. This is a <a
687
+ href="MessageChannel.html">MessageChannel</a> object.
688
+ </p>
689
+ <p>
690
+ Raises <a href="AbstractServer/ServerNotStarted.html">ServerNotStarted</a>
691
+ if the <a href="AbstractServer.html#M000140">server</a> hasn&#8216;t been
692
+ started yet.
693
+ </p>
694
+ <p>
695
+ This method may only be called in the parent process, and not in the
696
+ started <a href="AbstractServer.html#M000140">server</a> process.
697
+ </p>
698
+ </div>
699
+ <div class="sourcecode">
700
+ <p class="source-link">[ <a href="javascript:toggleSource('M000140_source')" id="l_M000140_source">show source</a> ]</p>
701
+ <div id="M000140_source" class="dyn-source">
702
+ <pre>
703
+ <span class="ruby-comment cmt"># File lib/phusion_passenger/abstract_server.rb, line 286</span>
704
+ 286: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">server</span>
705
+ 287: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">started?</span>
706
+ 288: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ServerNotStarted</span>, <span class="ruby-value str">&quot;Server hasn't been started yet. Please call start() first.&quot;</span>
707
+ 289: <span class="ruby-keyword kw">end</span>
708
+ 290: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@parent_channel</span>
709
+ 291: <span class="ruby-keyword kw">end</span>
710
+ </pre>
711
+ </div>
712
+ </div>
713
+ </div>
714
+ </div>
715
+
716
+ </div>
717
+
718
+ </body>
719
+ </html>