passenger 5.2.3 → 5.3.0

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 (241) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +13 -0
  3. data/CONTRIBUTORS +5 -1
  4. data/build/agent.rb +22 -2
  5. data/build/cxx_tests.rb +41 -5
  6. data/build/misc.rb +4 -1
  7. data/build/support/cxx_dependency_map.rb +1746 -908
  8. data/build/support/vendor/cxx_hinted_parser/CxxHintedParser.sublime-project +8 -0
  9. data/build/support/vendor/cxx_hinted_parser/Gemfile +5 -0
  10. data/build/support/vendor/cxx_hinted_parser/Gemfile.lock +30 -0
  11. data/{src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core → build/support/vendor/cxx_hinted_parser}/LICENSE.md +1 -1
  12. data/build/support/vendor/cxx_hinted_parser/README.md +95 -0
  13. data/build/support/vendor/cxx_hinted_parser/Rakefile +4 -0
  14. data/{src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/initialize.rb → build/support/vendor/cxx_hinted_parser/lib/cxx_hinted_parser.rb} +2 -9
  15. data/build/support/vendor/cxx_hinted_parser/lib/cxx_hinted_parser/parser.rb +239 -0
  16. data/dev/ci/README.md +15 -2
  17. data/dev/ci/lib/set-container-envvars.sh +6 -0
  18. data/dev/ci/lib/setup-container.sh +4 -1
  19. data/dev/ci/scripts/debug-console-wrapper.sh +3 -1
  20. data/dev/ci/setup-host +5 -0
  21. data/dev/ci/tests/binaries/Jenkinsfile +105 -0
  22. data/dev/ci/tests/binaries/build-linux +38 -0
  23. data/dev/ci/tests/binaries/build-macos +40 -0
  24. data/dev/ci/tests/binaries/prepare-macos +38 -0
  25. data/dev/ci/tests/binaries/test-linux +45 -0
  26. data/dev/ci/tests/binaries/test-macos +38 -0
  27. data/dev/ci/tests/debian/Jenkinsfile +2 -2
  28. data/dev/ci/tests/rpm/Jenkinsfile +1 -1
  29. data/dev/configkit-schemas/index.json +3 -24
  30. data/dev/vagrant/nginx_rakefile +0 -1
  31. data/package.json +15 -5
  32. data/resources/templates/error_renderer/.editorconfig +19 -0
  33. data/resources/templates/error_renderer/with_details/README.md +9 -0
  34. data/resources/templates/error_renderer/with_details/dist/bundle.js +33 -0
  35. data/resources/templates/error_renderer/with_details/dist/styles.css +17 -0
  36. data/resources/templates/error_renderer/with_details/src/DetailsView.jsx +52 -0
  37. data/resources/templates/error_renderer/with_details/src/GetHelpView.jsx +61 -0
  38. data/resources/templates/error_renderer/with_details/src/JourneyView.css +50 -0
  39. data/resources/templates/error_renderer/with_details/src/JourneyView.jsx +621 -0
  40. data/resources/templates/error_renderer/with_details/src/PageMain.css +114 -0
  41. data/resources/templates/error_renderer/with_details/src/PageMain.jsx +136 -0
  42. data/resources/templates/error_renderer/with_details/src/ProblemDescriptionView.jsx +14 -0
  43. data/resources/templates/error_renderer/with_details/src/ProcessDetailsView.jsx +56 -0
  44. data/resources/templates/error_renderer/with_details/src/SolutionDescriptionView.css +5 -0
  45. data/resources/templates/error_renderer/with_details/src/SolutionDescriptionView.jsx +15 -0
  46. data/resources/templates/error_renderer/with_details/src/SummaryView.jsx +35 -0
  47. data/resources/templates/error_renderer/with_details/src/SystemComponentView.css +34 -0
  48. data/resources/templates/error_renderer/with_details/src/SystemComponentView.jsx +168 -0
  49. data/resources/templates/error_renderer/with_details/src/SystemComponentsView.css +13 -0
  50. data/resources/templates/error_renderer/with_details/src/SystemComponentsView.jsx +116 -0
  51. data/resources/templates/error_renderer/with_details/src/Tab.jsx +12 -0
  52. data/resources/templates/error_renderer/with_details/src/Tabs.jsx +104 -0
  53. data/resources/templates/error_renderer/with_details/src/bootstrap/bootstrap.css +3446 -0
  54. data/resources/templates/error_renderer/with_details/src/bootstrap/bootstrap.js +293 -0
  55. data/resources/templates/error_renderer/with_details/src/bootstrap/config.json +401 -0
  56. data/resources/templates/error_renderer/with_details/src/index.html.template +22 -0
  57. data/resources/templates/error_renderer/with_details/src/index.jsx +23 -0
  58. data/resources/templates/error_renderer/with_details/webpack.config.js +47 -0
  59. data/resources/templates/error_renderer/without_details/dist/bundle.js +1 -0
  60. data/resources/templates/error_renderer/without_details/dist/styles.css +1 -0
  61. data/resources/templates/{undisclosed_error.html.template → error_renderer/without_details/src/index.html.template} +7 -11
  62. data/resources/templates/error_renderer/without_details/src/index.js +1 -0
  63. data/resources/templates/{error_layout.css → error_renderer/without_details/src/main.css} +5 -2
  64. data/resources/templates/error_renderer/without_details/webpack.config.js +42 -0
  65. data/src/agent/AgentMain.cpp +3 -3
  66. data/src/agent/Core/ApplicationPool/BasicProcessInfo.h +13 -0
  67. data/src/agent/Core/ApplicationPool/Common.h +3 -4
  68. data/src/agent/Core/ApplicationPool/Context.h +27 -17
  69. data/src/agent/Core/ApplicationPool/Group.h +3 -1
  70. data/src/agent/Core/ApplicationPool/Group/InitializationAndShutdown.cpp +2 -12
  71. data/src/agent/Core/ApplicationPool/Group/InternalUtils.cpp +55 -10
  72. data/src/agent/Core/ApplicationPool/Group/LifetimeAndBasics.cpp +1 -1
  73. data/src/agent/Core/ApplicationPool/Group/OutOfBandWork.cpp +1 -1
  74. data/src/agent/Core/ApplicationPool/Group/SpawningAndRestarting.cpp +13 -6
  75. data/src/agent/Core/ApplicationPool/Implementation.cpp +16 -100
  76. data/src/agent/Core/ApplicationPool/Options.h +8 -65
  77. data/src/agent/Core/ApplicationPool/Pool.h +4 -21
  78. data/src/agent/Core/ApplicationPool/Pool/AnalyticsCollection.cpp +1 -60
  79. data/src/agent/Core/ApplicationPool/Pool/GeneralUtils.cpp +10 -13
  80. data/src/agent/Core/ApplicationPool/Pool/InitializationAndShutdown.cpp +3 -8
  81. data/src/agent/Core/ApplicationPool/Pool/Miscellaneous.cpp +2 -34
  82. data/src/agent/Core/ApplicationPool/Pool/StateInspection.cpp +1 -1
  83. data/src/agent/Core/ApplicationPool/Process.cpp +17 -12
  84. data/src/agent/Core/ApplicationPool/Process.h +146 -93
  85. data/src/agent/Core/ApplicationPool/Session.h +2 -2
  86. data/src/agent/Core/ApplicationPool/Socket.h +28 -27
  87. data/src/agent/Core/Config.h +1 -3
  88. data/src/agent/Core/ConfigChange.cpp +2 -4
  89. data/src/agent/Core/Controller.h +2 -8
  90. data/src/agent/Core/Controller/BufferBody.cpp +0 -2
  91. data/src/agent/Core/Controller/CheckoutSession.cpp +12 -24
  92. data/src/agent/Core/Controller/Config.h +1 -9
  93. data/src/agent/Core/Controller/ForwardResponse.cpp +0 -34
  94. data/src/agent/Core/Controller/Hooks.cpp +0 -7
  95. data/src/agent/Core/Controller/InitRequest.cpp +0 -43
  96. data/src/agent/Core/Controller/InitializationAndShutdown.cpp +0 -4
  97. data/src/agent/Core/Controller/Request.h +1 -35
  98. data/src/agent/Core/Controller/SendRequest.cpp +0 -32
  99. data/src/agent/Core/CoreMain.cpp +19 -32
  100. data/src/agent/Core/SpawningKit/Config.h +329 -55
  101. data/src/agent/Core/SpawningKit/Config/AutoGeneratedCode.h +369 -0
  102. data/src/agent/Core/SpawningKit/Config/AutoGeneratedCode.h.cxxcodebuilder +307 -0
  103. data/src/agent/Core/SpawningKit/Context.h +211 -0
  104. data/src/agent/Core/SpawningKit/DirectSpawner.h +112 -122
  105. data/src/agent/Core/SpawningKit/DummySpawner.h +59 -20
  106. data/src/agent/Core/SpawningKit/ErrorRenderer.h +117 -0
  107. data/src/agent/Core/SpawningKit/Exceptions.h +1157 -0
  108. data/src/agent/Core/SpawningKit/Factory.h +24 -17
  109. data/src/agent/Core/SpawningKit/{BackgroundIOCapturer.h → Handshake/BackgroundIOCapturer.h} +48 -18
  110. data/src/agent/Core/SpawningKit/Handshake/Perform.h +1650 -0
  111. data/src/agent/Core/SpawningKit/Handshake/Prepare.h +582 -0
  112. data/src/agent/Core/SpawningKit/Handshake/Session.h +91 -0
  113. data/src/agent/Core/SpawningKit/Handshake/WorkDir.h +100 -0
  114. data/src/agent/Core/SpawningKit/Journey.h +561 -0
  115. data/src/agent/Core/SpawningKit/PipeWatcher.h +41 -18
  116. data/src/agent/Core/SpawningKit/README.md +534 -0
  117. data/src/agent/Core/SpawningKit/Result.h +182 -7
  118. data/src/agent/Core/SpawningKit/Result/AutoGeneratedCode.h +69 -0
  119. data/src/agent/Core/SpawningKit/Result/AutoGeneratedCode.h.cxxcodebuilder +110 -0
  120. data/src/agent/Core/SpawningKit/SmartSpawner.h +1027 -562
  121. data/src/agent/Core/SpawningKit/Spawner.h +70 -1134
  122. data/src/agent/Core/SpawningKit/UserSwitchingRules.h +3 -33
  123. data/src/agent/README.md +2 -3
  124. data/src/agent/Shared/ApiServerUtils.h +2 -3
  125. data/src/agent/SpawnEnvSetupper/SpawnEnvSetupperMain.cpp +932 -0
  126. data/src/agent/Watchdog/Config.h +1 -3
  127. data/src/agent/Watchdog/WatchdogMain.cpp +2 -1
  128. data/src/apache2_module/ConfigGeneral/AutoGeneratedDefinitions.cpp +5 -0
  129. data/src/apache2_module/ConfigGeneral/AutoGeneratedManifestDefaultsInitialization.cpp +5 -0
  130. data/src/apache2_module/ConfigGeneral/ManifestGeneration.h +22 -13
  131. data/src/apache2_module/DirConfig/AutoGeneratedCreateFunction.cpp +5 -0
  132. data/src/apache2_module/DirConfig/AutoGeneratedHeaderSerialization.cpp +3 -0
  133. data/src/apache2_module/DirConfig/AutoGeneratedManifestGeneration.cpp +13 -0
  134. data/src/apache2_module/DirConfig/AutoGeneratedMergeFunction.cpp +7 -0
  135. data/src/apache2_module/DirConfig/AutoGeneratedStruct.h +13 -0
  136. data/src/cxx_supportlib/Constants.h +3 -1
  137. data/src/cxx_supportlib/Exceptions.h +0 -121
  138. data/src/cxx_supportlib/LoggingKit/Implementation.cpp +7 -6
  139. data/src/cxx_supportlib/LoggingKit/Logging.h +3 -1
  140. data/src/cxx_supportlib/Utils.cpp +42 -0
  141. data/src/cxx_supportlib/Utils.h +7 -0
  142. data/src/cxx_supportlib/Utils/IOUtils.cpp +58 -0
  143. data/src/cxx_supportlib/Utils/IOUtils.h +13 -0
  144. data/src/cxx_supportlib/Utils/JsonUtils.h +130 -23
  145. data/src/cxx_supportlib/Utils/ScopeGuard.h +9 -4
  146. data/src/cxx_supportlib/Utils/StrIntUtils.cpp +7 -0
  147. data/src/cxx_supportlib/Utils/StrIntUtils.h +1 -0
  148. data/src/cxx_supportlib/Utils/SystemTime.h +1 -1
  149. data/src/cxx_supportlib/Utils/Timer.h +1 -1
  150. data/src/cxx_supportlib/WebSocketCommandReverseServer.h +6 -4
  151. data/src/cxx_supportlib/vendor-copy/adhoc_lve.h +1 -0
  152. data/src/helper-scripts/node-loader.js +54 -59
  153. data/src/helper-scripts/rack-loader.rb +63 -60
  154. data/src/helper-scripts/rack-preloader.rb +125 -72
  155. data/src/helper-scripts/wsgi-loader.py +100 -43
  156. data/src/nginx_module/ConfigGeneral/AutoGeneratedDefinitions.c +120 -112
  157. data/src/nginx_module/ConfigGeneral/AutoGeneratedManifestDefaultsInitialization.c +15 -8
  158. data/src/nginx_module/ConfigGeneral/AutoGeneratedSetterFuncs.c +142 -142
  159. data/src/nginx_module/ConfigGeneral/ManifestGeneration.c +26 -15
  160. data/src/nginx_module/ConfigGeneral/ManifestGeneration.h +3 -0
  161. data/src/nginx_module/LocationConfig/AutoGeneratedCreateFunction.c +76 -70
  162. data/src/nginx_module/LocationConfig/AutoGeneratedHeaderSerialization.c +114 -99
  163. data/src/nginx_module/LocationConfig/AutoGeneratedManifestGeneration.c +170 -156
  164. data/src/nginx_module/LocationConfig/AutoGeneratedMergeFunction.c +38 -35
  165. data/src/nginx_module/LocationConfig/AutoGeneratedStruct.h +5 -1
  166. data/src/ruby_supportlib/phusion_passenger.rb +5 -5
  167. data/src/ruby_supportlib/phusion_passenger/admin_tools/instance.rb +14 -1
  168. data/src/ruby_supportlib/phusion_passenger/apache2/config_options.rb +8 -0
  169. data/src/ruby_supportlib/phusion_passenger/common_library.rb +0 -3
  170. data/src/ruby_supportlib/phusion_passenger/config/nginx_engine_compiler.rb +0 -1
  171. data/src/ruby_supportlib/phusion_passenger/constants.rb +2 -0
  172. data/src/ruby_supportlib/phusion_passenger/loader_shared_helpers.rb +646 -238
  173. data/src/ruby_supportlib/phusion_passenger/nginx/config_options.rb +117 -95
  174. data/src/ruby_supportlib/phusion_passenger/packaging.rb +0 -1
  175. data/src/ruby_supportlib/phusion_passenger/platform_info/depcheck_specs/apache2.rb +5 -1
  176. data/src/ruby_supportlib/phusion_passenger/preloader_shared_helpers.rb +92 -69
  177. data/src/ruby_supportlib/phusion_passenger/public_api.rb +0 -17
  178. data/src/ruby_supportlib/phusion_passenger/rack/thread_handler_extension.rb +0 -3
  179. data/src/ruby_supportlib/phusion_passenger/request_handler.rb +4 -5
  180. data/src/ruby_supportlib/phusion_passenger/request_handler/thread_handler.rb +0 -22
  181. metadata +64 -67
  182. data/resources/templates/error_layout.html.template +0 -86
  183. data/resources/templates/general_error.html.template +0 -1
  184. data/resources/templates/general_error_with_html.html.template +0 -1
  185. data/src/agent/Core/ApplicationPool/ErrorRenderer.h +0 -131
  186. data/src/agent/Core/SpawningKit/Options.h +0 -41
  187. data/src/agent/Core/UnionStation/Connection.h +0 -173
  188. data/src/agent/Core/UnionStation/Context.h +0 -536
  189. data/src/agent/Core/UnionStation/StopwatchLog.h +0 -147
  190. data/src/agent/Core/UnionStation/Transaction.h +0 -249
  191. data/src/agent/SpawnPreparer/SpawnPreparerMain.cpp +0 -208
  192. data/src/cxx_supportlib/UnionStationFilterSupport.cpp +0 -67
  193. data/src/cxx_supportlib/UnionStationFilterSupport.h +0 -1622
  194. data/src/nodejs_supportlib/phusion_passenger/log_express.js +0 -106
  195. data/src/nodejs_supportlib/phusion_passenger/log_mongodb.js +0 -202
  196. data/src/nodejs_supportlib/phusion_passenger/ustreporter.js +0 -227
  197. data/src/nodejs_supportlib/phusion_passenger/ustrouter_connector.js +0 -448
  198. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/CONFIG.md +0 -37
  199. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/Gemfile +0 -17
  200. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/Gemfile.lock +0 -59
  201. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/README-API.md +0 -5
  202. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/README.md +0 -117
  203. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/Rakefile +0 -115
  204. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core.rb +0 -423
  205. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/api.rb +0 -238
  206. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/connection.rb +0 -67
  207. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/context.rb +0 -281
  208. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/lock.rb +0 -62
  209. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/log.rb +0 -66
  210. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/message_channel.rb +0 -157
  211. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter.rb +0 -150
  212. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/basics.rb +0 -199
  213. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/controllers.rb +0 -187
  214. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/misc.rb +0 -303
  215. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/view_rendering.rb +0 -91
  216. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/simple_json.rb +0 -396
  217. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/spec_helper.rb +0 -279
  218. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/time_point.rb +0 -39
  219. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/transaction.rb +0 -173
  220. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/utils.rb +0 -177
  221. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/version.rb +0 -32
  222. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/version_data.rb +0 -44
  223. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/ruby_versions.yml.example +0 -16
  224. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/ruby_versions.yml.travis +0 -20
  225. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/ruby_versions.yml.travis-with-sudo +0 -18
  226. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/union_station_hooks_core.gemspec +0 -23
  227. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/Gemfile +0 -14
  228. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/Gemfile.lock +0 -45
  229. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/LICENSE.md +0 -19
  230. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/README.md +0 -104
  231. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/Rakefile +0 -160
  232. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails.rb +0 -200
  233. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/action_controller_extension.rb +0 -45
  234. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/action_view_subscriber.rb +0 -55
  235. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/active_record_subscriber.rb +0 -41
  236. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/active_support_benchmarkable_extension.rb +0 -47
  237. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/active_support_cache_subscriber.rb +0 -79
  238. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/exception_logger.rb +0 -57
  239. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/version.rb +0 -32
  240. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/version_data.rb +0 -44
  241. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/union_station_hooks_rails.gemspec +0 -34
