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.
- checksums.yaml +4 -4
- data/CHANGELOG +13 -0
- data/CONTRIBUTORS +5 -1
- data/build/agent.rb +22 -2
- data/build/cxx_tests.rb +41 -5
- data/build/misc.rb +4 -1
- data/build/support/cxx_dependency_map.rb +1746 -908
- data/build/support/vendor/cxx_hinted_parser/CxxHintedParser.sublime-project +8 -0
- data/build/support/vendor/cxx_hinted_parser/Gemfile +5 -0
- data/build/support/vendor/cxx_hinted_parser/Gemfile.lock +30 -0
- data/{src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core → build/support/vendor/cxx_hinted_parser}/LICENSE.md +1 -1
- data/build/support/vendor/cxx_hinted_parser/README.md +95 -0
- data/build/support/vendor/cxx_hinted_parser/Rakefile +4 -0
- 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
- data/build/support/vendor/cxx_hinted_parser/lib/cxx_hinted_parser/parser.rb +239 -0
- data/dev/ci/README.md +15 -2
- data/dev/ci/lib/set-container-envvars.sh +6 -0
- data/dev/ci/lib/setup-container.sh +4 -1
- data/dev/ci/scripts/debug-console-wrapper.sh +3 -1
- data/dev/ci/setup-host +5 -0
- data/dev/ci/tests/binaries/Jenkinsfile +105 -0
- data/dev/ci/tests/binaries/build-linux +38 -0
- data/dev/ci/tests/binaries/build-macos +40 -0
- data/dev/ci/tests/binaries/prepare-macos +38 -0
- data/dev/ci/tests/binaries/test-linux +45 -0
- data/dev/ci/tests/binaries/test-macos +38 -0
- data/dev/ci/tests/debian/Jenkinsfile +2 -2
- data/dev/ci/tests/rpm/Jenkinsfile +1 -1
- data/dev/configkit-schemas/index.json +3 -24
- data/dev/vagrant/nginx_rakefile +0 -1
- data/package.json +15 -5
- data/resources/templates/error_renderer/.editorconfig +19 -0
- data/resources/templates/error_renderer/with_details/README.md +9 -0
- data/resources/templates/error_renderer/with_details/dist/bundle.js +33 -0
- data/resources/templates/error_renderer/with_details/dist/styles.css +17 -0
- data/resources/templates/error_renderer/with_details/src/DetailsView.jsx +52 -0
- data/resources/templates/error_renderer/with_details/src/GetHelpView.jsx +61 -0
- data/resources/templates/error_renderer/with_details/src/JourneyView.css +50 -0
- data/resources/templates/error_renderer/with_details/src/JourneyView.jsx +621 -0
- data/resources/templates/error_renderer/with_details/src/PageMain.css +114 -0
- data/resources/templates/error_renderer/with_details/src/PageMain.jsx +136 -0
- data/resources/templates/error_renderer/with_details/src/ProblemDescriptionView.jsx +14 -0
- data/resources/templates/error_renderer/with_details/src/ProcessDetailsView.jsx +56 -0
- data/resources/templates/error_renderer/with_details/src/SolutionDescriptionView.css +5 -0
- data/resources/templates/error_renderer/with_details/src/SolutionDescriptionView.jsx +15 -0
- data/resources/templates/error_renderer/with_details/src/SummaryView.jsx +35 -0
- data/resources/templates/error_renderer/with_details/src/SystemComponentView.css +34 -0
- data/resources/templates/error_renderer/with_details/src/SystemComponentView.jsx +168 -0
- data/resources/templates/error_renderer/with_details/src/SystemComponentsView.css +13 -0
- data/resources/templates/error_renderer/with_details/src/SystemComponentsView.jsx +116 -0
- data/resources/templates/error_renderer/with_details/src/Tab.jsx +12 -0
- data/resources/templates/error_renderer/with_details/src/Tabs.jsx +104 -0
- data/resources/templates/error_renderer/with_details/src/bootstrap/bootstrap.css +3446 -0
- data/resources/templates/error_renderer/with_details/src/bootstrap/bootstrap.js +293 -0
- data/resources/templates/error_renderer/with_details/src/bootstrap/config.json +401 -0
- data/resources/templates/error_renderer/with_details/src/index.html.template +22 -0
- data/resources/templates/error_renderer/with_details/src/index.jsx +23 -0
- data/resources/templates/error_renderer/with_details/webpack.config.js +47 -0
- data/resources/templates/error_renderer/without_details/dist/bundle.js +1 -0
- data/resources/templates/error_renderer/without_details/dist/styles.css +1 -0
- data/resources/templates/{undisclosed_error.html.template → error_renderer/without_details/src/index.html.template} +7 -11
- data/resources/templates/error_renderer/without_details/src/index.js +1 -0
- data/resources/templates/{error_layout.css → error_renderer/without_details/src/main.css} +5 -2
- data/resources/templates/error_renderer/without_details/webpack.config.js +42 -0
- data/src/agent/AgentMain.cpp +3 -3
- data/src/agent/Core/ApplicationPool/BasicProcessInfo.h +13 -0
- data/src/agent/Core/ApplicationPool/Common.h +3 -4
- data/src/agent/Core/ApplicationPool/Context.h +27 -17
- data/src/agent/Core/ApplicationPool/Group.h +3 -1
- data/src/agent/Core/ApplicationPool/Group/InitializationAndShutdown.cpp +2 -12
- data/src/agent/Core/ApplicationPool/Group/InternalUtils.cpp +55 -10
- data/src/agent/Core/ApplicationPool/Group/LifetimeAndBasics.cpp +1 -1
- data/src/agent/Core/ApplicationPool/Group/OutOfBandWork.cpp +1 -1
- data/src/agent/Core/ApplicationPool/Group/SpawningAndRestarting.cpp +13 -6
- data/src/agent/Core/ApplicationPool/Implementation.cpp +16 -100
- data/src/agent/Core/ApplicationPool/Options.h +8 -65
- data/src/agent/Core/ApplicationPool/Pool.h +4 -21
- data/src/agent/Core/ApplicationPool/Pool/AnalyticsCollection.cpp +1 -60
- data/src/agent/Core/ApplicationPool/Pool/GeneralUtils.cpp +10 -13
- data/src/agent/Core/ApplicationPool/Pool/InitializationAndShutdown.cpp +3 -8
- data/src/agent/Core/ApplicationPool/Pool/Miscellaneous.cpp +2 -34
- data/src/agent/Core/ApplicationPool/Pool/StateInspection.cpp +1 -1
- data/src/agent/Core/ApplicationPool/Process.cpp +17 -12
- data/src/agent/Core/ApplicationPool/Process.h +146 -93
- data/src/agent/Core/ApplicationPool/Session.h +2 -2
- data/src/agent/Core/ApplicationPool/Socket.h +28 -27
- data/src/agent/Core/Config.h +1 -3
- data/src/agent/Core/ConfigChange.cpp +2 -4
- data/src/agent/Core/Controller.h +2 -8
- data/src/agent/Core/Controller/BufferBody.cpp +0 -2
- data/src/agent/Core/Controller/CheckoutSession.cpp +12 -24
- data/src/agent/Core/Controller/Config.h +1 -9
- data/src/agent/Core/Controller/ForwardResponse.cpp +0 -34
- data/src/agent/Core/Controller/Hooks.cpp +0 -7
- data/src/agent/Core/Controller/InitRequest.cpp +0 -43
- data/src/agent/Core/Controller/InitializationAndShutdown.cpp +0 -4
- data/src/agent/Core/Controller/Request.h +1 -35
- data/src/agent/Core/Controller/SendRequest.cpp +0 -32
- data/src/agent/Core/CoreMain.cpp +19 -32
- data/src/agent/Core/SpawningKit/Config.h +329 -55
- data/src/agent/Core/SpawningKit/Config/AutoGeneratedCode.h +369 -0
- data/src/agent/Core/SpawningKit/Config/AutoGeneratedCode.h.cxxcodebuilder +307 -0
- data/src/agent/Core/SpawningKit/Context.h +211 -0
- data/src/agent/Core/SpawningKit/DirectSpawner.h +112 -122
- data/src/agent/Core/SpawningKit/DummySpawner.h +59 -20
- data/src/agent/Core/SpawningKit/ErrorRenderer.h +117 -0
- data/src/agent/Core/SpawningKit/Exceptions.h +1157 -0
- data/src/agent/Core/SpawningKit/Factory.h +24 -17
- data/src/agent/Core/SpawningKit/{BackgroundIOCapturer.h → Handshake/BackgroundIOCapturer.h} +48 -18
- data/src/agent/Core/SpawningKit/Handshake/Perform.h +1650 -0
- data/src/agent/Core/SpawningKit/Handshake/Prepare.h +582 -0
- data/src/agent/Core/SpawningKit/Handshake/Session.h +91 -0
- data/src/agent/Core/SpawningKit/Handshake/WorkDir.h +100 -0
- data/src/agent/Core/SpawningKit/Journey.h +561 -0
- data/src/agent/Core/SpawningKit/PipeWatcher.h +41 -18
- data/src/agent/Core/SpawningKit/README.md +534 -0
- data/src/agent/Core/SpawningKit/Result.h +182 -7
- data/src/agent/Core/SpawningKit/Result/AutoGeneratedCode.h +69 -0
- data/src/agent/Core/SpawningKit/Result/AutoGeneratedCode.h.cxxcodebuilder +110 -0
- data/src/agent/Core/SpawningKit/SmartSpawner.h +1027 -562
- data/src/agent/Core/SpawningKit/Spawner.h +70 -1134
- data/src/agent/Core/SpawningKit/UserSwitchingRules.h +3 -33
- data/src/agent/README.md +2 -3
- data/src/agent/Shared/ApiServerUtils.h +2 -3
- data/src/agent/SpawnEnvSetupper/SpawnEnvSetupperMain.cpp +932 -0
- data/src/agent/Watchdog/Config.h +1 -3
- data/src/agent/Watchdog/WatchdogMain.cpp +2 -1
- data/src/apache2_module/ConfigGeneral/AutoGeneratedDefinitions.cpp +5 -0
- data/src/apache2_module/ConfigGeneral/AutoGeneratedManifestDefaultsInitialization.cpp +5 -0
- data/src/apache2_module/ConfigGeneral/ManifestGeneration.h +22 -13
- data/src/apache2_module/DirConfig/AutoGeneratedCreateFunction.cpp +5 -0
- data/src/apache2_module/DirConfig/AutoGeneratedHeaderSerialization.cpp +3 -0
- data/src/apache2_module/DirConfig/AutoGeneratedManifestGeneration.cpp +13 -0
- data/src/apache2_module/DirConfig/AutoGeneratedMergeFunction.cpp +7 -0
- data/src/apache2_module/DirConfig/AutoGeneratedStruct.h +13 -0
- data/src/cxx_supportlib/Constants.h +3 -1
- data/src/cxx_supportlib/Exceptions.h +0 -121
- data/src/cxx_supportlib/LoggingKit/Implementation.cpp +7 -6
- data/src/cxx_supportlib/LoggingKit/Logging.h +3 -1
- data/src/cxx_supportlib/Utils.cpp +42 -0
- data/src/cxx_supportlib/Utils.h +7 -0
- data/src/cxx_supportlib/Utils/IOUtils.cpp +58 -0
- data/src/cxx_supportlib/Utils/IOUtils.h +13 -0
- data/src/cxx_supportlib/Utils/JsonUtils.h +130 -23
- data/src/cxx_supportlib/Utils/ScopeGuard.h +9 -4
- data/src/cxx_supportlib/Utils/StrIntUtils.cpp +7 -0
- data/src/cxx_supportlib/Utils/StrIntUtils.h +1 -0
- data/src/cxx_supportlib/Utils/SystemTime.h +1 -1
- data/src/cxx_supportlib/Utils/Timer.h +1 -1
- data/src/cxx_supportlib/WebSocketCommandReverseServer.h +6 -4
- data/src/cxx_supportlib/vendor-copy/adhoc_lve.h +1 -0
- data/src/helper-scripts/node-loader.js +54 -59
- data/src/helper-scripts/rack-loader.rb +63 -60
- data/src/helper-scripts/rack-preloader.rb +125 -72
- data/src/helper-scripts/wsgi-loader.py +100 -43
- data/src/nginx_module/ConfigGeneral/AutoGeneratedDefinitions.c +120 -112
- data/src/nginx_module/ConfigGeneral/AutoGeneratedManifestDefaultsInitialization.c +15 -8
- data/src/nginx_module/ConfigGeneral/AutoGeneratedSetterFuncs.c +142 -142
- data/src/nginx_module/ConfigGeneral/ManifestGeneration.c +26 -15
- data/src/nginx_module/ConfigGeneral/ManifestGeneration.h +3 -0
- data/src/nginx_module/LocationConfig/AutoGeneratedCreateFunction.c +76 -70
- data/src/nginx_module/LocationConfig/AutoGeneratedHeaderSerialization.c +114 -99
- data/src/nginx_module/LocationConfig/AutoGeneratedManifestGeneration.c +170 -156
- data/src/nginx_module/LocationConfig/AutoGeneratedMergeFunction.c +38 -35
- data/src/nginx_module/LocationConfig/AutoGeneratedStruct.h +5 -1
- data/src/ruby_supportlib/phusion_passenger.rb +5 -5
- data/src/ruby_supportlib/phusion_passenger/admin_tools/instance.rb +14 -1
- data/src/ruby_supportlib/phusion_passenger/apache2/config_options.rb +8 -0
- data/src/ruby_supportlib/phusion_passenger/common_library.rb +0 -3
- data/src/ruby_supportlib/phusion_passenger/config/nginx_engine_compiler.rb +0 -1
- data/src/ruby_supportlib/phusion_passenger/constants.rb +2 -0
- data/src/ruby_supportlib/phusion_passenger/loader_shared_helpers.rb +646 -238
- data/src/ruby_supportlib/phusion_passenger/nginx/config_options.rb +117 -95
- data/src/ruby_supportlib/phusion_passenger/packaging.rb +0 -1
- data/src/ruby_supportlib/phusion_passenger/platform_info/depcheck_specs/apache2.rb +5 -1
- data/src/ruby_supportlib/phusion_passenger/preloader_shared_helpers.rb +92 -69
- data/src/ruby_supportlib/phusion_passenger/public_api.rb +0 -17
- data/src/ruby_supportlib/phusion_passenger/rack/thread_handler_extension.rb +0 -3
- data/src/ruby_supportlib/phusion_passenger/request_handler.rb +4 -5
- data/src/ruby_supportlib/phusion_passenger/request_handler/thread_handler.rb +0 -22
- metadata +64 -67
- data/resources/templates/error_layout.html.template +0 -86
- data/resources/templates/general_error.html.template +0 -1
- data/resources/templates/general_error_with_html.html.template +0 -1
- data/src/agent/Core/ApplicationPool/ErrorRenderer.h +0 -131
- data/src/agent/Core/SpawningKit/Options.h +0 -41
- data/src/agent/Core/UnionStation/Connection.h +0 -173
- data/src/agent/Core/UnionStation/Context.h +0 -536
- data/src/agent/Core/UnionStation/StopwatchLog.h +0 -147
- data/src/agent/Core/UnionStation/Transaction.h +0 -249
- data/src/agent/SpawnPreparer/SpawnPreparerMain.cpp +0 -208
- data/src/cxx_supportlib/UnionStationFilterSupport.cpp +0 -67
- data/src/cxx_supportlib/UnionStationFilterSupport.h +0 -1622
- data/src/nodejs_supportlib/phusion_passenger/log_express.js +0 -106
- data/src/nodejs_supportlib/phusion_passenger/log_mongodb.js +0 -202
- data/src/nodejs_supportlib/phusion_passenger/ustreporter.js +0 -227
- data/src/nodejs_supportlib/phusion_passenger/ustrouter_connector.js +0 -448
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/CONFIG.md +0 -37
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/Gemfile +0 -17
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/Gemfile.lock +0 -59
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/README-API.md +0 -5
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/README.md +0 -117
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/Rakefile +0 -115
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core.rb +0 -423
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/api.rb +0 -238
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/connection.rb +0 -67
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/context.rb +0 -281
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/lock.rb +0 -62
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/log.rb +0 -66
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/message_channel.rb +0 -157
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter.rb +0 -150
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/basics.rb +0 -199
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/controllers.rb +0 -187
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/misc.rb +0 -303
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/view_rendering.rb +0 -91
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/simple_json.rb +0 -396
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/spec_helper.rb +0 -279
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/time_point.rb +0 -39
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/transaction.rb +0 -173
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/utils.rb +0 -177
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/version.rb +0 -32
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/version_data.rb +0 -44
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/ruby_versions.yml.example +0 -16
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/ruby_versions.yml.travis +0 -20
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/ruby_versions.yml.travis-with-sudo +0 -18
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/union_station_hooks_core.gemspec +0 -23
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/Gemfile +0 -14
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/Gemfile.lock +0 -45
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/LICENSE.md +0 -19
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/README.md +0 -104
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/Rakefile +0 -160
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails.rb +0 -200
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/action_controller_extension.rb +0 -45
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/action_view_subscriber.rb +0 -55
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/active_record_subscriber.rb +0 -41
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/active_support_benchmarkable_extension.rb +0 -47
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/active_support_cache_subscriber.rb +0 -79
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/exception_logger.rb +0 -57
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/version.rb +0 -32
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/version_data.rb +0 -44
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/union_station_hooks_rails.gemspec +0 -34
@@ -0,0 +1,211 @@
|
|
1
|
+
/*
|
2
|
+
* Phusion Passenger - https://www.phusionpassenger.com/
|
3
|
+
* Copyright (c) 2011-2017 Phusion Holding B.V.
|
4
|
+
*
|
5
|
+
* "Passenger", "Phusion Passenger" and "Union Station" are registered
|
6
|
+
* trademarks of Phusion Holding B.V.
|
7
|
+
*
|
8
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
9
|
+
* of this software and associated documentation files (the "Software"), to deal
|
10
|
+
* in the Software without restriction, including without limitation the rights
|
11
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
12
|
+
* copies of the Software, and to permit persons to whom the Software is
|
13
|
+
* furnished to do so, subject to the following conditions:
|
14
|
+
*
|
15
|
+
* The above copyright notice and this permission notice shall be included in
|
16
|
+
* all copies or substantial portions of the Software.
|
17
|
+
*
|
18
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
19
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
20
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
21
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
22
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
23
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
24
|
+
* THE SOFTWARE.
|
25
|
+
*/
|
26
|
+
#ifndef _PASSENGER_SPAWNING_KIT_CONTEXT_H_
|
27
|
+
#define _PASSENGER_SPAWNING_KIT_CONTEXT_H_
|
28
|
+
|
29
|
+
#include <boost/function.hpp>
|
30
|
+
#include <boost/shared_ptr.hpp>
|
31
|
+
#include <boost/make_shared.hpp>
|
32
|
+
#include <string>
|
33
|
+
#include <algorithm>
|
34
|
+
#include <cstddef>
|
35
|
+
|
36
|
+
#include <ResourceLocator.h>
|
37
|
+
#include <RandomGenerator.h>
|
38
|
+
#include <Exceptions.h>
|
39
|
+
#include <Utils/JsonUtils.h>
|
40
|
+
#include <Utils/VariantMap.h>
|
41
|
+
#include <ConfigKit/Store.h>
|
42
|
+
|
43
|
+
namespace Passenger {
|
44
|
+
namespace ApplicationPool2 {
|
45
|
+
class Options;
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
namespace Passenger {
|
50
|
+
namespace SpawningKit {
|
51
|
+
|
52
|
+
using namespace std;
|
53
|
+
|
54
|
+
|
55
|
+
class HandshakePrepare;
|
56
|
+
typedef boost::function<void (const char *data, unsigned int size)> OutputHandler;
|
57
|
+
typedef Passenger::ApplicationPool2::Options AppPoolOptions;
|
58
|
+
|
59
|
+
|
60
|
+
class Context {
|
61
|
+
public:
|
62
|
+
class Schema: public ConfigKit::Schema {
|
63
|
+
private:
|
64
|
+
static void validate(const ConfigKit::Store &config, vector<ConfigKit::Error> &errors) {
|
65
|
+
if (config["min_port_range"].asUInt() > config["max_port_range"].asUInt()) {
|
66
|
+
errors.push_back(ConfigKit::Error(
|
67
|
+
"'{{min_port_range}}' must be equal to or smaller than {{max_port_range}}"));
|
68
|
+
}
|
69
|
+
if (config["min_port_range"].asUInt() > 65535) {
|
70
|
+
errors.push_back(ConfigKit::Error(
|
71
|
+
"{{min_port_range}} must be equal to or less than 65535"));
|
72
|
+
}
|
73
|
+
if (config["max_port_range"].asUInt() > 65535) {
|
74
|
+
errors.push_back(ConfigKit::Error(
|
75
|
+
"{{max_port_range}} must be equal to or less than 65535"));
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
79
|
+
public:
|
80
|
+
Schema() {
|
81
|
+
using namespace ConfigKit;
|
82
|
+
|
83
|
+
add("min_port_range", UINT_TYPE, OPTIONAL, 5000);
|
84
|
+
add("max_port_range", UINT_TYPE, OPTIONAL, 65535);
|
85
|
+
|
86
|
+
addValidator(validate);
|
87
|
+
finalize();
|
88
|
+
}
|
89
|
+
};
|
90
|
+
|
91
|
+
struct DebugSupport {
|
92
|
+
// Used by DummySpawner and SpawnerFactory.
|
93
|
+
unsigned int dummyConcurrency;
|
94
|
+
unsigned long long dummySpawnDelay;
|
95
|
+
unsigned long long spawnerCreationSleepTime;
|
96
|
+
|
97
|
+
DebugSupport()
|
98
|
+
: dummyConcurrency(1),
|
99
|
+
dummySpawnDelay(0),
|
100
|
+
spawnerCreationSleepTime(0)
|
101
|
+
{ }
|
102
|
+
};
|
103
|
+
|
104
|
+
private:
|
105
|
+
friend class HandshakePrepare;
|
106
|
+
|
107
|
+
|
108
|
+
mutable boost::mutex syncher;
|
109
|
+
|
110
|
+
|
111
|
+
/****** Context-global configuration ******/
|
112
|
+
|
113
|
+
// Actual configuration store.
|
114
|
+
ConfigKit::Store config;
|
115
|
+
|
116
|
+
// Below follows cached values.
|
117
|
+
|
118
|
+
// Other.
|
119
|
+
unsigned int minPortRange, maxPortRange;
|
120
|
+
|
121
|
+
|
122
|
+
/****** Working state ******/
|
123
|
+
|
124
|
+
bool finalized;
|
125
|
+
unsigned int nextPort;
|
126
|
+
|
127
|
+
|
128
|
+
void updateConfigCache() {
|
129
|
+
minPortRange = config["min_port_range"].asUInt();
|
130
|
+
maxPortRange = config["max_port_range"].asUInt();
|
131
|
+
nextPort = std::max(std::min(nextPort, maxPortRange), minPortRange);
|
132
|
+
}
|
133
|
+
|
134
|
+
public:
|
135
|
+
/****** Dependencies ******/
|
136
|
+
|
137
|
+
ResourceLocator *resourceLocator;
|
138
|
+
RandomGeneratorPtr randomGenerator;
|
139
|
+
string integrationMode;
|
140
|
+
string instanceDir;
|
141
|
+
DebugSupport *debugSupport;
|
142
|
+
//UnionStation::ContextPtr unionStationContext;
|
143
|
+
|
144
|
+
|
145
|
+
Context(const Schema &schema, const Json::Value &initialConfig = Json::Value())
|
146
|
+
: config(schema),
|
147
|
+
|
148
|
+
finalized(false),
|
149
|
+
nextPort(0),
|
150
|
+
|
151
|
+
resourceLocator(NULL),
|
152
|
+
debugSupport(NULL)
|
153
|
+
{
|
154
|
+
vector<ConfigKit::Error> errors;
|
155
|
+
|
156
|
+
if (!config.update(initialConfig, errors)) {
|
157
|
+
throw ArgumentException("Invalid initial configuration: "
|
158
|
+
+ toString(errors));
|
159
|
+
}
|
160
|
+
updateConfigCache();
|
161
|
+
}
|
162
|
+
|
163
|
+
Json::Value previewConfigUpdate(const Json::Value &updates,
|
164
|
+
vector<ConfigKit::Error> &errors)
|
165
|
+
{
|
166
|
+
boost::lock_guard<boost::mutex> l(syncher);
|
167
|
+
return config.previewUpdate(updates, errors);
|
168
|
+
}
|
169
|
+
|
170
|
+
bool configure(const Json::Value &updates, vector<ConfigKit::Error> &errors) {
|
171
|
+
boost::lock_guard<boost::mutex> l(syncher);
|
172
|
+
if (config.update(updates, errors)) {
|
173
|
+
updateConfigCache();
|
174
|
+
return true;
|
175
|
+
} else {
|
176
|
+
return false;
|
177
|
+
}
|
178
|
+
}
|
179
|
+
|
180
|
+
Json::Value inspectConfig() const {
|
181
|
+
boost::lock_guard<boost::mutex> l(syncher);
|
182
|
+
return config.inspect();
|
183
|
+
}
|
184
|
+
|
185
|
+
void finalize() {
|
186
|
+
TRACE_POINT();
|
187
|
+
if (resourceLocator == NULL) {
|
188
|
+
throw RuntimeException("ResourceLocator not initialized");
|
189
|
+
}
|
190
|
+
if (randomGenerator == NULL) {
|
191
|
+
randomGenerator = boost::make_shared<RandomGenerator>();
|
192
|
+
}
|
193
|
+
if (integrationMode.empty()) {
|
194
|
+
throw RuntimeException("integrationMode not set");
|
195
|
+
}
|
196
|
+
|
197
|
+
finalized = true;
|
198
|
+
}
|
199
|
+
|
200
|
+
bool isFinalized() const {
|
201
|
+
return finalized;
|
202
|
+
}
|
203
|
+
};
|
204
|
+
|
205
|
+
typedef boost::shared_ptr<Context> ContextPtr;
|
206
|
+
|
207
|
+
|
208
|
+
} // namespace SpawningKit
|
209
|
+
} // namespace Passenger
|
210
|
+
|
211
|
+
#endif /* _PASSENGER_SPAWNING_KIT_CONTEXT_H_ */
|
@@ -26,13 +26,20 @@
|
|
26
26
|
#ifndef _PASSENGER_SPAWNING_KIT_DIRECT_SPAWNER_H_
|
27
27
|
#define _PASSENGER_SPAWNING_KIT_DIRECT_SPAWNER_H_
|
28
28
|
|
29
|
+
#include <stdexcept>
|
30
|
+
|
29
31
|
#include <Core/SpawningKit/Spawner.h>
|
32
|
+
#include <Core/SpawningKit/Handshake/Session.h>
|
33
|
+
#include <Core/SpawningKit/Handshake/Prepare.h>
|
34
|
+
#include <Core/SpawningKit/Handshake/Perform.h>
|
35
|
+
#include <ProcessManagement/Utils.h>
|
30
36
|
#include <Constants.h>
|
31
37
|
#include <LoggingKit/LoggingKit.h>
|
32
38
|
#include <LveLoggingDecorator.h>
|
39
|
+
#include <Utils/IOUtils.h>
|
40
|
+
|
33
41
|
#include <limits.h> // for PTHREAD_STACK_MIN
|
34
42
|
#include <pthread.h>
|
35
|
-
|
36
43
|
#include <adhoc_lve.h>
|
37
44
|
|
38
45
|
namespace Passenger {
|
@@ -112,161 +119,144 @@ private:
|
|
112
119
|
startBackgroundThread(detachProcessMain, (void *) (long) pid);
|
113
120
|
}
|
114
121
|
|
115
|
-
|
116
|
-
|
122
|
+
void setConfigFromAppPoolOptions(Config *config, Json::Value &extraArgs,
|
123
|
+
const AppPoolOptions &options)
|
117
124
|
{
|
118
|
-
|
119
|
-
|
120
|
-
vector<string> command;
|
121
|
-
|
122
|
-
split(options.getStartCommand(*config->resourceLocator), '\t', startCommandArgs);
|
123
|
-
if (startCommandArgs.empty()) {
|
124
|
-
throw RuntimeException("No startCommand given");
|
125
|
-
}
|
126
|
-
|
127
|
-
if (shouldLoadShellEnvvars(options, preparation)) {
|
128
|
-
command.push_back(preparation.userSwitching.shell);
|
129
|
-
command.push_back(preparation.userSwitching.shell);
|
130
|
-
if (LoggingKit::getLevel() >= LoggingKit::DEBUG3) {
|
131
|
-
command.push_back("-lxc");
|
132
|
-
} else {
|
133
|
-
command.push_back("-lc");
|
134
|
-
}
|
135
|
-
command.push_back("exec \"$@\"");
|
136
|
-
command.push_back("SpawnPreparerShell");
|
137
|
-
} else {
|
138
|
-
command.push_back(agentFilename);
|
139
|
-
}
|
140
|
-
command.push_back(agentFilename);
|
141
|
-
command.push_back("spawn-preparer");
|
142
|
-
command.push_back(preparation.appRoot);
|
143
|
-
command.push_back(serializeEnvvarsFromPoolOptions(options));
|
144
|
-
command.push_back(startCommandArgs[0]);
|
145
|
-
// Note: do not try to set a process title here.
|
146
|
-
// https://code.google.com/p/phusion-passenger/issues/detail?id=855
|
147
|
-
command.push_back(startCommandArgs[0]);
|
148
|
-
for (unsigned int i = 1; i < startCommandArgs.size(); i++) {
|
149
|
-
command.push_back(startCommandArgs[i]);
|
150
|
-
}
|
151
|
-
|
152
|
-
createCommandArgs(command, args);
|
153
|
-
return command;
|
125
|
+
Spawner::setConfigFromAppPoolOptions(config, extraArgs, options);
|
126
|
+
config->spawnMethod = P_STATIC_STRING("direct");
|
154
127
|
}
|
155
128
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
virtual Result spawn(const Options &options) {
|
129
|
+
Result internalSpawn(const AppPoolOptions &options, Config &config,
|
130
|
+
HandshakeSession &session, const Json::Value &extraArgs,
|
131
|
+
JourneyStep &stepToMarkAsErrored)
|
132
|
+
{
|
162
133
|
TRACE_POINT();
|
163
|
-
|
164
|
-
|
165
|
-
P_DEBUG("Spawning new process: appRoot=" << options.appRoot);
|
166
|
-
possiblyRaiseInternalError(options);
|
167
|
-
|
168
|
-
shared_array<const char *> args;
|
169
|
-
SpawnPreparationInfo preparation = prepareSpawn(options);
|
170
|
-
vector<string> command = createCommand(options, preparation, args);
|
171
|
-
SocketPair adminSocket = createUnixSocketPair(__FILE__, __LINE__);
|
172
|
-
Pipe errorPipe = createPipe(__FILE__, __LINE__);
|
173
|
-
DebugDirPtr debugDir = boost::make_shared<DebugDir>(preparation.userSwitching.uid,
|
174
|
-
preparation.userSwitching.gid);
|
175
|
-
pid_t pid;
|
176
|
-
|
134
|
+
Pipe stdinChannel = createPipe(__FILE__, __LINE__);
|
135
|
+
Pipe stdoutAndErrChannel = createPipe(__FILE__, __LINE__);
|
177
136
|
adhoc_lve::LveEnter scopedLveEnter(LveLoggingDecorator::lveInitOnce(),
|
178
|
-
|
179
|
-
|
180
|
-
|
137
|
+
session.uid,
|
138
|
+
config.lveMinUid,
|
139
|
+
LveLoggingDecorator::lveExitCallback);
|
181
140
|
LveLoggingDecorator::logLveEnter(scopedLveEnter,
|
182
|
-
|
183
|
-
|
141
|
+
session.uid,
|
142
|
+
config.lveMinUid);
|
143
|
+
string agentFilename = context->resourceLocator
|
144
|
+
->findSupportBinary(AGENT_EXE);
|
184
145
|
|
185
|
-
|
146
|
+
session.journey.setStepPerformed(SPAWNING_KIT_PREPARATION);
|
147
|
+
session.journey.setStepInProgress(SPAWNING_KIT_FORK_SUBPROCESS);
|
148
|
+
session.journey.setStepInProgress(SUBPROCESS_BEFORE_FIRST_EXEC);
|
149
|
+
stepToMarkAsErrored = SPAWNING_KIT_FORK_SUBPROCESS;
|
150
|
+
|
151
|
+
pid_t pid = syscalls::fork();
|
186
152
|
if (pid == 0) {
|
187
|
-
setenv("PASSENGER_DEBUG_DIR", debugDir->getPath().c_str(), 1);
|
188
153
|
purgeStdio(stdout);
|
189
154
|
purgeStdio(stderr);
|
190
155
|
resetSignalHandlersAndMask();
|
191
156
|
disableMallocDebugging();
|
192
|
-
int
|
193
|
-
int
|
194
|
-
dup2(
|
195
|
-
dup2(
|
196
|
-
dup2(
|
197
|
-
closeAllFileDescriptors(2);
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
157
|
+
int stdinCopy = dup2(stdinChannel.first, 3);
|
158
|
+
int stdoutAndErrCopy = dup2(stdoutAndErrChannel.second, 4);
|
159
|
+
dup2(stdinCopy, 0);
|
160
|
+
dup2(stdoutAndErrCopy, 1);
|
161
|
+
dup2(stdoutAndErrCopy, 2);
|
162
|
+
closeAllFileDescriptors(2, true);
|
163
|
+
execlp(agentFilename.c_str(),
|
164
|
+
agentFilename.c_str(),
|
165
|
+
"spawn-env-setupper",
|
166
|
+
session.workDir->getPath().c_str(),
|
167
|
+
"--before",
|
168
|
+
NULL);
|
203
169
|
|
204
170
|
int e = errno;
|
205
|
-
printf("!> Error\n");
|
206
|
-
printf("!> \n");
|
207
|
-
printf("Cannot execute \"%s\": %s (errno=%d)\n", command[0].c_str(),
|
208
|
-
strerror(e), e);
|
209
171
|
fprintf(stderr, "Cannot execute \"%s\": %s (errno=%d)\n",
|
210
|
-
|
211
|
-
fflush(stdout);
|
172
|
+
agentFilename.c_str(), strerror(e), e);
|
212
173
|
fflush(stderr);
|
213
174
|
_exit(1);
|
214
175
|
|
215
176
|
} else if (pid == -1) {
|
216
177
|
int e = errno;
|
217
|
-
|
178
|
+
session.journey.setStepErrored(SPAWNING_KIT_FORK_SUBPROCESS);
|
179
|
+
SpawnException ex(OPERATING_SYSTEM_ERROR, session.journey, &config);
|
180
|
+
ex.setSummary(StaticString("Cannot fork a new process: ") + strerror(e)
|
181
|
+
+ " (errno=" + toString(e) + ")");
|
182
|
+
ex.setAdvancedProblemDetails(StaticString("Cannot fork a new process: ")
|
183
|
+
+ strerror(e) + " (errno=" + toString(e) + ")");
|
184
|
+
throw ex.finalize();
|
218
185
|
|
219
186
|
} else {
|
220
187
|
UPDATE_TRACE_POINT();
|
188
|
+
session.journey.setStepPerformed(SPAWNING_KIT_FORK_SUBPROCESS);
|
189
|
+
session.journey.setStepInProgress(SPAWNING_KIT_HANDSHAKE_PERFORM);
|
190
|
+
stepToMarkAsErrored = SPAWNING_KIT_HANDSHAKE_PERFORM;
|
191
|
+
|
221
192
|
scopedLveEnter.exit();
|
222
193
|
|
223
|
-
P_LOG_FILE_DESCRIPTOR_PURPOSE(
|
224
|
-
"App " << pid << " (" << options.appRoot << ")
|
225
|
-
P_LOG_FILE_DESCRIPTOR_PURPOSE(
|
226
|
-
"App " << pid << " (" << options.appRoot << ")
|
227
|
-
P_LOG_FILE_DESCRIPTOR_PURPOSE(errorPipe.first,
|
228
|
-
"App " << pid << " (" << options.appRoot << ") errorPipe[0]");
|
229
|
-
P_LOG_FILE_DESCRIPTOR_PURPOSE(errorPipe.second,
|
230
|
-
"App " << pid << " (" << options.appRoot << ") errorPipe[1]");
|
194
|
+
P_LOG_FILE_DESCRIPTOR_PURPOSE(stdinChannel.second,
|
195
|
+
"App " << pid << " (" << options.appRoot << ") stdin");
|
196
|
+
P_LOG_FILE_DESCRIPTOR_PURPOSE(stdoutAndErrChannel.first,
|
197
|
+
"App " << pid << " (" << options.appRoot << ") stdoutAndErr");
|
231
198
|
|
232
199
|
UPDATE_TRACE_POINT();
|
233
200
|
ScopeGuard guard(boost::bind(nonInterruptableKillAndWaitpid, pid));
|
234
201
|
P_DEBUG("Process forked for appRoot=" << options.appRoot << ": PID " << pid);
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
NegotiationDetails details;
|
239
|
-
details.preparation = &preparation;
|
240
|
-
details.stderrCapturer =
|
241
|
-
boost::make_shared<BackgroundIOCapturer>(
|
242
|
-
errorPipe.first,
|
243
|
-
pid,
|
244
|
-
// The cast works around a compilation problem in Clang.
|
245
|
-
(const char *) "stderr",
|
246
|
-
options.getAppGroupName(),
|
247
|
-
options.appLogFile);
|
248
|
-
details.stderrCapturer->start();
|
249
|
-
details.pid = pid;
|
250
|
-
details.adminSocket = adminSocket.second;
|
251
|
-
details.io = BufferedIO(adminSocket.second);
|
252
|
-
details.errorPipe = errorPipe.first;
|
253
|
-
details.options = &options;
|
254
|
-
details.debugDir = debugDir;
|
202
|
+
stdinChannel.first.close();
|
203
|
+
stdoutAndErrChannel.second.close();
|
255
204
|
|
256
|
-
|
257
|
-
|
258
|
-
{
|
259
|
-
boost::this_thread::restore_interruption ri(di);
|
260
|
-
boost::this_thread::restore_syscall_interruption rsi(dsi);
|
261
|
-
result = negotiateSpawn(details);
|
262
|
-
}
|
205
|
+
HandshakePerform(session, pid, stdinChannel.second,
|
206
|
+
stdoutAndErrChannel.first).execute();
|
263
207
|
|
264
208
|
UPDATE_TRACE_POINT();
|
265
|
-
detachProcess(result
|
209
|
+
detachProcess(session.result.pid);
|
266
210
|
guard.clear();
|
211
|
+
session.journey.setStepPerformed(SPAWNING_KIT_HANDSHAKE_PERFORM);
|
267
212
|
P_DEBUG("Process spawning done: appRoot=" << options.appRoot <<
|
268
|
-
", pid=" << result
|
269
|
-
return result;
|
213
|
+
", pid=" << session.result.pid);
|
214
|
+
return session.result;
|
215
|
+
}
|
216
|
+
}
|
217
|
+
|
218
|
+
public:
|
219
|
+
DirectSpawner(Context *context)
|
220
|
+
: Spawner(context)
|
221
|
+
{ }
|
222
|
+
|
223
|
+
virtual Result spawn(const AppPoolOptions &options) {
|
224
|
+
TRACE_POINT();
|
225
|
+
boost::this_thread::disable_interruption di;
|
226
|
+
boost::this_thread::disable_syscall_interruption dsi;
|
227
|
+
P_DEBUG("Spawning new process: appRoot=" << options.appRoot);
|
228
|
+
possiblyRaiseInternalError(options);
|
229
|
+
|
230
|
+
UPDATE_TRACE_POINT();
|
231
|
+
Config config;
|
232
|
+
Json::Value extraArgs;
|
233
|
+
try {
|
234
|
+
setConfigFromAppPoolOptions(&config, extraArgs, options);
|
235
|
+
} catch (const std::exception &originalException) {
|
236
|
+
UPDATE_TRACE_POINT();
|
237
|
+
Journey journey(SPAWN_THROUGH_PRELOADER, true);
|
238
|
+
journey.setStepErrored(SPAWNING_KIT_PREPARATION, true);
|
239
|
+
SpawnException e(originalException, journey, &config);
|
240
|
+
throw e.finalize();
|
241
|
+
}
|
242
|
+
|
243
|
+
UPDATE_TRACE_POINT();
|
244
|
+
HandshakeSession session(*context, config, SPAWN_DIRECTLY);
|
245
|
+
session.journey.setStepInProgress(SPAWNING_KIT_PREPARATION);
|
246
|
+
HandshakePrepare(session, extraArgs).execute();
|
247
|
+
JourneyStep stepToMarkAsErrored = SPAWNING_KIT_PREPARATION;
|
248
|
+
|
249
|
+
UPDATE_TRACE_POINT();
|
250
|
+
try {
|
251
|
+
return internalSpawn(options, config, session, extraArgs,
|
252
|
+
stepToMarkAsErrored);
|
253
|
+
} catch (const SpawnException &) {
|
254
|
+
throw;
|
255
|
+
} catch (const std::exception &originalException) {
|
256
|
+
UPDATE_TRACE_POINT();
|
257
|
+
session.journey.setStepErrored(stepToMarkAsErrored, true);
|
258
|
+
throw SpawnException(originalException, session.journey,
|
259
|
+
&config).finalize();
|
270
260
|
}
|
271
261
|
}
|
272
262
|
};
|