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
@@ -1,147 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Phusion Passenger - https://www.phusionpassenger.com/
|
3
|
-
* Copyright (c) 2010-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_UNION_STATION_STOPWATCH_LOG_H_
|
27
|
-
#define _PASSENGER_UNION_STATION_STOPWATCH_LOG_H_
|
28
|
-
|
29
|
-
#include <boost/noncopyable.hpp>
|
30
|
-
|
31
|
-
#include <sys/resource.h>
|
32
|
-
|
33
|
-
#include <string>
|
34
|
-
|
35
|
-
#include <StaticString.h>
|
36
|
-
#include <Exceptions.h>
|
37
|
-
#include <Utils/StrIntUtils.h>
|
38
|
-
#include <Utils/SystemTime.h>
|
39
|
-
#include <Core/UnionStation/Transaction.h>
|
40
|
-
|
41
|
-
namespace Passenger {
|
42
|
-
namespace UnionStation {
|
43
|
-
|
44
|
-
using namespace std;
|
45
|
-
using namespace boost;
|
46
|
-
|
47
|
-
|
48
|
-
class StopwatchLog: public noncopyable {
|
49
|
-
private:
|
50
|
-
Transaction * const transaction;
|
51
|
-
const char *id;
|
52
|
-
bool ok;
|
53
|
-
|
54
|
-
static string timevalToString(struct timeval &tv) {
|
55
|
-
unsigned long long i = (unsigned long long) tv.tv_sec * 1000000 + tv.tv_usec;
|
56
|
-
return usecToString(i);
|
57
|
-
}
|
58
|
-
|
59
|
-
static string usecToString(unsigned long long usec) {
|
60
|
-
char timestamp[2 * sizeof(unsigned long long) + 1];
|
61
|
-
integerToHexatri<unsigned long long>(usec, timestamp);
|
62
|
-
return timestamp;
|
63
|
-
}
|
64
|
-
|
65
|
-
public:
|
66
|
-
StopwatchLog()
|
67
|
-
: transaction(NULL)
|
68
|
-
{ }
|
69
|
-
|
70
|
-
StopwatchLog(const TransactionPtr &_transaction, const char *id, const char *nameAndData)
|
71
|
-
: transaction(_transaction.get())
|
72
|
-
{
|
73
|
-
this->id = id;
|
74
|
-
ok = false;
|
75
|
-
|
76
|
-
char message[250];
|
77
|
-
char *pos = message;
|
78
|
-
const char *end = message + sizeof(message);
|
79
|
-
struct rusage usage;
|
80
|
-
|
81
|
-
pos = appendData(pos, end, "BEGIN: ");
|
82
|
-
pos = appendData(pos, end, id);
|
83
|
-
pos = appendData(pos, end, " (");
|
84
|
-
pos = appendData(pos, end, usecToString(SystemTime::getMonotonicUsec()));
|
85
|
-
pos = appendData(pos, end, ",");
|
86
|
-
if (getrusage(RUSAGE_SELF, &usage) == -1) {
|
87
|
-
int e = errno;
|
88
|
-
throw SystemException("getrusage() failed", e);
|
89
|
-
}
|
90
|
-
pos = appendData(pos, end, timevalToString(usage.ru_utime));
|
91
|
-
pos = appendData(pos, end, ",");
|
92
|
-
pos = appendData(pos, end, timevalToString(usage.ru_stime));
|
93
|
-
pos = appendData(pos, end, ") ");
|
94
|
-
|
95
|
-
if (nameAndData != NULL) {
|
96
|
-
try {
|
97
|
-
pos = appendData(pos, end, modp::b64_encode(nameAndData));
|
98
|
-
} catch (const std::runtime_error &) {
|
99
|
-
// non-fatal: ignore
|
100
|
-
}
|
101
|
-
}
|
102
|
-
|
103
|
-
if (transaction != NULL) {
|
104
|
-
transaction->message(StaticString(message, pos - message));
|
105
|
-
}
|
106
|
-
}
|
107
|
-
|
108
|
-
~StopwatchLog() {
|
109
|
-
if (transaction == NULL) {
|
110
|
-
return;
|
111
|
-
}
|
112
|
-
char message[150];
|
113
|
-
char *pos = message;
|
114
|
-
const char *end = message + sizeof(message);
|
115
|
-
struct rusage usage;
|
116
|
-
|
117
|
-
if (ok) {
|
118
|
-
pos = appendData(pos, end, "END: ");
|
119
|
-
} else {
|
120
|
-
pos = appendData(pos, end, "FAIL: ");
|
121
|
-
}
|
122
|
-
pos = appendData(pos, end, id);
|
123
|
-
pos = appendData(pos, end, " (");
|
124
|
-
pos = appendData(pos, end, usecToString(SystemTime::getMonotonicUsec()));
|
125
|
-
pos = appendData(pos, end, ",");
|
126
|
-
if (getrusage(RUSAGE_SELF, &usage) == -1) {
|
127
|
-
int e = errno;
|
128
|
-
throw SystemException("getrusage() failed", e);
|
129
|
-
}
|
130
|
-
pos = appendData(pos, end, timevalToString(usage.ru_utime));
|
131
|
-
pos = appendData(pos, end, ",");
|
132
|
-
pos = appendData(pos, end, timevalToString(usage.ru_stime));
|
133
|
-
pos = appendData(pos, end, ")");
|
134
|
-
|
135
|
-
transaction->message(StaticString(message, pos - message));
|
136
|
-
}
|
137
|
-
|
138
|
-
void success() {
|
139
|
-
ok = true;
|
140
|
-
}
|
141
|
-
};
|
142
|
-
|
143
|
-
|
144
|
-
} // namespace UnionStation
|
145
|
-
} // namespace Passenger
|
146
|
-
|
147
|
-
#endif /* _PASSENGER_UNION_STATION_STOPWATCH_LOG_H_ */
|
@@ -1,249 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Phusion Passenger - https://www.phusionpassenger.com/
|
3
|
-
* Copyright (c) 2010-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_UNION_STATION_TRANSACTION_H_
|
27
|
-
#define _PASSENGER_UNION_STATION_TRANSACTION_H_
|
28
|
-
|
29
|
-
#include <boost/shared_ptr.hpp>
|
30
|
-
#include <boost/noncopyable.hpp>
|
31
|
-
#include <oxt/backtrace.hpp>
|
32
|
-
|
33
|
-
#include <string>
|
34
|
-
#include <stdexcept>
|
35
|
-
|
36
|
-
#include <cstdio>
|
37
|
-
#include <cassert>
|
38
|
-
|
39
|
-
#include <LoggingKit/LoggingKit.h>
|
40
|
-
#include <Exceptions.h>
|
41
|
-
#include <StaticString.h>
|
42
|
-
#include <Utils/IOUtils.h>
|
43
|
-
#include <Utils/SystemTime.h>
|
44
|
-
#include <Utils/StrIntUtils.h>
|
45
|
-
#include <Core/UnionStation/Connection.h>
|
46
|
-
|
47
|
-
namespace Passenger {
|
48
|
-
namespace UnionStation {
|
49
|
-
|
50
|
-
using namespace std;
|
51
|
-
using namespace boost;
|
52
|
-
|
53
|
-
|
54
|
-
enum ExceptionHandlingMode {
|
55
|
-
PRINT,
|
56
|
-
THROW,
|
57
|
-
IGNORE
|
58
|
-
};
|
59
|
-
|
60
|
-
|
61
|
-
class Context;
|
62
|
-
typedef boost::shared_ptr<Context> ContextPtr;
|
63
|
-
|
64
|
-
inline void _checkinConnection(const ContextPtr &ctx, const ConnectionPtr &connection);
|
65
|
-
|
66
|
-
|
67
|
-
class Transaction: public boost::noncopyable {
|
68
|
-
private:
|
69
|
-
static const int INT64_STR_BUFSIZE = 22; // Long enough for a 64-bit number.
|
70
|
-
static const unsigned long long IO_TIMEOUT = 5000000; // In microseconds.
|
71
|
-
|
72
|
-
const ContextPtr context;
|
73
|
-
const ConnectionPtr connection;
|
74
|
-
const string txnId;
|
75
|
-
const string groupName;
|
76
|
-
const string category;
|
77
|
-
const string unionStationKey;
|
78
|
-
const ExceptionHandlingMode exceptionHandlingMode;
|
79
|
-
|
80
|
-
/**
|
81
|
-
* Buffer must be at least txnId.size() + 1 + INT64_STR_BUFSIZE + 1 bytes.
|
82
|
-
*/
|
83
|
-
char *insertTxnIdAndTimestamp(char *buffer, const char *end) {
|
84
|
-
assert(end - buffer >= int(txnId.size() + 1 + INT64_STR_BUFSIZE + 1));
|
85
|
-
int size;
|
86
|
-
|
87
|
-
// "txn-id-here"
|
88
|
-
buffer = appendData(buffer, end, txnId);
|
89
|
-
|
90
|
-
// "txn-id-here "
|
91
|
-
buffer = appendData(buffer, end, " ", 1);
|
92
|
-
|
93
|
-
// "txn-id-here 123456"
|
94
|
-
assert(end - buffer >= INT64_STR_BUFSIZE);
|
95
|
-
size = snprintf(buffer, INT64_STR_BUFSIZE, "%llu", SystemTime::getUsec());
|
96
|
-
if (size >= INT64_STR_BUFSIZE) {
|
97
|
-
// The buffer is too small.
|
98
|
-
throw IOException("Cannot format a new transaction log message timestamp.");
|
99
|
-
}
|
100
|
-
buffer += size;
|
101
|
-
|
102
|
-
// "txn-id-here 123456 "
|
103
|
-
buffer = appendData(buffer, end, " ", 1);
|
104
|
-
|
105
|
-
return buffer;
|
106
|
-
}
|
107
|
-
|
108
|
-
template<typename ExceptionType>
|
109
|
-
void handleException(const ExceptionType &e) {
|
110
|
-
switch (exceptionHandlingMode) {
|
111
|
-
case THROW:
|
112
|
-
throw e;
|
113
|
-
case PRINT: {
|
114
|
-
const tracable_exception *te =
|
115
|
-
dynamic_cast<const tracable_exception *>(&e);
|
116
|
-
if (te != NULL) {
|
117
|
-
P_WARN(te->what() << "\n" << te->backtrace());
|
118
|
-
} else {
|
119
|
-
P_WARN(e.what());
|
120
|
-
}
|
121
|
-
break;
|
122
|
-
}
|
123
|
-
default:
|
124
|
-
break;
|
125
|
-
}
|
126
|
-
}
|
127
|
-
|
128
|
-
public:
|
129
|
-
Transaction()
|
130
|
-
: exceptionHandlingMode(PRINT)
|
131
|
-
{ }
|
132
|
-
|
133
|
-
Transaction(const ContextPtr &_context,
|
134
|
-
const ConnectionPtr &_connection,
|
135
|
-
const string &_txnId,
|
136
|
-
const string &_groupName,
|
137
|
-
const string &_category,
|
138
|
-
const string &_unionStationKey,
|
139
|
-
ExceptionHandlingMode _exceptionHandlingMode = PRINT)
|
140
|
-
: context(_context),
|
141
|
-
connection(_connection),
|
142
|
-
txnId(_txnId),
|
143
|
-
groupName(_groupName),
|
144
|
-
category(_category),
|
145
|
-
unionStationKey(_unionStationKey),
|
146
|
-
exceptionHandlingMode(_exceptionHandlingMode)
|
147
|
-
{ }
|
148
|
-
|
149
|
-
~Transaction() {
|
150
|
-
TRACE_POINT();
|
151
|
-
if (connection == NULL) {
|
152
|
-
return;
|
153
|
-
}
|
154
|
-
ConnectionLock l(connection);
|
155
|
-
if (!connection->connected()) {
|
156
|
-
return;
|
157
|
-
}
|
158
|
-
|
159
|
-
char timestamp[2 * sizeof(unsigned long long) + 1];
|
160
|
-
integerToHexatri<unsigned long long>(SystemTime::getUsec(),
|
161
|
-
timestamp);
|
162
|
-
|
163
|
-
UPDATE_TRACE_POINT();
|
164
|
-
ConnectionGuard guard(connection.get());
|
165
|
-
try {
|
166
|
-
unsigned long long timeout = IO_TIMEOUT;
|
167
|
-
writeArrayMessage(connection->fd, &timeout,
|
168
|
-
"closeTransaction",
|
169
|
-
txnId.c_str(),
|
170
|
-
timestamp,
|
171
|
-
NULL);
|
172
|
-
|
173
|
-
_checkinConnection(context, connection);
|
174
|
-
guard.clear();
|
175
|
-
} catch (const SystemException &e) {
|
176
|
-
UPDATE_TRACE_POINT();
|
177
|
-
guard.clear();
|
178
|
-
connection->disconnect();
|
179
|
-
handleException(e);
|
180
|
-
}
|
181
|
-
}
|
182
|
-
|
183
|
-
void message(const StaticString &text) {
|
184
|
-
TRACE_POINT();
|
185
|
-
if (connection == NULL) {
|
186
|
-
P_TRACE(3, "[Union Station log to null] " << text);
|
187
|
-
return;
|
188
|
-
}
|
189
|
-
ConnectionLock l(connection);
|
190
|
-
if (!connection->connected()) {
|
191
|
-
P_TRACE(3, "[Union Station log to null] " << text);
|
192
|
-
return;
|
193
|
-
}
|
194
|
-
|
195
|
-
char timestamp[2 * sizeof(unsigned long long) + 1];
|
196
|
-
integerToHexatri<unsigned long long>(SystemTime::getUsec(), timestamp);
|
197
|
-
|
198
|
-
UPDATE_TRACE_POINT();
|
199
|
-
ConnectionGuard guard(connection.get());
|
200
|
-
try {
|
201
|
-
unsigned long long timeout = IO_TIMEOUT;
|
202
|
-
P_TRACE(3, "[Union Station log] " << txnId << " " << timestamp << " " << text);
|
203
|
-
writeArrayMessage(connection->fd, &timeout,
|
204
|
-
"log",
|
205
|
-
txnId.c_str(),
|
206
|
-
timestamp,
|
207
|
-
NULL);
|
208
|
-
writeScalarMessage(connection->fd, text, &timeout);
|
209
|
-
guard.clear();
|
210
|
-
} catch (const std::exception &e) {
|
211
|
-
UPDATE_TRACE_POINT();
|
212
|
-
guard.clear();
|
213
|
-
connection->disconnect();
|
214
|
-
handleException(e);
|
215
|
-
}
|
216
|
-
}
|
217
|
-
|
218
|
-
void abort(const StaticString &text) {
|
219
|
-
message("ABORT");
|
220
|
-
}
|
221
|
-
|
222
|
-
bool isNull() const {
|
223
|
-
return connection == NULL;
|
224
|
-
}
|
225
|
-
|
226
|
-
const string &getTxnId() const {
|
227
|
-
return txnId;
|
228
|
-
}
|
229
|
-
|
230
|
-
const string &getGroupName() const {
|
231
|
-
return groupName;
|
232
|
-
}
|
233
|
-
|
234
|
-
const string &getCategory() const {
|
235
|
-
return category;
|
236
|
-
}
|
237
|
-
|
238
|
-
const string &getUnionStationKey() const {
|
239
|
-
return unionStationKey;
|
240
|
-
}
|
241
|
-
};
|
242
|
-
|
243
|
-
typedef boost::shared_ptr<Transaction> TransactionPtr;
|
244
|
-
|
245
|
-
|
246
|
-
} // namespace UnionStation
|
247
|
-
} // namespace Passenger
|
248
|
-
|
249
|
-
#endif /* _PASSENGER_UNION_STATION_TRANSACTION_H_ */
|
@@ -1,208 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Phusion Passenger - https://www.phusionpassenger.com/
|
3
|
-
* Copyright (c) 2012-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
|
-
|
27
|
-
/*
|
28
|
-
* Sets given environment variables, dumps the entire environment to
|
29
|
-
* a given file (for diagnostics purposes), then execs the given command.
|
30
|
-
*
|
31
|
-
* This is a separate executable because it does quite
|
32
|
-
* some non-async-signal-safe stuff that we can't do after
|
33
|
-
* fork()ing from the Spawner and before exec()ing.
|
34
|
-
*/
|
35
|
-
|
36
|
-
#include <cstdio>
|
37
|
-
#include <cstdlib>
|
38
|
-
#include <cstring>
|
39
|
-
#include <cerrno>
|
40
|
-
#include <sys/types.h>
|
41
|
-
#include <sys/wait.h>
|
42
|
-
#include <unistd.h>
|
43
|
-
#include <stdlib.h>
|
44
|
-
#include <string>
|
45
|
-
#include <sstream>
|
46
|
-
#include <modp_b64.h>
|
47
|
-
#include <Utils/SystemMetricsCollector.h>
|
48
|
-
|
49
|
-
using namespace std;
|
50
|
-
using namespace Passenger;
|
51
|
-
|
52
|
-
extern "C" {
|
53
|
-
extern char **environ;
|
54
|
-
}
|
55
|
-
|
56
|
-
static void
|
57
|
-
changeWorkingDir(const char *dir) {
|
58
|
-
int ret = chdir(dir);
|
59
|
-
if (ret == 0) {
|
60
|
-
setenv("PWD", dir, 1);
|
61
|
-
} else {
|
62
|
-
int e = errno;
|
63
|
-
printf("!> Error\n");
|
64
|
-
printf("!> \n");
|
65
|
-
printf("Unable to change working directory to '%s': %s (errno=%d)\n",
|
66
|
-
dir, strerror(e), e);
|
67
|
-
fflush(stdout);
|
68
|
-
exit(1);
|
69
|
-
}
|
70
|
-
}
|
71
|
-
|
72
|
-
static void
|
73
|
-
setGivenEnvVars(const char *envvarsData) {
|
74
|
-
string envvars = modp::b64_decode(envvarsData);
|
75
|
-
const char *key = envvars.data();
|
76
|
-
const char *end = envvars.data() + envvars.size();
|
77
|
-
|
78
|
-
while (key < end) {
|
79
|
-
const char *keyEnd = (const char *) memchr(key, '\0', end - key);
|
80
|
-
if (keyEnd != NULL) {
|
81
|
-
const char *value = keyEnd + 1;
|
82
|
-
if (value < end) {
|
83
|
-
const char *valueEnd = (const char *) memchr(value, '\0', end - value);
|
84
|
-
if (valueEnd != NULL) {
|
85
|
-
setenv(key, value, 1);
|
86
|
-
key = valueEnd + 1;
|
87
|
-
} else {
|
88
|
-
break;
|
89
|
-
}
|
90
|
-
} else {
|
91
|
-
break;
|
92
|
-
}
|
93
|
-
} else {
|
94
|
-
break;
|
95
|
-
}
|
96
|
-
}
|
97
|
-
}
|
98
|
-
|
99
|
-
static void
|
100
|
-
dumpInformation() {
|
101
|
-
const char *c_dir;
|
102
|
-
if ((c_dir = getenv("PASSENGER_DEBUG_DIR")) == NULL) {
|
103
|
-
return;
|
104
|
-
}
|
105
|
-
|
106
|
-
FILE *f;
|
107
|
-
string dir = c_dir;
|
108
|
-
|
109
|
-
f = fopen((dir + "/envvars").c_str(), "w");
|
110
|
-
if (f != NULL) {
|
111
|
-
int i = 0;
|
112
|
-
while (environ[i] != NULL) {
|
113
|
-
fputs(environ[i], f);
|
114
|
-
putc('\n', f);
|
115
|
-
i++;
|
116
|
-
}
|
117
|
-
fclose(f);
|
118
|
-
}
|
119
|
-
|
120
|
-
f = fopen((dir + "/user_info").c_str(), "w");
|
121
|
-
if (f != NULL) {
|
122
|
-
pid_t pid = fork();
|
123
|
-
if (pid == 0) {
|
124
|
-
dup2(fileno(f), 1);
|
125
|
-
execlp("id", "id", (char *) 0);
|
126
|
-
_exit(1);
|
127
|
-
} else if (pid == -1) {
|
128
|
-
int e = errno;
|
129
|
-
fprintf(stderr, "Error: cannot fork a new process: %s (errno=%d)\n",
|
130
|
-
strerror(e), e);
|
131
|
-
} else {
|
132
|
-
waitpid(pid, NULL, 0);
|
133
|
-
}
|
134
|
-
fclose(f);
|
135
|
-
}
|
136
|
-
|
137
|
-
f = fopen((dir + "/ulimit").c_str(), "w");
|
138
|
-
if (f != NULL) {
|
139
|
-
pid_t pid = fork();
|
140
|
-
if (pid == 0) {
|
141
|
-
dup2(fileno(f), 1);
|
142
|
-
execlp("ulimit", "ulimit", "-a", (char *) 0);
|
143
|
-
_exit(1);
|
144
|
-
} else if (pid == -1) {
|
145
|
-
int e = errno;
|
146
|
-
fprintf(stderr, "Error: cannot fork a new process: %s (errno=%d)\n",
|
147
|
-
strerror(e), e);
|
148
|
-
} else {
|
149
|
-
waitpid(pid, NULL, 0);
|
150
|
-
}
|
151
|
-
fclose(f);
|
152
|
-
}
|
153
|
-
|
154
|
-
SystemMetrics metrics;
|
155
|
-
bool collected = false;
|
156
|
-
try {
|
157
|
-
SystemMetricsCollector collector;
|
158
|
-
collector.collect(metrics);
|
159
|
-
usleep(50000); // Correct collect CPU metrics.
|
160
|
-
collector.collect(metrics);
|
161
|
-
collected = true;
|
162
|
-
} catch (const RuntimeException &e) {
|
163
|
-
fprintf(stderr, "Warning: %s\n", e.what());
|
164
|
-
}
|
165
|
-
if (collected) {
|
166
|
-
f = fopen((dir + "/system_metrics").c_str(), "w");
|
167
|
-
if (f != NULL) {
|
168
|
-
stringstream stream;
|
169
|
-
metrics.toDescription(stream);
|
170
|
-
string info = stream.str();
|
171
|
-
|
172
|
-
fwrite(info.data(), 1, info.size(), f);
|
173
|
-
fclose(f);
|
174
|
-
}
|
175
|
-
}
|
176
|
-
}
|
177
|
-
|
178
|
-
// Usage: PassengerAgent spawn-preparer <working directory> <envvars> <executable> <exec args...>
|
179
|
-
int
|
180
|
-
spawnPreparerMain(int argc, char *argv[]) {
|
181
|
-
#define ARG_OFFSET 1
|
182
|
-
if (argc < ARG_OFFSET + 5) {
|
183
|
-
fprintf(stderr, "Too few arguments.\n");
|
184
|
-
exit(1);
|
185
|
-
}
|
186
|
-
|
187
|
-
const char *workingDir = argv[ARG_OFFSET + 1];
|
188
|
-
const char *envvars = argv[ARG_OFFSET + 2];
|
189
|
-
const char *executable = argv[ARG_OFFSET + 3];
|
190
|
-
char **execArgs = &argv[ARG_OFFSET + 4];
|
191
|
-
|
192
|
-
changeWorkingDir(workingDir);
|
193
|
-
setGivenEnvVars(envvars);
|
194
|
-
dumpInformation();
|
195
|
-
|
196
|
-
// Print a newline just in case whatever executed us printed data
|
197
|
-
// without a newline. Otherwise the next process's "!> I have control"
|
198
|
-
// command will not be properly recognized.
|
199
|
-
// https://code.google.com/p/phusion-passenger/issues/detail?id=842#c16
|
200
|
-
printf("\n");
|
201
|
-
fflush(stdout);
|
202
|
-
|
203
|
-
execvp(executable, (char * const *) execArgs);
|
204
|
-
int e = errno;
|
205
|
-
fprintf(stderr, "*** ERROR ***: Cannot execute %s: %s (%d)\n",
|
206
|
-
executable, strerror(e), e);
|
207
|
-
return 1;
|
208
|
-
}
|