passenger 5.3.4 → 6.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (283) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +69 -0
  3. data/CONTRIBUTORS +1 -0
  4. data/README.md +2 -1
  5. data/Rakefile +0 -5
  6. data/build/agent.rb +6 -3
  7. data/build/cxx_tests.rb +28 -19
  8. data/build/integration_tests.rb +6 -2
  9. data/build/misc.rb +2 -1
  10. data/build/packaging.rb +2 -0
  11. data/build/support/cplusplus.rb +2 -2
  12. data/build/support/cxx_dependency_map.rb +2651 -2189
  13. data/dev/colorize-logs +272 -0
  14. data/dev/show-latest-crashlog-dir +27 -0
  15. data/resources/templates/standalone/http.erb +2 -0
  16. data/resources/templates/standalone/server.erb +1 -0
  17. data/src/agent/AgentMain.cpp +4 -0
  18. data/src/agent/Core/AdminPanelConnector.h +6 -6
  19. data/src/agent/Core/ApiServer.h +4 -4
  20. data/src/agent/Core/ApplicationPool/BasicProcessInfo.h +2 -2
  21. data/src/agent/Core/ApplicationPool/Context.h +5 -1
  22. data/src/agent/Core/ApplicationPool/Group/InternalUtils.cpp +2 -2
  23. data/src/agent/Core/ApplicationPool/Group/LifetimeAndBasics.cpp +5 -0
  24. data/src/agent/Core/ApplicationPool/Group/Miscellaneous.cpp +2 -1
  25. data/src/agent/Core/ApplicationPool/Group/OutOfBandWork.cpp +3 -3
  26. data/src/agent/Core/ApplicationPool/Group/ProcessListManagement.cpp +1 -1
  27. data/src/agent/Core/ApplicationPool/Group/StateInspection.cpp +13 -20
  28. data/src/agent/Core/ApplicationPool/Group.h +4 -2
  29. data/src/agent/Core/ApplicationPool/Implementation.cpp +5 -5
  30. data/src/agent/Core/ApplicationPool/Options.h +42 -38
  31. data/src/agent/Core/ApplicationPool/Pool/GroupUtils.cpp +2 -1
  32. data/src/agent/Core/ApplicationPool/Pool.h +4 -4
  33. data/src/agent/Core/ApplicationPool/Process.h +13 -15
  34. data/src/agent/Core/ApplicationPool/Socket.h +5 -5
  35. data/src/agent/Core/ApplicationPool/TestSession.h +3 -3
  36. data/src/agent/Core/Config.h +50 -10
  37. data/src/agent/Core/ConfigChange.cpp +13 -1
  38. data/src/agent/Core/Controller/Config.h +41 -17
  39. data/src/agent/Core/Controller/ForwardResponse.cpp +4 -0
  40. data/src/agent/Core/Controller/InitRequest.cpp +14 -8
  41. data/src/agent/Core/Controller/InitializationAndShutdown.cpp +5 -0
  42. data/src/agent/Core/Controller/SendRequest.cpp +9 -9
  43. data/src/agent/Core/Controller/TurboCaching.h +2 -2
  44. data/src/agent/Core/Controller.h +7 -5
  45. data/src/agent/Core/CoreMain.cpp +204 -60
  46. data/src/agent/Core/OptionParser.h +20 -3
  47. data/src/agent/Core/ResponseCache.h +3 -3
  48. data/src/agent/Core/SecurityUpdateChecker.h +4 -2
  49. data/src/agent/Core/SpawningKit/Config/AutoGeneratedCode.h +1 -1
  50. data/src/agent/Core/SpawningKit/Config.h +3 -2
  51. data/src/agent/Core/SpawningKit/Context.h +8 -2
  52. data/src/agent/Core/SpawningKit/DirectSpawner.h +4 -4
  53. data/src/agent/Core/SpawningKit/DummySpawner.h +3 -3
  54. data/src/agent/Core/SpawningKit/ErrorRenderer.h +1 -1
  55. data/src/agent/Core/SpawningKit/Exceptions.h +21 -14
  56. data/src/agent/Core/SpawningKit/Factory.h +1 -1
  57. data/src/agent/Core/SpawningKit/Handshake/BackgroundIOCapturer.h +1 -1
  58. data/src/agent/Core/SpawningKit/Handshake/Perform.h +14 -2
  59. data/src/agent/Core/SpawningKit/Handshake/Prepare.h +3 -3
  60. data/src/agent/Core/SpawningKit/Handshake/WorkDir.h +1 -1
  61. data/src/agent/Core/SpawningKit/Journey.h +4 -5
  62. data/src/agent/Core/SpawningKit/PipeWatcher.h +1 -1
  63. data/src/agent/Core/SpawningKit/README.md +34 -17
  64. data/src/agent/Core/SpawningKit/Result/AutoGeneratedCode.h +1 -1
  65. data/src/agent/Core/SpawningKit/Result.h +20 -8
  66. data/src/agent/Core/SpawningKit/SmartSpawner.h +7 -7
  67. data/src/agent/Core/SpawningKit/Spawner.h +25 -8
  68. data/src/agent/Core/SpawningKit/UserSwitchingRules.h +17 -7
  69. data/src/agent/Core/TelemetryCollector.h +681 -0
  70. data/src/agent/ExecHelper/ExecHelperMain.cpp +1 -1
  71. data/src/agent/FileReadHelper/FileReadHelperMain.cpp +198 -0
  72. data/src/agent/README.md +1 -1
  73. data/src/agent/Shared/ApiAccountUtils.h +1 -1
  74. data/src/agent/Shared/ApiServerUtils.h +3 -3
  75. data/src/agent/Shared/ApplicationPoolApiKey.h +2 -2
  76. data/src/agent/Shared/Fundamentals/AbortHandler.cpp +324 -98
  77. data/src/agent/Shared/Fundamentals/AbortHandler.h +31 -4
  78. data/src/agent/Shared/Fundamentals/Initialization.cpp +4 -5
  79. data/src/agent/Shared/Fundamentals/Initialization.h +9 -1
  80. data/src/agent/SpawnEnvSetupper/SpawnEnvSetupperMain.cpp +1 -1
  81. data/src/agent/SystemMetrics/SystemMetricsMain.cpp +4 -3
  82. data/src/agent/TempDirToucher/TempDirToucherMain.cpp +3 -3
  83. data/src/agent/Watchdog/ApiServer.h +3 -3
  84. data/src/agent/Watchdog/Config.h +24 -5
  85. data/src/agent/Watchdog/CoreWatcher.cpp +2 -2
  86. data/src/agent/Watchdog/WatchdogMain.cpp +97 -28
  87. data/src/apache2_module/Config.cpp +14 -14
  88. data/src/apache2_module/Config.h +8 -16
  89. data/src/apache2_module/ConfigGeneral/AutoGeneratedDefinitions.cpp +510 -481
  90. data/src/apache2_module/ConfigGeneral/AutoGeneratedDefinitions.cpp.cxxcodebuilder +39 -17
  91. data/src/apache2_module/ConfigGeneral/AutoGeneratedManifestDefaultsInitialization.cpp +5 -0
  92. data/src/apache2_module/ConfigGeneral/AutoGeneratedSetterFuncs.cpp +69 -1
  93. data/src/apache2_module/ConfigGeneral/AutoGeneratedSetterFuncs.cpp.cxxcodebuilder +31 -1
  94. data/src/apache2_module/ConfigGeneral/Common.h +45 -0
  95. data/src/apache2_module/DirConfig/AutoGeneratedCreateFunction.cpp +17 -1
  96. data/src/apache2_module/DirConfig/AutoGeneratedCreateFunction.cpp.cxxcodebuilder +16 -1
  97. data/src/apache2_module/DirConfig/AutoGeneratedHeaderSerialization.cpp +19 -5
  98. data/src/apache2_module/DirConfig/AutoGeneratedHeaderSerialization.cpp.cxxcodebuilder +26 -9
  99. data/src/apache2_module/DirConfig/AutoGeneratedManifestGeneration.cpp +19 -1
  100. data/src/apache2_module/DirConfig/AutoGeneratedManifestGeneration.cpp.cxxcodebuilder +10 -1
  101. data/src/apache2_module/DirConfig/AutoGeneratedMergeFunction.cpp +14 -1
  102. data/src/apache2_module/DirConfig/AutoGeneratedMergeFunction.cpp.cxxcodebuilder +11 -1
  103. data/src/apache2_module/DirConfig/AutoGeneratedStruct.h +36 -1
  104. data/src/apache2_module/DirConfig/AutoGeneratedStruct.h.cxxcodebuilder +34 -1
  105. data/src/apache2_module/DirectoryMapper.h +36 -37
  106. data/src/apache2_module/Hooks.cpp +27 -8
  107. data/src/apache2_module/ServerConfig/AutoGeneratedManifestGeneration.cpp +20 -0
  108. data/src/apache2_module/ServerConfig/AutoGeneratedStruct.h +48 -1
  109. data/src/apache2_module/ServerConfig/AutoGeneratedStruct.h.cxxcodebuilder +36 -1
  110. data/src/cxx_supportlib/{Utils → Algorithms}/Hasher.cpp +2 -2
  111. data/src/cxx_supportlib/{Utils → Algorithms}/Hasher.h +4 -4
  112. data/src/cxx_supportlib/AppLocalConfigFileUtils.h +148 -0
  113. data/src/cxx_supportlib/AppTypeDetector/CBindings.cpp +147 -0
  114. data/src/cxx_supportlib/AppTypeDetector/CBindings.h +75 -0
  115. data/src/cxx_supportlib/{AppTypes.h → AppTypeDetector/Detector.h} +92 -131
  116. data/src/cxx_supportlib/ConfigKit/README.md +90 -2
  117. data/src/cxx_supportlib/ConfigKit/Schema.h +60 -15
  118. data/src/cxx_supportlib/ConfigKit/Store.h +129 -5
  119. data/src/cxx_supportlib/Constants.h +1 -1
  120. data/src/cxx_supportlib/{Utils → DataStructures}/HashMap.h +4 -4
  121. data/src/cxx_supportlib/DataStructures/HashedStaticString.h +5 -5
  122. data/src/cxx_supportlib/DataStructures/LString.h +3 -3
  123. data/src/cxx_supportlib/{Utils → DataStructures}/StringMap.h +36 -36
  124. data/src/cxx_supportlib/FileTools/FileManip.cpp +1 -1
  125. data/src/cxx_supportlib/FileTools/PathManip.cpp +2 -2
  126. data/src/cxx_supportlib/FileTools/PathSecurityCheck.cpp +1 -1
  127. data/src/cxx_supportlib/Hooks.h +2 -2
  128. data/src/cxx_supportlib/{Utils → IOTools}/BufferedIO.h +5 -5
  129. data/src/cxx_supportlib/{Utils → IOTools}/IOUtils.cpp +4 -3
  130. data/src/cxx_supportlib/{Utils → IOTools}/IOUtils.h +3 -3
  131. data/src/cxx_supportlib/{Utils → IOTools}/MessageIO.h +7 -7
  132. data/src/cxx_supportlib/{MessageReadersWriters.h → IOTools/MessageSerialization.h} +5 -5
  133. data/src/cxx_supportlib/InstanceDirectory.h +4 -4
  134. data/src/cxx_supportlib/Integrations/LibevJsonUtils.h +3 -3
  135. data/src/cxx_supportlib/{Utils → JsonTools}/JsonUtils.h +5 -5
  136. data/src/cxx_supportlib/LoggingKit/Context.h +2 -2
  137. data/src/cxx_supportlib/LoggingKit/Implementation.cpp +3 -3
  138. data/src/cxx_supportlib/MemoryKit/mbuf.cpp +2 -2
  139. data/src/cxx_supportlib/ProcessManagement/Ruby.cpp +3 -3
  140. data/src/cxx_supportlib/ProcessManagement/Ruby.h +7 -2
  141. data/src/cxx_supportlib/ProcessManagement/Spawn.cpp +19 -12
  142. data/src/cxx_supportlib/ProcessManagement/Spawn.h +21 -2
  143. data/src/cxx_supportlib/ProcessManagement/Utils.h +10 -0
  144. data/src/cxx_supportlib/RandomGenerator.h +2 -2
  145. data/src/cxx_supportlib/ResourceLocator.h +1 -1
  146. data/src/cxx_supportlib/{Crypto.cpp → SecurityKit/Crypto.cpp} +4 -4
  147. data/src/cxx_supportlib/{Crypto.h → SecurityKit/Crypto.h} +4 -4
  148. data/src/cxx_supportlib/{Utils → SecurityKit}/MemZeroGuard.h +0 -0
  149. data/src/cxx_supportlib/ServerKit/AcceptLoadBalancer.h +2 -2
  150. data/src/cxx_supportlib/ServerKit/Channel.h +1 -1
  151. data/src/cxx_supportlib/ServerKit/ClientRef.h +17 -7
  152. data/src/cxx_supportlib/ServerKit/Context.h +2 -2
  153. data/src/cxx_supportlib/ServerKit/FileBufferedChannel.h +1 -1
  154. data/src/cxx_supportlib/ServerKit/HttpHeaderParser.h +3 -3
  155. data/src/cxx_supportlib/ServerKit/HttpHeaderParserState.h +2 -2
  156. data/src/cxx_supportlib/ServerKit/HttpRequestRef.h +17 -7
  157. data/src/cxx_supportlib/ServerKit/HttpServer.h +16 -10
  158. data/src/cxx_supportlib/ServerKit/Server.h +3 -4
  159. data/src/cxx_supportlib/{Utils → StrIntTools}/DateParsing.h +5 -5
  160. data/src/cxx_supportlib/{Utils → StrIntTools}/StrIntUtils.cpp +3 -3
  161. data/src/cxx_supportlib/{Utils → StrIntTools}/StrIntUtils.h +0 -0
  162. data/src/cxx_supportlib/{Utils → StrIntTools}/StrIntUtilsNoStrictAliasing.cpp +12 -12
  163. data/src/cxx_supportlib/{Utils → StrIntTools}/StringScanning.h +5 -5
  164. data/src/cxx_supportlib/{Utils → StrIntTools}/Template.h +30 -5
  165. data/src/cxx_supportlib/SystemTools/ContainerHelpers.h +88 -0
  166. data/src/cxx_supportlib/{Utils → SystemTools}/ProcessMetricsCollector.h +15 -12
  167. data/src/cxx_supportlib/{Utils → SystemTools}/SystemMetricsCollector.h +3 -3
  168. data/src/cxx_supportlib/{Utils → SystemTools}/SystemTime.cpp +1 -1
  169. data/src/cxx_supportlib/{Utils → SystemTools}/SystemTime.h +0 -0
  170. data/src/cxx_supportlib/SystemTools/UserDatabase.h +1 -1
  171. data/src/cxx_supportlib/Utils/CachedFileStat.hpp +3 -3
  172. data/src/cxx_supportlib/Utils/Curl.h +2 -2
  173. data/src/cxx_supportlib/Utils/FileChangeChecker.h +2 -2
  174. data/src/cxx_supportlib/Utils/MessagePassing.h +1 -1
  175. data/src/cxx_supportlib/Utils/SpeedMeter.h +2 -2
  176. data/src/cxx_supportlib/Utils/Timer.h +2 -2
  177. data/src/cxx_supportlib/Utils/VariantMap.h +3 -3
  178. data/src/cxx_supportlib/Utils.cpp +2 -2
  179. data/src/cxx_supportlib/WatchdogLauncher.h +3 -3
  180. data/src/cxx_supportlib/WebSocketCommandReverseServer.h +1 -1
  181. data/src/cxx_supportlib/WrapperRegistry/CBindings.cpp +85 -0
  182. data/src/cxx_supportlib/{Utils/MemoryBarrier.h → WrapperRegistry/CBindings.h} +30 -27
  183. data/src/cxx_supportlib/WrapperRegistry/Entry.h +112 -0
  184. data/src/cxx_supportlib/WrapperRegistry/README.md +37 -0
  185. data/src/cxx_supportlib/WrapperRegistry/Registry.h +309 -0
  186. data/src/cxx_supportlib/vendor-modified/psg_sysqueue.h +3 -0
  187. data/src/helper-scripts/download_binaries/extconf.rb +6 -2
  188. data/src/nginx_module/ConfigGeneral/AutoGeneratedDefinitions.c +32 -0
  189. data/src/nginx_module/ConfigGeneral/AutoGeneratedManifestDefaultsInitialization.c +12 -0
  190. data/src/nginx_module/ConfigGeneral/AutoGeneratedSetterFuncs.c +36 -0
  191. data/src/nginx_module/Configuration.c +23 -3
  192. data/src/nginx_module/ContentHandler.c +331 -32
  193. data/src/nginx_module/ContentHandler.h +8 -3
  194. data/src/nginx_module/LocationConfig/AutoGeneratedCreateFunction.c +10 -0
  195. data/src/nginx_module/LocationConfig/AutoGeneratedManifestGeneration.c +27 -0
  196. data/src/nginx_module/LocationConfig/AutoGeneratedMergeFunction.c +3 -0
  197. data/src/nginx_module/LocationConfig/AutoGeneratedStruct.h +7 -0
  198. data/src/nginx_module/MainConfig/AutoGeneratedCreateFunction.c +11 -0
  199. data/src/nginx_module/MainConfig/AutoGeneratedManifestGeneration.c +23 -0
  200. data/src/nginx_module/MainConfig/AutoGeneratedStruct.h +8 -0
  201. data/src/nginx_module/config +2 -1
  202. data/src/nginx_module/ngx_http_passenger_module.c +9 -3
  203. data/src/nginx_module/ngx_http_passenger_module.h +10 -3
  204. data/src/ruby_supportlib/phusion_passenger/apache2/config_options.rb +19 -0
  205. data/src/ruby_supportlib/phusion_passenger/common_library.rb +19 -16
  206. data/src/ruby_supportlib/phusion_passenger/config/agent_compiler.rb +4 -4
  207. data/src/ruby_supportlib/phusion_passenger/config/download_agent_command.rb +6 -2
  208. data/src/ruby_supportlib/phusion_passenger/config/download_nginx_engine_command.rb +6 -2
  209. data/src/ruby_supportlib/phusion_passenger/config/nginx_engine_compiler.rb +1 -1
  210. data/src/ruby_supportlib/phusion_passenger/message_channel.rb +2 -2
  211. data/src/ruby_supportlib/phusion_passenger/native_support.rb +7 -3
  212. data/src/ruby_supportlib/phusion_passenger/nginx/config_options.rb +29 -0
  213. data/src/ruby_supportlib/phusion_passenger/packaging.rb +20 -19
  214. data/src/ruby_supportlib/phusion_passenger/platform_info/apache.rb +22 -4
  215. data/src/ruby_supportlib/phusion_passenger/platform_info/ruby.rb +33 -13
  216. data/src/ruby_supportlib/phusion_passenger/standalone/app_finder.rb +1 -0
  217. data/src/ruby_supportlib/phusion_passenger/standalone/config_options_list.rb +22 -2
  218. data/src/ruby_supportlib/phusion_passenger/standalone/start_command/builtin_engine.rb +4 -1
  219. data/src/ruby_supportlib/phusion_passenger.rb +7 -5
  220. data/src/schema_printer/SchemaPrinterMain.cpp +2 -0
  221. metadata +40 -89
  222. data/.editorconfig +0 -134
  223. data/CODE_OF_CONDUCT.md +0 -52
  224. data/dev/boost-patches/0001-Patch-boost-thread-so-that-oxt-thread-can-use-it.patch +0 -48
  225. data/dev/boost-patches/0002-Make-boost-thread_interrupted-derive-from-oxt-tracab.patch +0 -33
  226. data/dev/boost-patches/0003-Disable-a-Clang-pragma-to-prevent-warnings-on-OS-X.patch +0 -25
  227. data/dev/ci/README.md +0 -134
  228. data/dev/ci/lib/functions.sh +0 -129
  229. data/dev/ci/lib/set-container-envvars.sh +0 -53
  230. data/dev/ci/lib/setup-container.sh +0 -46
  231. data/dev/ci/run-tests-natively +0 -24
  232. data/dev/ci/run-tests-with-docker +0 -42
  233. data/dev/ci/scripts/debug-console-wrapper.sh +0 -29
  234. data/dev/ci/scripts/docker-entrypoint-stage2.sh +0 -17
  235. data/dev/ci/scripts/docker-entrypoint.sh +0 -17
  236. data/dev/ci/scripts/inituidgid +0 -17
  237. data/dev/ci/scripts/run-tests-natively-stage2.sh +0 -17
  238. data/dev/ci/scripts/setup-host-natively.sh +0 -11
  239. data/dev/ci/setup-host +0 -56
  240. data/dev/ci/tests/apache2/run +0 -6
  241. data/dev/ci/tests/apache2/setup +0 -4
  242. data/dev/ci/tests/binaries/Jenkinsfile +0 -105
  243. data/dev/ci/tests/binaries/build-linux +0 -38
  244. data/dev/ci/tests/binaries/build-macos +0 -40
  245. data/dev/ci/tests/binaries/prepare-macos +0 -38
  246. data/dev/ci/tests/binaries/test-linux +0 -45
  247. data/dev/ci/tests/binaries/test-macos +0 -38
  248. data/dev/ci/tests/cxx/run +0 -9
  249. data/dev/ci/tests/cxx/setup +0 -4
  250. data/dev/ci/tests/debian/Jenkinsfile +0 -89
  251. data/dev/ci/tests/debian/run +0 -60
  252. data/dev/ci/tests/nginx/run +0 -5
  253. data/dev/ci/tests/nginx/setup +0 -4
  254. data/dev/ci/tests/nginx-dynamic/run +0 -20
  255. data/dev/ci/tests/nginx-dynamic/setup +0 -4
  256. data/dev/ci/tests/nodejs/run +0 -4
  257. data/dev/ci/tests/nodejs/setup +0 -4
  258. data/dev/ci/tests/rpm/Jenkinsfile +0 -68
  259. data/dev/ci/tests/rpm/run +0 -63
  260. data/dev/ci/tests/ruby/run +0 -4
  261. data/dev/ci/tests/ruby/setup +0 -4
  262. data/dev/ci/tests/source-packaging/run +0 -4
  263. data/dev/ci/tests/source-packaging/setup +0 -4
  264. data/dev/ci/tests/standalone/run +0 -4
  265. data/dev/ci/tests/standalone/setup +0 -4
  266. data/dev/configkit-schemas/index.json +0 -1748
  267. data/dev/configkit-schemas/update_schema_inline_comments.rb +0 -118
  268. data/dev/rack.test/config.ru +0 -5
  269. data/dev/rack.test/public/asset.txt +0 -1
  270. data/dev/vagrant/apache_default_site.conf +0 -35
  271. data/dev/vagrant/apache_passenger.conf +0 -5
  272. data/dev/vagrant/apache_passenger.load +0 -1
  273. data/dev/vagrant/apache_ports.conf +0 -24
  274. data/dev/vagrant/apache_rack_test.conf +0 -9
  275. data/dev/vagrant/bashrc +0 -23
  276. data/dev/vagrant/nginx.conf +0 -39
  277. data/dev/vagrant/nginx_rakefile +0 -33
  278. data/dev/vagrant/nginx_start +0 -32
  279. data/dev/vagrant/provision.sh +0 -117
  280. data/dev/vagrant/sudoers.conf +0 -5
  281. data/resources/templates/error_renderer/.editorconfig +0 -19
  282. data/src/cxx_supportlib/AppTypes.cpp +0 -109
  283. data/src/cxx_supportlib/vendor-modified/SmallVector.h +0 -653