@@ -96,7 +96,7 @@ Group::getPallocPool() const {
96
96
 
97
97
  const ResourceLocator &
98
98
  Group::getResourceLocator() const {
99
- return *getPool()->getSpawningKitConfig()->resourceLocator;
99
+ return *getPool()->getSpawningKitContext()->resourceLocator;
100
100
  }
101
101
 
102
102
 
@@ -209,7 +209,7 @@ Group::spawnThreadOOBWRequest(GroupPtr self, ProcessPtr process) {
209
209
 
210
210
  assert(process->oobwStatus == Process::OOBW_IN_PROGRESS);
211
211
  assert(process->sessions == 0);
212
- socket = process->findSessionSocketWithLowestBusyness();
212
+ socket = process->findSocketsAcceptingHttpRequestsAndWithLowestBusyness();
213
213
  }
214
214
 
215
215
  UPDATE_TRACE_POINT();
@@ -96,14 +96,21 @@ Group::spawnThreadRealMain(const SpawningKit::SpawnerPtr &spawner,
96
96
  boost::this_thread::restore_interruption ri(di);
97
97
  boost::this_thread::restore_syscall_interruption rsi(dsi);
98
98
  if (shouldFail) {
99
- SpawnException e("Simulated failure");
100
- processAndLogNewSpawnException(e, options, pool->getSpawningKitConfig());
101
- throw e;
99
+ SpawningKit::Journey journey(SpawningKit::SPAWN_DIRECTLY, false);
100
+ SpawningKit::Config config;
101
+ journey.setStepErrored(SpawningKit::SPAWNING_KIT_PREPARATION, true);
102
+ SpawningKit::SpawnException e(SpawningKit::INTERNAL_ERROR,
103
+ journey, &config);
104
+ e.setSummary("Simulated failure");
105
+ throw e.finalize();
102
106
  } else {
103
- process = createProcessObject(spawner->spawn(options));
107
+ process = createProcessObject(*spawner, spawner->spawn(options));
104
108
  }
105
- } catch (const thread_interrupted &) {
109
+ } catch (const boost::thread_interrupted &) {
106
110
  break;
111
+ } catch (SpawningKit::SpawnException &e) {
112
+ processAndLogNewSpawnException(e, options, pool->getContext());
113
+ exception = copyException(e);
107
114
  } catch (const tracable_exception &e) {
108
115
  exception = copyException(e);
109
116
  // Let other (unexpected) exceptions crash the program so
@@ -316,7 +323,7 @@ Group::restart(const Options &options, RestartMethod method) {
316
323
  boost::bind(&Group::finalizeRestart, this, shared_from_this(),
317
324
  this->options.copyAndPersist().clearPerRequestFields(),
318
325
  options.copyAndPersist().clearPerRequestFields(),
319
- method, getContext()->getSpawningKitFactory(),
326
+ method, getContext()->spawningKitFactory,
320
327
  restartsInitiated, actions),
321
328
  "Group restarter: " + getName(),
322
329
  POOL_HELPER_THREAD_STACK_SIZE
@@ -45,8 +45,6 @@
45
45
  #include <Utils/JsonUtils.h>
46
46
  #include <Core/ApplicationPool/Pool.h>
47
47
  #include <Core/ApplicationPool/Group.h>
48
- #include <Core/ApplicationPool/Process.cpp>
49
- #include <Core/ApplicationPool/ErrorRenderer.h>
50
48
  #include <Core/ApplicationPool/Pool/InitializationAndShutdown.cpp>
51
49
  #include <Core/ApplicationPool/Pool/AnalyticsCollection.cpp>
52
50
  #include <Core/ApplicationPool/Pool/GarbageCollection.cpp>
@@ -65,6 +63,8 @@
65
63
  #include <Core/ApplicationPool/Group/InternalUtils.cpp>
66
64
  #include <Core/ApplicationPool/Group/StateInspection.cpp>
67
65
  #include <Core/ApplicationPool/Group/Verification.cpp>
66
+ #include <Core/ApplicationPool/Process.cpp>
67
+ #include <Core/SpawningKit/ErrorRenderer.h>
68
68
 
69
69
  namespace Passenger {
70
70
  namespace ApplicationPool2 {
@@ -95,7 +95,7 @@ copyException(const tracable_exception &e) {
95
95
 
96
96
  TRY_COPY_EXCEPTION(RequestQueueFullException);
97
97
  TRY_COPY_EXCEPTION(GetAbortedException);
98
- TRY_COPY_EXCEPTION(SpawnException);
98
+ TRY_COPY_EXCEPTION(SpawningKit::SpawnException);
99
99
 
100
100
  TRY_COPY_EXCEPTION(InvalidModeStringException);
101
101
  TRY_COPY_EXCEPTION(ArgumentException);
@@ -135,7 +135,7 @@ rethrowException(const ExceptionPtr &e) {
135
135
 
136
136
  TRY_RETHROW_EXCEPTION(ConfigurationException);
137
137
 
138
- TRY_RETHROW_EXCEPTION(SpawnException);
138
+ TRY_RETHROW_EXCEPTION(SpawningKit::SpawnException);
139
139
  TRY_RETHROW_EXCEPTION(RequestQueueFullException);
140
140
  TRY_RETHROW_EXCEPTION(GetAbortedException);
141
141
 
@@ -165,47 +165,27 @@ rethrowException(const ExceptionPtr &e) {
165
165
  throw tracable_exception(*e);
166
166
  }
167
167
 
168
- void processAndLogNewSpawnException(SpawnException &e, const Options &options,
169
- const SpawningKit::ConfigPtr &config)
168
+ void processAndLogNewSpawnException(SpawningKit::SpawnException &e, const Options &options,
169
+ const Context *context)
170
170
  {
171
171
  TRACE_POINT();
172
- UnionStation::TransactionPtr transaction;
173
- ErrorRenderer renderer(*config->resourceLocator);
174
- string appMessage = e.getErrorPage();
172
+ SpawningKit::ErrorRenderer renderer(*context->getSpawningKitContext());
175
173
  string errorId;
176
174
  char filename[PATH_MAX];
177
175
  stringstream stream;
178
-
179
- if (options.analytics && config->unionStationContext != NULL) {
180
- try {
181
- UPDATE_TRACE_POINT();
182
- transaction = config->unionStationContext->newTransaction(
183
- options.getAppGroupName(),
184
- "exceptions",
185
- options.unionStationKey);
186
- errorId = transaction->getTxnId();
187
- } catch (const tracable_exception &e2) {
188
- transaction.reset();
189
- P_WARN("Cannot log to Union Station: " << e2.what() <<
190
- "\n Backtrace:\n" << e2.backtrace());
191
- }
192
- }
176
+ string errorPage;
193
177
 
194
178
  UPDATE_TRACE_POINT();
195
- if (appMessage.empty()) {
196
- appMessage = "none";
197
- }
198
179
  if (errorId.empty()) {
199
- errorId = config->randomGenerator->generateHexString(4);
180
+ errorId = context->getRandomGenerator()->generateHexString(4);
200
181
  }
201
- e.set("error_id", errorId);
182
+ e.setId(errorId);
202
183
 
203
184
  try {
204
185
  int fd = -1;
205
- string errorPage;
206
186
 
207
187
  UPDATE_TRACE_POINT();
208
- errorPage = renderer.renderWithDetails(appMessage, options, &e);
188
+ errorPage = renderer.renderWithDetails(e);
209
189
 
210
190
  #if (defined(__linux__) && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 11))) || defined(__APPLE__) || defined(__FreeBSD__)
211
191
  snprintf(filename, PATH_MAX, "%s/passenger-error-XXXXXX.html",
@@ -231,69 +211,6 @@ void processAndLogNewSpawnException(SpawnException &e, const Options &options,
231
211
  e2.backtrace());
232
212
  }
233
213
 
234
- if (transaction != NULL) {
235
- try {
236
- UPDATE_TRACE_POINT();
237
- transaction->message("Context: spawning");
238
- transaction->message("Message: " +
239
- jsonString(e.what()));
240
- transaction->message("App message: " +
241
- jsonString(appMessage));
242
-
243
- const char *kind;
244
- switch (e.getErrorKind()) {
245
- case SpawnException::PRELOADER_STARTUP_ERROR:
246
- kind = "PRELOADER_STARTUP_ERROR";
247
- break;
248
- case SpawnException::PRELOADER_STARTUP_PROTOCOL_ERROR:
249
- kind = "PRELOADER_STARTUP_PROTOCOL_ERROR";
250
- break;
251
- case SpawnException::PRELOADER_STARTUP_TIMEOUT:
252
- kind = "PRELOADER_STARTUP_TIMEOUT";
253
- break;
254
- case SpawnException::PRELOADER_STARTUP_EXPLAINABLE_ERROR:
255
- kind = "PRELOADER_STARTUP_EXPLAINABLE_ERROR";
256
- break;
257
- case SpawnException::APP_STARTUP_ERROR:
258
- kind = "APP_STARTUP_ERROR";
259
- break;
260
- case SpawnException::APP_STARTUP_PROTOCOL_ERROR:
261
- kind = "APP_STARTUP_PROTOCOL_ERROR";
262
- break;
263
- case SpawnException::APP_STARTUP_TIMEOUT:
264
- kind = "APP_STARTUP_TIMEOUT";
265
- break;
266
- case SpawnException::APP_STARTUP_EXPLAINABLE_ERROR:
267
- kind = "APP_STARTUP_EXPLAINABLE_ERROR";
268
- break;
269
- default:
270
- kind = "UNDEFINED_ERROR";
271
- break;
272
- }
273
- transaction->message(string("Kind: ") + kind);
274
-
275
- Json::Value details;
276
- const map<string, string> &annotations = e.getAnnotations();
277
- map<string, string>::const_iterator it, end = annotations.end();
278
-
279
- for (it = annotations.begin(); it != end; it++) {
280
- details[it->first] = it->second;
281
- }
282
-
283
- // This information is not very useful. Union Station
284
- // already collects system metrics.
285
- details.removeMember("system_metrics");
286
- // Don't include environment variables because they may
287
- // contain sensitive information.
288
- details.removeMember("envvars");
289
-
290
- transaction->message("Details: " + stringifyJson(details));
291
- } catch (const tracable_exception &e2) {
292
- P_WARN("Cannot log to Union Station: " << e2.what() <<
293
- "\n Backtrace:\n" << e2.backtrace());
294
- }
295
- }
296
-
297
214
  UPDATE_TRACE_POINT();
298
215
  stream << "Could not spawn process for application " << options.appRoot <<
299
216
  ": " << e.what() << "\n" <<
@@ -301,21 +218,20 @@ void processAndLogNewSpawnException(SpawnException &e, const Options &options,
301
218
  if (filename[0] != '\0') {
302
219
  stream << " Error details saved to: " << filename << "\n";
303
220
  }
304
- stream << " Message from application: " << appMessage << "\n";
305
221
  P_ERROR(stream.str());
306
222
 
307
- ScopedLock l(config->agentConfigSyncher);
308
- if (!config->agentConfig.isNull()) {
223
+ ScopedLock l(context->agentConfigSyncher);
224
+ if (!context->agentConfig.isNull()) {
309
225
  HookScriptOptions hOptions;
310
226
  hOptions.name = "spawn_failed";
311
- hOptions.spec = config->agentConfig.get("hook_spawn_failed", Json::Value()).asString();
312
- hOptions.agentConfig = config->agentConfig;
227
+ hOptions.spec = context->agentConfig.get("hook_spawn_failed", Json::Value()).asString();
228
+ hOptions.agentConfig = context->agentConfig;
313
229
  l.unlock();
314
230
  hOptions.environment.push_back(make_pair("PASSENGER_APP_ROOT", options.appRoot));
315
231
  hOptions.environment.push_back(make_pair("PASSENGER_APP_GROUP_NAME", options.getAppGroupName()));
316
232
  hOptions.environment.push_back(make_pair("PASSENGER_ERROR_MESSAGE", e.what()));
317
233
  hOptions.environment.push_back(make_pair("PASSENGER_ERROR_ID", errorId));
318
- hOptions.environment.push_back(make_pair("PASSENGER_APP_ERROR_MESSAGE", appMessage));
234
+ hOptions.environment.push_back(make_pair("PASSENGER_ERROR_PAGE", errorPage));
319
235
  oxt::thread(boost::bind(runHookScripts, hOptions),
320
236
  "Hook: spawn_failed", 256 * 1024);
321
237
  }
@@ -37,8 +37,6 @@
37
37
  #include <StaticString.h>
38
38
  #include <FileTools/PathManip.h>
39
39
  #include <Utils.h>
40
- #include <Core/UnionStation/Context.h>
41
- #include <Core/UnionStation/Transaction.h>
42
40
 
43
41
  namespace Passenger {
44
42
  namespace ApplicationPool2 {
@@ -112,14 +110,10 @@ private:
112
110
  result.push_back(&options.meteorAppSettings);
113
111
 
114
112
  result.push_back(&options.environmentVariables);
115
- result.push_back(&options.ustRouterAddress);
116
- result.push_back(&options.ustRouterUsername);
117
- result.push_back(&options.ustRouterPassword);
118
113
  result.push_back(&options.apiKey);
119
114
  result.push_back(&options.groupUuid);
120
115
  result.push_back(&options.hostName);
121
116
  result.push_back(&options.uri);
122
- result.push_back(&options.unionStationKey);
123
117
 
124
118
  return result;
125
119
  }
@@ -311,23 +305,6 @@ public:
311
305
 
312
306
  bool userSwitching;
313
307
 
314
- /** Whether Union Station logging should be enabled. Enabling this option will
315
- * result in:
316
- *
317
- * - The application enabling its Union Station support.
318
- * - Periodic tasks such as `collectAnalytics()` to log things to Union Station.
319
- *
320
- * It does *not* necessarily result in a request logging data to Union Station.
321
- * That depends on whether the `transaction` member is set.
322
- *
323
- * If this is set to true, then 'ustRouterAddress', 'ustRouterUsername'
324
- * and 'ustRouterPassword' must be non-empty.
325
- */
326
- bool analytics;
327
- StaticString ustRouterAddress;
328
- StaticString ustRouterUsername;
329
- StaticString ustRouterPassword;
330
-
331
308
  /**
332
309
  * Whether Spawner should raise an internal error when spawning. Used
333
310
  * during unit tests.
@@ -376,19 +353,6 @@ public:
376
353
  */
377
354
  bool abortWebsocketsOnProcessShutdown;
378
355
 
379
- /**
380
- * The Union Station key to use in case analytics logging is enabled.
381
- * It is used by Pool::collectAnalytics() and other administrative
382
- * functions which are called periodically. Because they do not belong
383
- * to any request, and they may still want to log to Union Station,
384
- * this key is stored in the per-group options structure.
385
- *
386
- * It is not used on a per-request basis. Per-request analytics logging
387
- * (and Union Station logging) uses the logger object in the `logger` field
388
- * instead.
389
- */
390
- StaticString unionStationKey;
391
-
392
356
  /*-----------------*/
393
357
 
394
358
 
@@ -404,18 +368,6 @@ public:
404
368
  /** Current request URI. */
405
369
  StaticString uri;
406
370
 
407
- /**
408
- * The Union Station log transaction that this request belongs to.
409
- * May be the null pointer, in which case Union Station logging is
410
- * disabled for this request.
411
- *
412
- * When an Options object is passed to another thread (either direct or through
413
- * a copy), the caller should call `detachFromUnionStationTransaction()`.
414
- * Each Union Station transaction object is only supposed to be used in the same
415
- * thread.
416
- */
417
- UnionStation::TransactionPtr transaction;
418
-
419
371
  /**
420
372
  * A sticky session ID for routing to a specific process.
421
373
  */
@@ -493,7 +445,6 @@ public:
493
445
  debugger(false),
494
446
  loadShellEnvvars(true),
495
447
  userSwitching(true),
496
- analytics(false),
497
448
  raiseInternalError(false),
498
449
 
499
450
  minProcesses(1),
@@ -579,11 +530,6 @@ public:
579
530
  stickySessionId = 0;
580
531
  currentTime = 0;
581
532
  noop = false;
582
- return detachFromUnionStationTransaction();
583
- }
584
-
585
- Options &detachFromUnionStationTransaction() {
586
- transaction.reset();
587
533
  return *this;
588
534
  }
589
535
 
@@ -626,11 +572,7 @@ public:
626
572
  appendKeyValue (vec, "python", python);
627
573
  appendKeyValue (vec, "nodejs", nodejs);
628
574
  appendKeyValue (vec, "meteor_app_settings", meteorAppSettings);
629
- appendKeyValue (vec, "ust_router_address", ustRouterAddress);
630
- appendKeyValue (vec, "ust_router_username", ustRouterUsername);
631
- appendKeyValue (vec, "ust_router_password", ustRouterPassword);
632
575
  appendKeyValue4(vec, "debugger", debugger);
633
- appendKeyValue4(vec, "analytics", analytics);
634
576
  appendKeyValue (vec, "api_key", apiKey);
635
577
 
636
578
  /*********************************/
@@ -641,9 +583,6 @@ public:
641
583
  appendKeyValue2(vec, "max_preloader_idle_time", maxPreloaderIdleTime);
642
584
  appendKeyValue3(vec, "max_out_of_band_work_instances", maxOutOfBandWorkInstances);
643
585
  }
644
- if ((fields & SPAWN_OPTIONS) || (fields & PER_GROUP_POOL_OPTIONS)) {
645
- appendKeyValue (vec, "union_station_key", unionStationKey);
646
- }
647
586
 
648
587
  /*********************************/
649
588
  }
@@ -677,13 +616,17 @@ public:
677
616
 
678
617
  string getStartCommand(const ResourceLocator &resourceLocator) const {
679
618
  if (appType == P_STATIC_STRING("rack")) {
680
- return ruby + "\t" + resourceLocator.getHelperScriptsDir() + "/rack-loader.rb";
619
+ return escapeShell(ruby) + " "
620
+ + escapeShell(resourceLocator.getHelperScriptsDir() + "/rack-loader.rb");
681
621
  } else if (appType == P_STATIC_STRING("wsgi")) {
682
- return python + "\t" + resourceLocator.getHelperScriptsDir() + "/wsgi-loader.py";
622
+ return escapeShell(python) + " "
623
+ + escapeShell(resourceLocator.getHelperScriptsDir() + "/wsgi-loader.py");
683
624
  } else if (appType == P_STATIC_STRING("node")) {
684
- return nodejs + "\t" + resourceLocator.getHelperScriptsDir() + "/node-loader.js";
625
+ return escapeShell(nodejs) + " "
626
+ + escapeShell(resourceLocator.getHelperScriptsDir() + "/node-loader.js");
685
627
  } else if (appType == P_STATIC_STRING("meteor")) {
686
- return ruby + "\t" + resourceLocator.getHelperScriptsDir() + "/meteor-loader.rb";
628
+ return escapeShell(ruby) + " "
629
+ + escapeShell(resourceLocator.getHelperScriptsDir() + "/meteor-loader.rb");
687
630
  } else {
688
631
  return startCommand;
689
632
  }
@@ -59,7 +59,6 @@
59
59
  #include <Utils/VariantMap.h>
60
60
  #include <Utils/ProcessMetricsCollector.h>
61
61
  #include <Utils/SystemMetricsCollector.h>
62
- #include <Core/UnionStation/StopwatchLog.h>
63
62
  #include <Core/ApplicationPool/Common.h>
64
63
  #include <Core/ApplicationPool/Context.h>
65
64
  #include <Core/ApplicationPool/Process.h>
@@ -211,7 +210,7 @@ public:
211
210
  unsigned long long maxIdleTime;
212
211
  bool selfchecking;
213
212
 
214
- Context context;
213
+ Context *context;
215
214
 
216
215
  /**
217
216
  * Code can register background threads in one of these dynamic thread groups
@@ -273,8 +272,6 @@ public:
273
272
  */
274
273
  vector<GetWaiter> getWaitlist;
275
274
 
276
- Json::Value agentConfig;
277
-
278
275
  // Actually private, but marked public so that unit tests can access the fields.
279
276
  public:
280
277
  /****** Debugging support *******/
@@ -315,13 +312,6 @@ public:
315
312
 
316
313
  /****** Analytics collection ******/
317
314
 
318
- struct UnionStationLogEntry {
319
- string groupName;
320
- const char *category;
321
- string key;
322
- string data;
323
- };
324
-
325
315
  SystemMetricsCollector systemMetricsCollector;
326
316
  SystemMetrics systemMetrics;
327
317
 
@@ -331,10 +321,6 @@ public:
331
321
  static void updateProcessMetrics(const ProcessList &processes,
332
322
  const ProcessMetricMap &allMetrics,
333
323
  vector<ProcessPtr> &processesToDetach);
334
- void prepareUnionStationProcessStateLogs(vector<UnionStationLogEntry> &logEntries,
335
- const GroupPtr &group) const;
336
- void prepareUnionStationSystemMetricsLogs(vector<UnionStationLogEntry> &logEntries,
337
- const GroupPtr &group) const;
338
324
  void realCollectAnalytics();
339
325
 
340
326
 
@@ -448,8 +434,7 @@ public:
448
434
 
449
435
  /****** Initialization and shutdown ******/
450
436
 
451
- Pool(const SpawningKit::FactoryPtr &spawningKitFactory,
452
- const Json::Value &agentConfig = Json::Value());
437
+ Pool(Context *context);
453
438
  ~Pool();
454
439
  void initialize();
455
440
  void initDebugging();
@@ -460,8 +445,7 @@ public:
460
445
  /****** General utilities ******/
461
446
 
462
447
  Context *getContext();
463
- const SpawningKit::ConfigPtr &getSpawningKitConfig() const;
464
- const UnionStation::ContextPtr &getUnionStationContext() const;
448
+ SpawningKit::Context *getSpawningKitContext() const;
465
449
  const RandomGeneratorPtr &getRandomGenerator() const;
466
450
 
467
451
 
@@ -506,12 +490,11 @@ public:
506
490
 
507
491
  /****** Miscellaneous ******/
508
492
 
509
- void asyncGet(const Options &options, const GetCallback &callback, bool lockNow = true, UnionStation::StopwatchLog **stopwatchLog = NULL);
493
+ void asyncGet(const Options &options, const GetCallback &callback, bool lockNow = true);
510
494
  SessionPtr get(const Options &options, Ticket *ticket);
511
495
  void setMax(unsigned int max);
512
496
  void setMaxIdleTime(unsigned long long value);
513
497
  void enableSelfChecking(bool enabled);
514
- void setAgentConfig(const Json::Value &agentConfig);
515
498
  bool isSpawning(bool lock = true) const;
516
499
  bool authorizeByApiKey(const ApiKey &key, bool lock = true) const;
517
500
  bool authorizeByUid(uid_t uid, bool lock = true) const;