passenger 5.3.4 → 6.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +69 -0
- data/CONTRIBUTORS +1 -0
- data/README.md +2 -1
- data/Rakefile +0 -5
- data/build/agent.rb +6 -3
- data/build/cxx_tests.rb +28 -19
- data/build/integration_tests.rb +6 -2
- data/build/misc.rb +2 -1
- data/build/packaging.rb +2 -0
- data/build/support/cplusplus.rb +2 -2
- data/build/support/cxx_dependency_map.rb +2651 -2189
- data/dev/colorize-logs +272 -0
- data/dev/show-latest-crashlog-dir +27 -0
- data/resources/templates/standalone/http.erb +2 -0
- data/resources/templates/standalone/server.erb +1 -0
- data/src/agent/AgentMain.cpp +4 -0
- data/src/agent/Core/AdminPanelConnector.h +6 -6
- data/src/agent/Core/ApiServer.h +4 -4
- data/src/agent/Core/ApplicationPool/BasicProcessInfo.h +2 -2
- data/src/agent/Core/ApplicationPool/Context.h +5 -1
- data/src/agent/Core/ApplicationPool/Group/InternalUtils.cpp +2 -2
- data/src/agent/Core/ApplicationPool/Group/LifetimeAndBasics.cpp +5 -0
- data/src/agent/Core/ApplicationPool/Group/Miscellaneous.cpp +2 -1
- data/src/agent/Core/ApplicationPool/Group/OutOfBandWork.cpp +3 -3
- data/src/agent/Core/ApplicationPool/Group/ProcessListManagement.cpp +1 -1
- data/src/agent/Core/ApplicationPool/Group/StateInspection.cpp +13 -20
- data/src/agent/Core/ApplicationPool/Group.h +4 -2
- data/src/agent/Core/ApplicationPool/Implementation.cpp +5 -5
- data/src/agent/Core/ApplicationPool/Options.h +42 -38
- data/src/agent/Core/ApplicationPool/Pool/GroupUtils.cpp +2 -1
- data/src/agent/Core/ApplicationPool/Pool.h +4 -4
- data/src/agent/Core/ApplicationPool/Process.h +13 -15
- data/src/agent/Core/ApplicationPool/Socket.h +5 -5
- data/src/agent/Core/ApplicationPool/TestSession.h +3 -3
- data/src/agent/Core/Config.h +50 -10
- data/src/agent/Core/ConfigChange.cpp +13 -1
- data/src/agent/Core/Controller/Config.h +41 -17
- data/src/agent/Core/Controller/ForwardResponse.cpp +4 -0
- data/src/agent/Core/Controller/InitRequest.cpp +14 -8
- data/src/agent/Core/Controller/InitializationAndShutdown.cpp +5 -0
- data/src/agent/Core/Controller/SendRequest.cpp +9 -9
- data/src/agent/Core/Controller/TurboCaching.h +2 -2
- data/src/agent/Core/Controller.h +7 -5
- data/src/agent/Core/CoreMain.cpp +204 -60
- data/src/agent/Core/OptionParser.h +20 -3
- data/src/agent/Core/ResponseCache.h +3 -3
- data/src/agent/Core/SecurityUpdateChecker.h +4 -2
- data/src/agent/Core/SpawningKit/Config/AutoGeneratedCode.h +1 -1
- data/src/agent/Core/SpawningKit/Config.h +3 -2
- data/src/agent/Core/SpawningKit/Context.h +8 -2
- data/src/agent/Core/SpawningKit/DirectSpawner.h +4 -4
- data/src/agent/Core/SpawningKit/DummySpawner.h +3 -3
- data/src/agent/Core/SpawningKit/ErrorRenderer.h +1 -1
- data/src/agent/Core/SpawningKit/Exceptions.h +21 -14
- data/src/agent/Core/SpawningKit/Factory.h +1 -1
- data/src/agent/Core/SpawningKit/Handshake/BackgroundIOCapturer.h +1 -1
- data/src/agent/Core/SpawningKit/Handshake/Perform.h +14 -2
- data/src/agent/Core/SpawningKit/Handshake/Prepare.h +3 -3
- data/src/agent/Core/SpawningKit/Handshake/WorkDir.h +1 -1
- data/src/agent/Core/SpawningKit/Journey.h +4 -5
- data/src/agent/Core/SpawningKit/PipeWatcher.h +1 -1
- data/src/agent/Core/SpawningKit/README.md +34 -17
- data/src/agent/Core/SpawningKit/Result/AutoGeneratedCode.h +1 -1
- data/src/agent/Core/SpawningKit/Result.h +20 -8
- data/src/agent/Core/SpawningKit/SmartSpawner.h +7 -7
- data/src/agent/Core/SpawningKit/Spawner.h +25 -8
- data/src/agent/Core/SpawningKit/UserSwitchingRules.h +17 -7
- data/src/agent/Core/TelemetryCollector.h +681 -0
- data/src/agent/ExecHelper/ExecHelperMain.cpp +1 -1
- data/src/agent/FileReadHelper/FileReadHelperMain.cpp +198 -0
- data/src/agent/README.md +1 -1
- data/src/agent/Shared/ApiAccountUtils.h +1 -1
- data/src/agent/Shared/ApiServerUtils.h +3 -3
- data/src/agent/Shared/ApplicationPoolApiKey.h +2 -2
- data/src/agent/Shared/Fundamentals/AbortHandler.cpp +324 -98
- data/src/agent/Shared/Fundamentals/AbortHandler.h +31 -4
- data/src/agent/Shared/Fundamentals/Initialization.cpp +4 -5
- data/src/agent/Shared/Fundamentals/Initialization.h +9 -1
- data/src/agent/SpawnEnvSetupper/SpawnEnvSetupperMain.cpp +1 -1
- data/src/agent/SystemMetrics/SystemMetricsMain.cpp +4 -3
- data/src/agent/TempDirToucher/TempDirToucherMain.cpp +3 -3
- data/src/agent/Watchdog/ApiServer.h +3 -3
- data/src/agent/Watchdog/Config.h +24 -5
- data/src/agent/Watchdog/CoreWatcher.cpp +2 -2
- data/src/agent/Watchdog/WatchdogMain.cpp +97 -28
- data/src/apache2_module/Config.cpp +14 -14
- data/src/apache2_module/Config.h +8 -16
- data/src/apache2_module/ConfigGeneral/AutoGeneratedDefinitions.cpp +510 -481
- data/src/apache2_module/ConfigGeneral/AutoGeneratedDefinitions.cpp.cxxcodebuilder +39 -17
- data/src/apache2_module/ConfigGeneral/AutoGeneratedManifestDefaultsInitialization.cpp +5 -0
- data/src/apache2_module/ConfigGeneral/AutoGeneratedSetterFuncs.cpp +69 -1
- data/src/apache2_module/ConfigGeneral/AutoGeneratedSetterFuncs.cpp.cxxcodebuilder +31 -1
- data/src/apache2_module/ConfigGeneral/Common.h +45 -0
- data/src/apache2_module/DirConfig/AutoGeneratedCreateFunction.cpp +17 -1
- data/src/apache2_module/DirConfig/AutoGeneratedCreateFunction.cpp.cxxcodebuilder +16 -1
- data/src/apache2_module/DirConfig/AutoGeneratedHeaderSerialization.cpp +19 -5
- data/src/apache2_module/DirConfig/AutoGeneratedHeaderSerialization.cpp.cxxcodebuilder +26 -9
- data/src/apache2_module/DirConfig/AutoGeneratedManifestGeneration.cpp +19 -1
- data/src/apache2_module/DirConfig/AutoGeneratedManifestGeneration.cpp.cxxcodebuilder +10 -1
- data/src/apache2_module/DirConfig/AutoGeneratedMergeFunction.cpp +14 -1
- data/src/apache2_module/DirConfig/AutoGeneratedMergeFunction.cpp.cxxcodebuilder +11 -1
- data/src/apache2_module/DirConfig/AutoGeneratedStruct.h +36 -1
- data/src/apache2_module/DirConfig/AutoGeneratedStruct.h.cxxcodebuilder +34 -1
- data/src/apache2_module/DirectoryMapper.h +36 -37
- data/src/apache2_module/Hooks.cpp +27 -8
- data/src/apache2_module/ServerConfig/AutoGeneratedManifestGeneration.cpp +20 -0
- data/src/apache2_module/ServerConfig/AutoGeneratedStruct.h +48 -1
- data/src/apache2_module/ServerConfig/AutoGeneratedStruct.h.cxxcodebuilder +36 -1
- data/src/cxx_supportlib/{Utils → Algorithms}/Hasher.cpp +2 -2
- data/src/cxx_supportlib/{Utils → Algorithms}/Hasher.h +4 -4
- data/src/cxx_supportlib/AppLocalConfigFileUtils.h +148 -0
- data/src/cxx_supportlib/AppTypeDetector/CBindings.cpp +147 -0
- data/src/cxx_supportlib/AppTypeDetector/CBindings.h +75 -0
- data/src/cxx_supportlib/{AppTypes.h → AppTypeDetector/Detector.h} +92 -131
- data/src/cxx_supportlib/ConfigKit/README.md +90 -2
- data/src/cxx_supportlib/ConfigKit/Schema.h +60 -15
- data/src/cxx_supportlib/ConfigKit/Store.h +129 -5
- data/src/cxx_supportlib/Constants.h +1 -1
- data/src/cxx_supportlib/{Utils → DataStructures}/HashMap.h +4 -4
- data/src/cxx_supportlib/DataStructures/HashedStaticString.h +5 -5
- data/src/cxx_supportlib/DataStructures/LString.h +3 -3
- data/src/cxx_supportlib/{Utils → DataStructures}/StringMap.h +36 -36
- data/src/cxx_supportlib/FileTools/FileManip.cpp +1 -1
- data/src/cxx_supportlib/FileTools/PathManip.cpp +2 -2
- data/src/cxx_supportlib/FileTools/PathSecurityCheck.cpp +1 -1
- data/src/cxx_supportlib/Hooks.h +2 -2
- data/src/cxx_supportlib/{Utils → IOTools}/BufferedIO.h +5 -5
- data/src/cxx_supportlib/{Utils → IOTools}/IOUtils.cpp +4 -3
- data/src/cxx_supportlib/{Utils → IOTools}/IOUtils.h +3 -3
- data/src/cxx_supportlib/{Utils → IOTools}/MessageIO.h +7 -7
- data/src/cxx_supportlib/{MessageReadersWriters.h → IOTools/MessageSerialization.h} +5 -5
- data/src/cxx_supportlib/InstanceDirectory.h +4 -4
- data/src/cxx_supportlib/Integrations/LibevJsonUtils.h +3 -3
- data/src/cxx_supportlib/{Utils → JsonTools}/JsonUtils.h +5 -5
- data/src/cxx_supportlib/LoggingKit/Context.h +2 -2
- data/src/cxx_supportlib/LoggingKit/Implementation.cpp +3 -3
- data/src/cxx_supportlib/MemoryKit/mbuf.cpp +2 -2
- data/src/cxx_supportlib/ProcessManagement/Ruby.cpp +3 -3
- data/src/cxx_supportlib/ProcessManagement/Ruby.h +7 -2
- data/src/cxx_supportlib/ProcessManagement/Spawn.cpp +19 -12
- data/src/cxx_supportlib/ProcessManagement/Spawn.h +21 -2
- data/src/cxx_supportlib/ProcessManagement/Utils.h +10 -0
- data/src/cxx_supportlib/RandomGenerator.h +2 -2
- data/src/cxx_supportlib/ResourceLocator.h +1 -1
- data/src/cxx_supportlib/{Crypto.cpp → SecurityKit/Crypto.cpp} +4 -4
- data/src/cxx_supportlib/{Crypto.h → SecurityKit/Crypto.h} +4 -4
- data/src/cxx_supportlib/{Utils → SecurityKit}/MemZeroGuard.h +0 -0
- data/src/cxx_supportlib/ServerKit/AcceptLoadBalancer.h +2 -2
- data/src/cxx_supportlib/ServerKit/Channel.h +1 -1
- data/src/cxx_supportlib/ServerKit/ClientRef.h +17 -7
- data/src/cxx_supportlib/ServerKit/Context.h +2 -2
- data/src/cxx_supportlib/ServerKit/FileBufferedChannel.h +1 -1
- data/src/cxx_supportlib/ServerKit/HttpHeaderParser.h +3 -3
- data/src/cxx_supportlib/ServerKit/HttpHeaderParserState.h +2 -2
- data/src/cxx_supportlib/ServerKit/HttpRequestRef.h +17 -7
- data/src/cxx_supportlib/ServerKit/HttpServer.h +16 -10
- data/src/cxx_supportlib/ServerKit/Server.h +3 -4
- data/src/cxx_supportlib/{Utils → StrIntTools}/DateParsing.h +5 -5
- data/src/cxx_supportlib/{Utils → StrIntTools}/StrIntUtils.cpp +3 -3
- data/src/cxx_supportlib/{Utils → StrIntTools}/StrIntUtils.h +0 -0
- data/src/cxx_supportlib/{Utils → StrIntTools}/StrIntUtilsNoStrictAliasing.cpp +12 -12
- data/src/cxx_supportlib/{Utils → StrIntTools}/StringScanning.h +5 -5
- data/src/cxx_supportlib/{Utils → StrIntTools}/Template.h +30 -5
- data/src/cxx_supportlib/SystemTools/ContainerHelpers.h +88 -0
- data/src/cxx_supportlib/{Utils → SystemTools}/ProcessMetricsCollector.h +15 -12
- data/src/cxx_supportlib/{Utils → SystemTools}/SystemMetricsCollector.h +3 -3
- data/src/cxx_supportlib/{Utils → SystemTools}/SystemTime.cpp +1 -1
- data/src/cxx_supportlib/{Utils → SystemTools}/SystemTime.h +0 -0
- data/src/cxx_supportlib/SystemTools/UserDatabase.h +1 -1
- data/src/cxx_supportlib/Utils/CachedFileStat.hpp +3 -3
- data/src/cxx_supportlib/Utils/Curl.h +2 -2
- data/src/cxx_supportlib/Utils/FileChangeChecker.h +2 -2
- data/src/cxx_supportlib/Utils/MessagePassing.h +1 -1
- data/src/cxx_supportlib/Utils/SpeedMeter.h +2 -2
- data/src/cxx_supportlib/Utils/Timer.h +2 -2
- data/src/cxx_supportlib/Utils/VariantMap.h +3 -3
- data/src/cxx_supportlib/Utils.cpp +2 -2
- data/src/cxx_supportlib/WatchdogLauncher.h +3 -3
- data/src/cxx_supportlib/WebSocketCommandReverseServer.h +1 -1
- data/src/cxx_supportlib/WrapperRegistry/CBindings.cpp +85 -0
- data/src/cxx_supportlib/{Utils/MemoryBarrier.h → WrapperRegistry/CBindings.h} +30 -27
- data/src/cxx_supportlib/WrapperRegistry/Entry.h +112 -0
- data/src/cxx_supportlib/WrapperRegistry/README.md +37 -0
- data/src/cxx_supportlib/WrapperRegistry/Registry.h +309 -0
- data/src/cxx_supportlib/vendor-modified/psg_sysqueue.h +3 -0
- data/src/helper-scripts/download_binaries/extconf.rb +6 -2
- data/src/nginx_module/ConfigGeneral/AutoGeneratedDefinitions.c +32 -0
- data/src/nginx_module/ConfigGeneral/AutoGeneratedManifestDefaultsInitialization.c +12 -0
- data/src/nginx_module/ConfigGeneral/AutoGeneratedSetterFuncs.c +36 -0
- data/src/nginx_module/Configuration.c +23 -3
- data/src/nginx_module/ContentHandler.c +331 -32
- data/src/nginx_module/ContentHandler.h +8 -3
- data/src/nginx_module/LocationConfig/AutoGeneratedCreateFunction.c +10 -0
- data/src/nginx_module/LocationConfig/AutoGeneratedManifestGeneration.c +27 -0
- data/src/nginx_module/LocationConfig/AutoGeneratedMergeFunction.c +3 -0
- data/src/nginx_module/LocationConfig/AutoGeneratedStruct.h +7 -0
- data/src/nginx_module/MainConfig/AutoGeneratedCreateFunction.c +11 -0
- data/src/nginx_module/MainConfig/AutoGeneratedManifestGeneration.c +23 -0
- data/src/nginx_module/MainConfig/AutoGeneratedStruct.h +8 -0
- data/src/nginx_module/config +2 -1
- data/src/nginx_module/ngx_http_passenger_module.c +9 -3
- data/src/nginx_module/ngx_http_passenger_module.h +10 -3
- data/src/ruby_supportlib/phusion_passenger/apache2/config_options.rb +19 -0
- data/src/ruby_supportlib/phusion_passenger/common_library.rb +19 -16
- data/src/ruby_supportlib/phusion_passenger/config/agent_compiler.rb +4 -4
- data/src/ruby_supportlib/phusion_passenger/config/download_agent_command.rb +6 -2
- data/src/ruby_supportlib/phusion_passenger/config/download_nginx_engine_command.rb +6 -2
- data/src/ruby_supportlib/phusion_passenger/config/nginx_engine_compiler.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/message_channel.rb +2 -2
- data/src/ruby_supportlib/phusion_passenger/native_support.rb +7 -3
- data/src/ruby_supportlib/phusion_passenger/nginx/config_options.rb +29 -0
- data/src/ruby_supportlib/phusion_passenger/packaging.rb +20 -19
- data/src/ruby_supportlib/phusion_passenger/platform_info/apache.rb +22 -4
- data/src/ruby_supportlib/phusion_passenger/platform_info/ruby.rb +33 -13
- data/src/ruby_supportlib/phusion_passenger/standalone/app_finder.rb +1 -0
- data/src/ruby_supportlib/phusion_passenger/standalone/config_options_list.rb +22 -2
- data/src/ruby_supportlib/phusion_passenger/standalone/start_command/builtin_engine.rb +4 -1
- data/src/ruby_supportlib/phusion_passenger.rb +7 -5
- data/src/schema_printer/SchemaPrinterMain.cpp +2 -0
- metadata +40 -89
- data/.editorconfig +0 -134
- data/CODE_OF_CONDUCT.md +0 -52
- data/dev/boost-patches/0001-Patch-boost-thread-so-that-oxt-thread-can-use-it.patch +0 -48
- data/dev/boost-patches/0002-Make-boost-thread_interrupted-derive-from-oxt-tracab.patch +0 -33
- data/dev/boost-patches/0003-Disable-a-Clang-pragma-to-prevent-warnings-on-OS-X.patch +0 -25
- data/dev/ci/README.md +0 -134
- data/dev/ci/lib/functions.sh +0 -129
- data/dev/ci/lib/set-container-envvars.sh +0 -53
- data/dev/ci/lib/setup-container.sh +0 -46
- data/dev/ci/run-tests-natively +0 -24
- data/dev/ci/run-tests-with-docker +0 -42
- data/dev/ci/scripts/debug-console-wrapper.sh +0 -29
- data/dev/ci/scripts/docker-entrypoint-stage2.sh +0 -17
- data/dev/ci/scripts/docker-entrypoint.sh +0 -17
- data/dev/ci/scripts/inituidgid +0 -17
- data/dev/ci/scripts/run-tests-natively-stage2.sh +0 -17
- data/dev/ci/scripts/setup-host-natively.sh +0 -11
- data/dev/ci/setup-host +0 -56
- data/dev/ci/tests/apache2/run +0 -6
- data/dev/ci/tests/apache2/setup +0 -4
- data/dev/ci/tests/binaries/Jenkinsfile +0 -105
- data/dev/ci/tests/binaries/build-linux +0 -38
- data/dev/ci/tests/binaries/build-macos +0 -40
- data/dev/ci/tests/binaries/prepare-macos +0 -38
- data/dev/ci/tests/binaries/test-linux +0 -45
- data/dev/ci/tests/binaries/test-macos +0 -38
- data/dev/ci/tests/cxx/run +0 -9
- data/dev/ci/tests/cxx/setup +0 -4
- data/dev/ci/tests/debian/Jenkinsfile +0 -89
- data/dev/ci/tests/debian/run +0 -60
- data/dev/ci/tests/nginx/run +0 -5
- data/dev/ci/tests/nginx/setup +0 -4
- data/dev/ci/tests/nginx-dynamic/run +0 -20
- data/dev/ci/tests/nginx-dynamic/setup +0 -4
- data/dev/ci/tests/nodejs/run +0 -4
- data/dev/ci/tests/nodejs/setup +0 -4
- data/dev/ci/tests/rpm/Jenkinsfile +0 -68
- data/dev/ci/tests/rpm/run +0 -63
- data/dev/ci/tests/ruby/run +0 -4
- data/dev/ci/tests/ruby/setup +0 -4
- data/dev/ci/tests/source-packaging/run +0 -4
- data/dev/ci/tests/source-packaging/setup +0 -4
- data/dev/ci/tests/standalone/run +0 -4
- data/dev/ci/tests/standalone/setup +0 -4
- data/dev/configkit-schemas/index.json +0 -1748
- data/dev/configkit-schemas/update_schema_inline_comments.rb +0 -118
- data/dev/rack.test/config.ru +0 -5
- data/dev/rack.test/public/asset.txt +0 -1
- data/dev/vagrant/apache_default_site.conf +0 -35
- data/dev/vagrant/apache_passenger.conf +0 -5
- data/dev/vagrant/apache_passenger.load +0 -1
- data/dev/vagrant/apache_ports.conf +0 -24
- data/dev/vagrant/apache_rack_test.conf +0 -9
- data/dev/vagrant/bashrc +0 -23
- data/dev/vagrant/nginx.conf +0 -39
- data/dev/vagrant/nginx_rakefile +0 -33
- data/dev/vagrant/nginx_start +0 -32
- data/dev/vagrant/provision.sh +0 -117
- data/dev/vagrant/sudoers.conf +0 -5
- data/resources/templates/error_renderer/.editorconfig +0 -19
- data/src/cxx_supportlib/AppTypes.cpp +0 -109
- 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-
|
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
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
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.
|
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-
|
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 <
|
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-
|
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 <
|
38
|
+
#include <StrIntTools/StrIntUtils.h>
|
39
39
|
#include <Core/ResponseCache.h>
|
40
40
|
|
41
41
|
namespace Passenger {
|
data/src/agent/Core/Controller.h
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
* Phusion Passenger - https://www.phusionpassenger.com/
|
3
|
-
* Copyright (c) 2011-
|
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 <
|
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 <
|
77
|
-
#include <
|
78
|
-
#include <
|
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
|
|
data/src/agent/Core/CoreMain.cpp
CHANGED
@@ -81,7 +81,8 @@
|
|
81
81
|
#include <ConfigKit/SubComponentUtils.h>
|
82
82
|
#include <ServerKit/Server.h>
|
83
83
|
#include <ServerKit/AcceptLoadBalancer.h>
|
84
|
-
#include <
|
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 <
|
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(
|
261
|
-
|
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
|
-
|
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 (
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
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
|
295
|
-
|
296
|
-
|
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
|
-
|
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 << "
|
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 << "
|
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 << "
|
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 << "
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
}
|