@@ -278,6 +278,7 @@ Controller::onAppSourceData(Client *client, Request *req, const MemoryKit::mbuf
278
278
  endRequestWithAppSocketReadError(&client, &req, errcode);
279
279
  return Channel::Result(0, true);
280
280
  }
281
+ break; // Never reached, shut up compiler warning.
281
282
 
282
283
  case AppResponse::PARSING_BODY_UNTIL_EOF:
283
284
  case AppResponse::UPGRADED:
@@ -305,11 +306,14 @@ Controller::onAppSourceData(Client *client, Request *req, const MemoryKit::mbuf
305
306
  endRequestWithAppSocketReadError(&client, &req, errcode);
306
307
  return Channel::Result(0, false);
307
308
  }
309
+ break; // Never reached, shut up compiler warning.
308
310
 
309
311
  default:
310
312
  P_BUG("Invalid request HTTP state " << (int) resp->httpState);
311
313
  return Channel::Result(0, false);
312
314
  }
315
+
316
+ return Channel::Result(0, false); // Never reached, shut up compiler warning.
313
317
  }
314
318
 
315
319
  void
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Phusion Passenger - https://www.phusionpassenger.com/
3
- * Copyright (c) 2011-2017 Phusion Holding B.V.
3
+ * Copyright (c) 2011-2018 Phusion Holding B.V.
4
4
  *
5
5
  * "Passenger", "Phusion Passenger" and "Union Station" are registered
6
6
  * trademarks of Phusion Holding B.V.
@@ -24,6 +24,7 @@
24
24
  * THE SOFTWARE.
25
25
  */
26
26
  #include <Core/Controller.h>
27
+ #include <AppTypeDetector/Detector.h>
27
28
 
28
29
  /*************************************************************************
29
30
  *
@@ -336,13 +337,18 @@ Controller::createNewPoolOptions(Client *client, Request *req,
336
337
 
337
338
  const LString *appType = secureHeaders.lookup("!~PASSENGER_APP_TYPE");
338
339
  if (appType == NULL || appType->size == 0) {
339
- AppTypeDetector detector;
340
- PassengerAppType type = detector.checkAppRoot(options.appRoot);
341
- if (type == PAT_NONE || type == PAT_ERROR) {
342
- disconnectWithError(&client, "client did not send a recognized !~PASSENGER_APP_TYPE header");
343
- return;
340
+ const LString *appStartCommand = secureHeaders.lookup("!~PASSENGER_APP_START_COMMAND");
341
+ if (appStartCommand == NULL || appStartCommand->size == 0) {
342
+ AppTypeDetector::Detector detector(*wrapperRegistry);
343
+ AppTypeDetector::Detector::Result result = detector.checkAppRoot(options.appRoot);
344
+ if (result.isNull()) {
345
+ disconnectWithError(&client, "client did not send a recognized !~PASSENGER_APP_TYPE header");
346
+ return;
347
+ }
348
+ options.appType = result.wrapperRegistryEntry->language;
349
+ } else {
350
+ fillPoolOption(req, options.appStartCommand, "!~PASSENGER_APP_START_COMMAND");
344
351
  }
345
- options.appType = getAppTypeName(type);
346
352
  } else {
347
353
  fillPoolOption(req, options.appType, "!~PASSENGER_APP_TYPE");
348
354
  }
@@ -359,7 +365,7 @@ Controller::createNewPoolOptions(Client *client, Request *req,
359
365
  fillPoolOption(req, options.group, "!~PASSENGER_GROUP");
360
366
  fillPoolOption(req, options.minProcesses, "!~PASSENGER_MIN_PROCESSES");
361
367
  fillPoolOption(req, options.spawnMethod, "!~PASSENGER_SPAWN_METHOD");
362
- fillPoolOption(req, options.startCommand, "!~PASSENGER_START_COMMAND");
368
+ fillPoolOption(req, options.appStartCommand, "!~PASSENGER_APP_START_COMMAND");
363
369
  fillPoolOptionSecToMsec(req, options.startTimeout, "!~PASSENGER_START_TIMEOUT");
364
370
  fillPoolOption(req, options.maxPreloaderIdleTime, "!~PASSENGER_MAX_PRELOADER_IDLE_TIME");
365
371
  fillPoolOption(req, options.maxRequestQueueSize, "!~PASSENGER_MAX_REQUEST_QUEUE_SIZE");
@@ -94,6 +94,9 @@ Controller::initialize() {
94
94
  if (resourceLocator == NULL) {
95
95
  throw RuntimeException("ResourceLocator not initialized");
96
96
  }
97
+ if (wrapperRegistry == NULL) {
98
+ throw RuntimeException("WrapperRegistry not initialized");
99
+ }
97
100
  if (appPool == NULL) {
98
101
  throw RuntimeException("AppPool not initialized");
99
102
  }
@@ -109,11 +112,13 @@ Controller::initialize() {
109
112
  string environment = config["default_environment"].asString();
110
113
  string appType = singleAppModeConfig->get("app_type").asString();
111
114
  string startupFile = singleAppModeConfig->get("startup_file").asString();
115
+ string appStartCommand = singleAppModeConfig->get("app_start_command").asString();
112
116
 
113
117
  options->appRoot = appRoot;
114
118
  options->environment = environment;
115
119
  options->appType = appType;
116
120
  options->startupFile = startupFile;
121
+ options->appStartCommand = appStartCommand;
117
122
  *options = options->copyAndPersist();
118
123
  poolOptionsCache.insert(options->getAppGroupName(), options);
119
124
  }
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Phusion Passenger - https://www.phusionpassenger.com/
3
- * Copyright (c) 2011-2017 Phusion Holding B.V.
3
+ * Copyright (c) 2011-2018 Phusion Holding B.V.
4
4
  *
5
5
  * "Passenger", "Phusion Passenger" and "Union Station" are registered
6
6
  * trademarks of Phusion Holding B.V.
@@ -24,7 +24,7 @@
24
24
  * THE SOFTWARE.
25
25
  */
26
26
  #include <Core/Controller.h>
27
- #include <Utils/SystemTime.h>
27
+ #include <SystemTools/SystemTime.h>
28
28
 
29
29
  /*************************************************************************
30
30
  *
@@ -305,13 +305,13 @@ httpHeaderToScgiUpperCase(unsigned char *data, unsigned int size) {
305
305
 
306
306
  i = imax * 8;
307
307
  switch (leftover) {
308
- case 7: *data++ = (unsigned char) toUpperMap[buf[i++]];
309
- case 6: *data++ = (unsigned char) toUpperMap[buf[i++]];
310
- case 5: *data++ = (unsigned char) toUpperMap[buf[i++]];
311
- case 4: *data++ = (unsigned char) toUpperMap[buf[i++]];
312
- case 3: *data++ = (unsigned char) toUpperMap[buf[i++]];
313
- case 2: *data++ = (unsigned char) toUpperMap[buf[i++]];
314
- case 1: *data++ = (unsigned char) toUpperMap[buf[i]];
308
+ case 7: *data++ = (unsigned char) toUpperMap[buf[i++]]; /* Falls through. */
309
+ case 6: *data++ = (unsigned char) toUpperMap[buf[i++]]; /* Falls through. */
310
+ case 5: *data++ = (unsigned char) toUpperMap[buf[i++]]; /* Falls through. */
311
+ case 4: *data++ = (unsigned char) toUpperMap[buf[i++]]; /* Falls through. */
312
+ case 3: *data++ = (unsigned char) toUpperMap[buf[i++]]; /* Falls through. */
313
+ case 2: *data++ = (unsigned char) toUpperMap[buf[i++]]; /* Falls through. */
314
+ case 1: *data++ = (unsigned char) toUpperMap[buf[i]]; /* Falls through. */
315
315
  case 0: break;
316
316
  }
317
317
  }
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Phusion Passenger - https://www.phusionpassenger.com/
3
- * Copyright (c) 2014-2017 Phusion Holding B.V.
3
+ * Copyright (c) 2014-2018 Phusion Holding B.V.
4
4
  *
5
5
  * "Passenger", "Phusion Passenger" and "Union Station" are registered
6
6
  * trademarks of Phusion Holding B.V.
@@ -35,7 +35,7 @@
35
35
  #include <ServerKit/Context.h>
36
36
  #include <Constants.h>
37
37
  #include <LoggingKit/LoggingKit.h>
38
- #include <Utils/StrIntUtils.h>
38
+ #include <StrIntTools/StrIntUtils.h>
39
39
  #include <Core/ResponseCache.h>
40
40
 
41
41
  namespace Passenger {
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Phusion Passenger - https://www.phusionpassenger.com/
3
- * Copyright (c) 2011-2017 Phusion Holding B.V.
3
+ * Copyright (c) 2011-2018 Phusion Holding B.V.
4
4
  *
5
5
  * "Passenger", "Phusion Passenger" and "Union Station" are registered
6
6
  * trademarks of Phusion Holding B.V.
@@ -62,7 +62,7 @@
62
62
  #include <cctype>
63
63
 
64
64
  #include <LoggingKit/LoggingKit.h>
65
- #include <MessageReadersWriters.h>
65
+ #include <IOTools/MessageSerialization.h>
66
66
  #include <Constants.h>
67
67
  #include <ConfigKit/ConfigKit.h>
68
68
  #include <ServerKit/Errors.h>
@@ -71,11 +71,12 @@
71
71
  #include <MemoryKit/palloc.h>
72
72
  #include <DataStructures/LString.h>
73
73
  #include <DataStructures/StringKeyTable.h>
74
+ #include <WrapperRegistry/Registry.h>
74
75
  #include <StaticString.h>
75
76
  #include <Utils.h>
76
- #include <Utils/StrIntUtils.h>
77
- #include <Utils/IOUtils.h>
78
- #include <Utils/JsonUtils.h>
77
+ #include <StrIntTools/StrIntUtils.h>
78
+ #include <IOTools/IOUtils.h>
79
+ #include <JsonTools/JsonUtils.h>
79
80
  #include <Utils/HttpConstants.h>
80
81
  #include <Utils/Timer.h>
81
82
  #include <Core/Controller/Config.h>
@@ -365,6 +366,7 @@ public:
365
366
 
366
367
  // Dependencies
367
368
  ResourceLocator *resourceLocator;
369
+ WrapperRegistry::Registry *wrapperRegistry;
368
370
  PoolPtr appPool;
369
371
 
370
372
 
@@ -81,7 +81,8 @@
81
81
  #include <ConfigKit/SubComponentUtils.h>
82
82
  #include <ServerKit/Server.h>
83
83
  #include <ServerKit/AcceptLoadBalancer.h>
84
- #include <MessageReadersWriters.h>
84
+ #include <AppTypeDetector/Detector.h>
85
+ #include <IOTools/MessageSerialization.h>
85
86
  #include <FileDescriptor.h>
86
87
  #include <ResourceLocator.h>
87
88
  #include <BackgroundEventLoop.cpp>
@@ -90,7 +91,7 @@
90
91
  #include <Exceptions.h>
91
92
  #include <Utils.h>
92
93
  #include <Utils/Timer.h>
93
- #include <Utils/MessageIO.h>
94
+ #include <IOTools/MessageIO.h>
94
95
  #include <Core/OptionParser.h>
95
96
  #include <Core/Controller.h>
96
97
  #include <Core/ApiServer.h>
@@ -98,6 +99,7 @@
98
99
  #include <Core/ConfigChange.h>
99
100
  #include <Core/ApplicationPool/Pool.h>
100
101
  #include <Core/SecurityUpdateChecker.h>
102
+ #include <Core/TelemetryCollector.h>
101
103
  #include <Core/AdminPanelConnector.h>
102
104
 
103
105
  using namespace boost;
@@ -165,6 +167,7 @@ namespace Core {
165
167
  oxt::thread *prestarterThread;
166
168
 
167
169
  SecurityUpdateChecker *securityUpdateChecker;
170
+ TelemetryCollector *telemetryCollector;
168
171
  AdminPanelConnector *adminPanelConnector;
169
172
  oxt::thread *adminPanelConnectorThread;
170
173
 
@@ -175,6 +178,7 @@ namespace Core {
175
178
  shutdownCounter(0),
176
179
  prestarterThread(NULL),
177
180
  securityUpdateChecker(NULL),
181
+ telemetryCollector(NULL),
178
182
  adminPanelConnector(NULL),
179
183
  adminPanelConnectorThread(NULL)
180
184
  /*******************/
@@ -190,6 +194,7 @@ namespace Core {
190
194
  delete adminPanelConnectorThread;
191
195
  delete adminPanelConnector;
192
196
  delete securityUpdateChecker;
197
+ delete telemetryCollector;
193
198
 
194
199
  /*******************/
195
200
  /*******************/
@@ -211,6 +216,7 @@ namespace Core {
211
216
 
212
217
  using namespace Passenger::Core;
213
218
 
219
+ static WrapperRegistry::Registry *coreWrapperRegistry;
214
220
  static Schema *coreSchema;
215
221
  static ConfigKit::Store *coreConfig;
216
222
  static WorkingObjects *workingObjects;
@@ -252,48 +258,83 @@ initializeSingleAppMode() {
252
258
  }
253
259
 
254
260
  WorkingObjects *wo = workingObjects;
255
- string appType, startupFile;
261
+ string appType, startupFile, appStartCommand;
256
262
  string appRoot = coreConfig->get("single_app_mode_app_root").asString();
257
263
 
258
- if (coreConfig->get("single_app_mode_app_type").isNull()) {
264
+ if (!coreConfig->get("single_app_mode_app_type").isNull()
265
+ && !coreConfig->get("single_app_mode_app_start_command").isNull())
266
+ {
267
+ fprintf(stderr, "ERROR: it is not allowed for both --app-type and"
268
+ " --app-start-command to be set.\n");
269
+ exit(1);
270
+ }
271
+
272
+ if (!coreConfig->get("single_app_mode_app_start_command").isNull()) {
273
+ // The config specified that this is a generic app or a Kuria app.
274
+ appStartCommand = coreConfig->get("single_app_mode_app_start_command").asString();
275
+ } else if (coreConfig->get("single_app_mode_app_type").isNull()) {
276
+ // Autodetect whether this is generic app, Kuria app or auto-supported app.
259
277
  P_DEBUG("Autodetecting application type...");
260
- AppTypeDetector detector(NULL, 0);
261
- PassengerAppType appTypeEnum = detector.checkAppRoot(appRoot);
262
- if (appTypeEnum == PAT_NONE || appTypeEnum == PAT_ERROR) {
263
- fprintf(stderr, "ERROR: unable to autodetect what kind of application "
264
- "lives in %s. Please specify information about the app using "
265
- "--app-type and --startup-file, or specify a correct location to "
266
- "the application you want to serve.\n"
267
- "Type '" SHORT_PROGRAM_NAME " core --help' for more information.\n",
268
- appRoot.c_str());
269
- exit(1);
270
- }
278
+ AppTypeDetector::Detector detector(*coreWrapperRegistry);
279
+ AppTypeDetector::Detector::Result detectorResult = detector.checkAppRoot(appRoot);
271
280
 
272
- appType = getAppTypeName(appTypeEnum);
281
+ if (!detectorResult.appStartCommand.empty()) {
282
+ // This is a generic or Kuria app.
283
+ appStartCommand = detectorResult.appStartCommand;
284
+ } else {
285
+ // This is an auto-supported app.
286
+ if (coreConfig->get("single_app_mode_app_type").isNull()) {
287
+ if (detectorResult.isNull()) {
288
+ fprintf(stderr, "ERROR: unable to autodetect what kind of application "
289
+ "lives in %s. Please specify information about the app using "
290
+ "--app-type, --startup-file and --app-start-command, or specify a "
291
+ "correct location to the application you want to serve.\n"
292
+ "Type '" SHORT_PROGRAM_NAME " core --help' for more information.\n",
293
+ appRoot.c_str());
294
+ exit(1);
295
+ }
296
+ appType = detectorResult.wrapperRegistryEntry->language;
297
+ } else {
298
+ appType = coreConfig->get("single_app_mode_app_type").asString();
299
+ }
300
+ }
273
301
  } else {
302
+ // This is an auto-supported app.
274
303
  appType = coreConfig->get("single_app_mode_app_type").asString();
275
304
  }
276
305
 
277
- if (coreConfig->get("single_app_mode_startup_file").isNull()) {
278
- startupFile = appRoot + "/" + getAppTypeStartupFile(getAppType(appType));
279
- } else {
280
- startupFile = coreConfig->get("single_app_mode_startup_file").asString();
281
- }
282
- if (!fileExists(startupFile)) {
283
- fprintf(stderr, "ERROR: unable to find expected startup file %s."
284
- " Please specify its correct path with --startup-file.\n",
285
- startupFile.c_str());
286
- exit(1);
306
+ if (!appType.empty()) {
307
+ if (coreConfig->get("single_app_mode_startup_file").isNull()) {
308
+ const WrapperRegistry::Entry &entry = coreWrapperRegistry->lookup(appType);
309
+ if (entry.defaultStartupFiles.empty()) {
310
+ startupFile = appRoot + "/";
311
+ } else {
312
+ startupFile = appRoot + "/" + entry.defaultStartupFiles[0];
313
+ }
314
+ } else {
315
+ startupFile = coreConfig->get("single_app_mode_startup_file").asString();
316
+ }
317
+ if (!fileExists(startupFile)) {
318
+ fprintf(stderr, "ERROR: unable to find expected startup file %s."
319
+ " Please specify its correct path with --startup-file.\n",
320
+ startupFile.c_str());
321
+ exit(1);
322
+ }
287
323
  }
288
324
 
289
325
  wo->singleAppModeConfig["app_root"] = appRoot;
290
- wo->singleAppModeConfig["app_type"] = appType;
291
- wo->singleAppModeConfig["startup_file"] = startupFile;
292
326
 
293
327
  P_NOTICE(SHORT_PROGRAM_NAME " core running in single-application mode.");
294
- P_NOTICE("Serving app : " << appRoot);
295
- P_NOTICE("App type : " << appType);
296
- P_NOTICE("App startup file: " << startupFile);
328
+ P_NOTICE("Serving app : " << appRoot);
329
+ if (!appType.empty()) {
330
+ P_NOTICE("App type : " << appType);
331
+ P_NOTICE("App startup file : " << startupFile);
332
+ wo->singleAppModeConfig["app_type"] = appType;
333
+ wo->singleAppModeConfig["startup_file"] = startupFile;
334
+ } else {
335
+ P_NOTICE("App start command: " << appStartCommand);
336
+ wo->singleAppModeConfig["app_start_command"] = appStartCommand;
337
+ }
297
338
  }
298
339
 
299
340
  static void
@@ -551,39 +592,62 @@ printInfoInThread() {
551
592
  }
552
593
 
553
594
  static void
554
- dumpDiagnosticsOnCrash(void *userData) {
555
- WorkingObjects *wo = workingObjects;
556
- unsigned int i;
557
-
558
- cerr << "### Backtraces\n";
595
+ dumpOxtBacktracesOnCrash(void *userData) {
559
596
  cerr << oxt::thread::all_backtraces();
560
597
  cerr.flush();
598
+ }
599
+
600
+ static void
601
+ dumpControllerStatesOnCrash(void *userData) {
602
+ WorkingObjects *wo = workingObjects;
603
+ unsigned int i;
561
604
 
562
605
  for (i = 0; i < wo->threadWorkingObjects.size(); i++) {
563
606
  ThreadWorkingObjects *two = &wo->threadWorkingObjects[i];
564
- cerr << "### Request handler state (thread " << (i + 1) << ")\n";
607
+ cerr << "####### Controller state (thread " << (i + 1) << ") #######\n";
565
608
  cerr << two->controller->inspectStateAsJson();
566
- cerr << "\n";
609
+ cerr << "\n\n";
567
610
  cerr.flush();
568
611
  }
612
+ }
613
+
614
+ static void
615
+ dumpControllerConfigsOnCrash(void *userData) {
616
+ WorkingObjects *wo = workingObjects;
617
+ unsigned int i;
569
618
 
570
619
  for (i = 0; i < wo->threadWorkingObjects.size(); i++) {
571
620
  ThreadWorkingObjects *two = &wo->threadWorkingObjects[i];
572
- cerr << "### Request handler config (thread " << (i + 1) << ")\n";
621
+ cerr << "####### Controller config (thread " << (i + 1) << ") #######\n";
573
622
  cerr << two->controller->inspectConfig();
574
- cerr << "\n";
623
+ cerr << "\n\n";
575
624
  cerr.flush();
576
625
  }
626
+ }
627
+
628
+ static void
629
+ dumpPoolStateOnCrash(void *userData) {
630
+ WorkingObjects *wo = workingObjects;
577
631
 
578
- cerr << "### Pool state (simple)\n";
632
+ cerr << "####### Pool state (simple) #######\n";
579
633
  // Do not lock, the crash may occur within the pool.
580
634
  Pool::InspectOptions options(Pool::InspectOptions::makeAuthorized());
581
635
  options.verbose = true;
582
636
  cerr << wo->appPool->inspect(options, false);
583
- cerr << "\n";
637
+ cerr << "\n\n";
584
638
  cerr.flush();
585
639
 
586
- cerr << "### mbuf stats\n\n";
640
+ cerr << "####### Pool state (XML) #######\n";
641
+ Pool::ToXmlOptions options2(Pool::ToXmlOptions::makeAuthorized());
642
+ options2.secrets = true;
643
+ cerr << wo->appPool->toXml(options2, false);
644
+ cerr << "\n\n";
645
+ cerr.flush();
646
+ }
647
+
648
+ static void
649
+ dumpMbufStatsOnCrash(void *userData) {
650
+ WorkingObjects *wo = workingObjects;
587
651
  cerr << "nfree_mbuf_blockq : " <<
588
652
  wo->threadWorkingObjects[0].serverKitContext->mbuf_pool.nfree_mbuf_blockq << "\n";
589
653
  cerr << "nactive_mbuf_blockq: " <<
@@ -592,13 +656,6 @@ dumpDiagnosticsOnCrash(void *userData) {
592
656
  wo->threadWorkingObjects[0].serverKitContext->mbuf_pool.mbuf_block_chunk_size << "\n";
593
657
  cerr << "\n";
594
658
  cerr.flush();
595
-
596
- cerr << "### Pool state (XML)\n";
597
- Pool::ToXmlOptions options2(Pool::ToXmlOptions::makeAuthorized());
598
- options2.secrets = true;
599
- cerr << wo->appPool->toXml(options2, false);
600
- cerr << "\n\n";
601
- cerr.flush();
602
659
  }
603
660
 
604
661
  static void
@@ -653,6 +710,7 @@ initializeNonPrivilegedWorkingObjects() {
653
710
  wo->spawningKitContext = boost::make_shared<SpawningKit::Context>(
654
711
  wo->spawningKitContextSchema);
655
712
  wo->spawningKitContext->resourceLocator = &wo->resourceLocator;
713
+ wo->spawningKitContext->wrapperRegistry = coreWrapperRegistry;
656
714
  wo->spawningKitContext->randomGenerator = wo->randomGenerator;
657
715
  wo->spawningKitContext->integrationMode = coreConfig->get("integration_mode").asString();
658
716
  wo->spawningKitContext->instanceDir = coreConfig->get("instance_dir").asString();
@@ -713,6 +771,7 @@ initializeNonPrivilegedWorkingObjects() {
713
771
  &wo->singleAppModeConfig,
714
772
  coreSchema->controllerSingleAppMode.translator);
715
773
  two.controller->resourceLocator = &wo->resourceLocator;
774
+ two.controller->wrapperRegistry = coreWrapperRegistry;
716
775
  two.controller->appPool = wo->appPool;
717
776
  two.controller->shutdownFinishCallback = controllerShutdownFinished;
718
777
  two.controller->initialize();
@@ -821,6 +880,26 @@ initializeSecurityUpdateChecker() {
821
880
  checker->start();
822
881
  }
823
882
 
883
+ static void
884
+ initializeTelemetryCollector() {
885
+ TRACE_POINT();
886
+ WorkingObjects &wo = *workingObjects;
887
+
888
+ Json::Value config = coreConfig->inspectEffectiveValues();
889
+ TelemetryCollector *collector = new TelemetryCollector(
890
+ coreSchema->telemetryCollector.schema,
891
+ coreConfig->inspectEffectiveValues(),
892
+ coreSchema->telemetryCollector.translator);
893
+ wo.telemetryCollector = collector;
894
+ for (unsigned int i = 0; i < wo.threadWorkingObjects.size(); i++) {
895
+ ThreadWorkingObjects *two = &wo.threadWorkingObjects[i];
896
+ collector->controllers.push_back(two->controller);
897
+ }
898
+ collector->initialize();
899
+ collector->start();
900
+ wo.shutdownCounter.fetch_add(1, boost::memory_order_relaxed);
901
+ }
902
+
824
903
  static void
825
904
  runAdminPanelConnector(AdminPanelConnector *connector) {
826
905
  connector->run();
@@ -968,6 +1047,50 @@ reportInitializationInfo() {
968
1047
  }
969
1048
  }
970
1049
 
1050
+ static void
1051
+ initializeAbortHandlerCustomerDiagnostics() {
1052
+ if (!Agent::Fundamentals::abortHandlerInstalled()) {
1053
+ return;
1054
+ }
1055
+
1056
+ Agent::Fundamentals::AbortHandlerConfig::DiagnosticsDumper *diagnosticsDumpers
1057
+ = &Agent::Fundamentals::context->abortHandlerConfig.diagnosticsDumpers[0];
1058
+
1059
+ diagnosticsDumpers[0].name = "OXT backtraces";
1060
+ diagnosticsDumpers[0].logFileName = "backtrace_oxt.log";
1061
+ diagnosticsDumpers[0].func = dumpOxtBacktracesOnCrash;
1062
+
1063
+ diagnosticsDumpers[1].name = "controller states";
1064
+ diagnosticsDumpers[1].logFileName = "controller_states.log";
1065
+ diagnosticsDumpers[1].func = dumpControllerStatesOnCrash;
1066
+
1067
+ diagnosticsDumpers[2].name = "controller configs";
1068
+ diagnosticsDumpers[2].logFileName = "controller_configs.log";
1069
+ diagnosticsDumpers[2].func = dumpControllerConfigsOnCrash;
1070
+
1071
+ diagnosticsDumpers[3].name = "pool state";
1072
+ diagnosticsDumpers[3].logFileName = "pool.log";
1073
+ diagnosticsDumpers[3].func = dumpPoolStateOnCrash;
1074
+
1075
+ diagnosticsDumpers[4].name = "mbuf statistics";
1076
+ diagnosticsDumpers[4].logFileName = "mbufs.log";
1077
+ diagnosticsDumpers[4].func = dumpMbufStatsOnCrash;
1078
+
1079
+ Agent::Fundamentals::abortHandlerConfigChanged();
1080
+ }
1081
+
1082
+ static void
1083
+ uninstallAbortHandlerCustomDiagnostics() {
1084
+ if (!Agent::Fundamentals::abortHandlerInstalled()) {
1085
+ return;
1086
+ }
1087
+
1088
+ for (unsigned int i = 0; i < Agent::Fundamentals::AbortHandlerConfig::MAX_DIAGNOSTICS_DUMPERS; i++) {
1089
+ Agent::Fundamentals::context->abortHandlerConfig.diagnosticsDumpers[i].func = NULL;
1090
+ }
1091
+ Agent::Fundamentals::abortHandlerConfigChanged();
1092
+ }
1093
+
971
1094
  static void
972
1095
  mainLoop() {
973
1096
  TRACE_POINT();
@@ -978,9 +1101,6 @@ mainLoop() {
978
1101
  && maxCpus <= CPU_SETSIZE;
979
1102
  #endif
980
1103
 
981
- Agent::Fundamentals::context->abortHandlerConfig.diagnosticsDumper = dumpDiagnosticsOnCrash;
982
- Agent::Fundamentals::abortHandlerConfigChanged();
983
-
984
1104
  for (unsigned int i = 0; i < wo->threadWorkingObjects.size(); i++) {
985
1105
  ThreadWorkingObjects *two = &wo->threadWorkingObjects[i];
986
1106
  two->bgloop->start("Main event loop: thread " + toString(i + 1), 0);
@@ -1064,6 +1184,20 @@ apiServerShutdownFinished(Core::ApiServer::ApiServer *server) {
1064
1184
  serverShutdownFinished();
1065
1185
  }
1066
1186
 
1187
+ static void
1188
+ telemetryCollectorAsyncShutdownThreadMain() {
1189
+ WorkingObjects *wo = workingObjects;
1190
+ wo->telemetryCollector->stop();
1191
+ serverShutdownFinished();
1192
+ }
1193
+
1194
+ static void
1195
+ asyncShutdownTelemetryCollector() {
1196
+ oxt::thread(telemetryCollectorAsyncShutdownThreadMain,
1197
+ "Telemetry collector shutdown",
1198
+ 512 * 1024);
1199
+ }
1200
+
1067
1201
  /* Wait until the watchdog closes the feedback fd (meaning it
1068
1202
  * was killed) or until we receive an exit message.
1069
1203
  */
@@ -1085,8 +1219,7 @@ waitForExitEvent() {
1085
1219
  TRACE_POINT();
1086
1220
  if (syscalls::select(largestFd + 1, &fds, NULL, NULL, NULL) == -1) {
1087
1221
  int e = errno;
1088
- Agent::Fundamentals::context->abortHandlerConfig.diagnosticsDumper = NULL;
1089
- Agent::Fundamentals::abortHandlerConfigChanged();
1222
+ uninstallAbortHandlerCustomDiagnostics();
1090
1223
  throw SystemException("select() failed", e);
1091
1224
  }
1092
1225
 
@@ -1122,6 +1255,9 @@ waitForExitEvent() {
1122
1255
  if (wo->apiWorkingObjects.apiServer != NULL) {
1123
1256
  wo->apiWorkingObjects.bgloop->safe->runLater(shutdownApiServer);
1124
1257
  }
1258
+ if (wo->telemetryCollector != NULL) {
1259
+ asyncShutdownTelemetryCollector();
1260
+ }
1125
1261
  if (wo->adminPanelConnector != NULL) {
1126
1262
  wo->adminPanelConnector->asyncShutdown();
1127
1263
  }
@@ -1133,8 +1269,7 @@ waitForExitEvent() {
1133
1269
  &fds, NULL, NULL, NULL) == -1)
1134
1270
  {
1135
1271
  int e = errno;
1136
- Agent::Fundamentals::context->abortHandlerConfig.diagnosticsDumper = NULL;
1137
- Agent::Fundamentals::abortHandlerConfigChanged();
1272
+ uninstallAbortHandlerCustomDiagnostics();
1138
1273
  throw SystemException("select() failed", e);
1139
1274
  }
1140
1275
 
@@ -1150,8 +1285,7 @@ cleanup() {
1150
1285
  P_DEBUG("Shutting down " SHORT_PROGRAM_NAME " core...");
1151
1286
  wo->appPool->destroy();
1152
1287
 
1153
- Agent::Fundamentals::context->abortHandlerConfig.diagnosticsDumper = dumpDiagnosticsOnCrash;
1154
- Agent::Fundamentals::abortHandlerConfigChanged();
1288
+ uninstallAbortHandlerCustomDiagnostics();
1155
1289
 
1156
1290
  for (unsigned i = 0; i < wo->threadWorkingObjects.size(); i++) {
1157
1291
  ThreadWorkingObjects *two = &wo->threadWorkingObjects[i];
@@ -1160,6 +1294,11 @@ cleanup() {
1160
1294
  if (wo->apiWorkingObjects.apiServer != NULL) {
1161
1295
  wo->apiWorkingObjects.bgloop->stop();
1162
1296
  }
1297
+ if (wo->telemetryCollector != NULL
1298
+ && !coreConfig->get("telemetry_collector_disabled").asBool())
1299
+ {
1300
+ wo->telemetryCollector->runOneCycle(true);
1301
+ }
1163
1302
  wo->appPool.reset();
1164
1303
  for (unsigned i = 0; i < wo->threadWorkingObjects.size(); i++) {
1165
1304
  ThreadWorkingObjects *two = &wo->threadWorkingObjects[i];
@@ -1210,12 +1349,14 @@ runCore() {
1210
1349
  initializeCurl();
1211
1350
  initializeNonPrivilegedWorkingObjects();
1212
1351
  initializeSecurityUpdateChecker();
1352
+ initializeTelemetryCollector();
1213
1353
  initializeAdminPanelConnector();
1214
1354
  prestartWebApps();
1215
1355
 
1216
1356
  UPDATE_TRACE_POINT();
1217
1357
  warnIfPassengerRootVulnerable();
1218
1358
  reportInitializationInfo();
1359
+ initializeAbortHandlerCustomerDiagnostics();
1219
1360
  mainLoop();
1220
1361
 
1221
1362
  UPDATE_TRACE_POINT();
@@ -1277,7 +1418,9 @@ int
1277
1418
  coreMain(int argc, char *argv[]) {
1278
1419
  int ret;
1279
1420
 
1280
- coreSchema = new Schema();
1421
+ coreWrapperRegistry = new WrapperRegistry::Registry();
1422
+ coreWrapperRegistry->finalize();
1423
+ coreSchema = new Schema(coreWrapperRegistry);
1281
1424
  coreConfig = new ConfigKit::Store(*coreSchema);
1282
1425
  initializeAgent(argc, &argv, SHORT_PROGRAM_NAME " core",
1283
1426
  *coreConfig, coreSchema->loggingKit.translator,
@@ -1289,5 +1432,6 @@ coreMain(int argc, char *argv[]) {
1289
1432
 
1290
1433
  ret = runCore();
1291
1434
  shutdownAgent(coreSchema, coreConfig);
1435
+ delete coreWrapperRegistry;
1292
1436
  return ret;
1293
1437
  }