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,62 +0,0 @@
|
|
1
|
-
# Union Station - https://www.unionstationapp.com/
|
2
|
-
# Copyright (c) 2010-2015 Phusion Holding B.V.
|
3
|
-
#
|
4
|
-
# "Union Station" and "Passenger" are trademarks of Phusion Holding B.V.
|
5
|
-
#
|
6
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
-
# of this software and associated documentation files (the "Software"), to deal
|
8
|
-
# in the Software without restriction, including without limitation the rights
|
9
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
-
# copies of the Software, and to permit persons to whom the Software is
|
11
|
-
# furnished to do so, subject to the following conditions:
|
12
|
-
#
|
13
|
-
# The above copyright notice and this permission notice shall be included in
|
14
|
-
# all copies or substantial portions of the Software.
|
15
|
-
#
|
16
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
-
# THE SOFTWARE.
|
23
|
-
|
24
|
-
|
25
|
-
module UnionStationHooks
|
26
|
-
# A wrapper around a mutex, for use within Connection.
|
27
|
-
#
|
28
|
-
# @private
|
29
|
-
class Lock
|
30
|
-
def initialize(mutex)
|
31
|
-
@mutex = mutex
|
32
|
-
@locked = false
|
33
|
-
end
|
34
|
-
|
35
|
-
def reset(mutex, lock_now = true)
|
36
|
-
unlock if @locked
|
37
|
-
@mutex = mutex
|
38
|
-
lock if lock_now
|
39
|
-
end
|
40
|
-
|
41
|
-
def synchronize
|
42
|
-
lock if !@locked
|
43
|
-
begin
|
44
|
-
yield(self)
|
45
|
-
ensure
|
46
|
-
unlock if @locked
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def lock
|
51
|
-
raise if @locked
|
52
|
-
@mutex.lock
|
53
|
-
@locked = true
|
54
|
-
end
|
55
|
-
|
56
|
-
def unlock
|
57
|
-
raise if !@locked
|
58
|
-
@mutex.unlock
|
59
|
-
@locked = false
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,66 +0,0 @@
|
|
1
|
-
# Union Station - https://www.unionstationapp.com/
|
2
|
-
# Copyright (c) 2010-2015 Phusion Holding B.V.
|
3
|
-
#
|
4
|
-
# "Union Station" and "Passenger" are trademarks of Phusion Holding B.V.
|
5
|
-
#
|
6
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
-
# of this software and associated documentation files (the "Software"), to deal
|
8
|
-
# in the Software without restriction, including without limitation the rights
|
9
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
-
# copies of the Software, and to permit persons to whom the Software is
|
11
|
-
# furnished to do so, subject to the following conditions:
|
12
|
-
#
|
13
|
-
# The above copyright notice and this permission notice shall be included in
|
14
|
-
# all copies or substantial portions of the Software.
|
15
|
-
#
|
16
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
-
# THE SOFTWARE.
|
23
|
-
|
24
|
-
|
25
|
-
module UnionStationHooks
|
26
|
-
# Provides methods for `union_station_*` gems to log internal warnings and
|
27
|
-
# debugging messages. This module is *not* to be used by application
|
28
|
-
# developers for the purpose of logging information to Union Station.
|
29
|
-
#
|
30
|
-
# @private
|
31
|
-
module Log
|
32
|
-
@@debugging = false
|
33
|
-
@@warn_callback = nil
|
34
|
-
@@debug_callback = nil
|
35
|
-
|
36
|
-
def self.debugging=(value)
|
37
|
-
@@debugging = value
|
38
|
-
end
|
39
|
-
|
40
|
-
def self.warn(message)
|
41
|
-
if @@warn_callback
|
42
|
-
@@warn_callback.call(message)
|
43
|
-
else
|
44
|
-
STDERR.puts("[UnionStationHooks] #{message}")
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def self.debug(message)
|
49
|
-
if @@debugging
|
50
|
-
if @@debug_callback
|
51
|
-
@@debug_callback.call(message)
|
52
|
-
else
|
53
|
-
STDERR.puts("[UnionStationHooks] #{message}")
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def self.warn_callback=(cb)
|
59
|
-
@@warn_callback = cb
|
60
|
-
end
|
61
|
-
|
62
|
-
def self.debug_callback=(cb)
|
63
|
-
@@debug_callback = cb
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
@@ -1,157 +0,0 @@
|
|
1
|
-
# encoding: binary
|
2
|
-
# Union Station - https://www.unionstationapp.com/
|
3
|
-
# Copyright (c) 2010-2015 Phusion Holding B.V.
|
4
|
-
#
|
5
|
-
# "Union Station" and "Passenger" are trademarks of Phusion Holding B.V.
|
6
|
-
#
|
7
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
-
# of this software and associated documentation files (the "Software"), to deal
|
9
|
-
# in the Software without restriction, including without limitation the rights
|
10
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
-
# copies of the Software, and to permit persons to whom the Software is
|
12
|
-
# furnished to do so, subject to the following conditions:
|
13
|
-
#
|
14
|
-
# The above copyright notice and this permission notice shall be included in
|
15
|
-
# all copies or substantial portions of the Software.
|
16
|
-
#
|
17
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
23
|
-
# THE SOFTWARE.
|
24
|
-
|
25
|
-
|
26
|
-
module UnionStationHooks
|
27
|
-
# This class allows reading and writing structured messages over
|
28
|
-
# I/O channels. This is the Ruby implementation of Passenger's
|
29
|
-
# src/cxx_supportlib/Utils/MessageIO.h; see that file for more information.
|
30
|
-
#
|
31
|
-
# @private
|
32
|
-
class MessageChannel
|
33
|
-
HEADER_SIZE = 2
|
34
|
-
DELIMITER = "\0"
|
35
|
-
DELIMITER_NAME = 'null byte'
|
36
|
-
UINT16_PACK_FORMAT = 'n'
|
37
|
-
UINT32_PACK_FORMAT = 'N'
|
38
|
-
|
39
|
-
class InvalidHashError < StandardError
|
40
|
-
end
|
41
|
-
|
42
|
-
# The wrapped IO object.
|
43
|
-
attr_accessor :io
|
44
|
-
|
45
|
-
# Create a new MessageChannel by wrapping the given IO object.
|
46
|
-
def initialize(io = nil)
|
47
|
-
@io = io
|
48
|
-
# Make it binary just in case.
|
49
|
-
@io.binmode if @io
|
50
|
-
end
|
51
|
-
|
52
|
-
# rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity
|
53
|
-
# rubocop:disable Metrics/PerceivedComplexity, Metrics/AbcSize
|
54
|
-
|
55
|
-
# Read an array message from the underlying file descriptor.
|
56
|
-
# Returns the array message as an array, or nil when end-of-stream has
|
57
|
-
# been reached.
|
58
|
-
#
|
59
|
-
# Might raise SystemCallError, IOError or SocketError when something
|
60
|
-
# goes wrong.
|
61
|
-
def read
|
62
|
-
buffer = new_buffer
|
63
|
-
if !@io.read(HEADER_SIZE, buffer)
|
64
|
-
return nil
|
65
|
-
end
|
66
|
-
while buffer.size < HEADER_SIZE
|
67
|
-
tmp = @io.read(HEADER_SIZE - buffer.size)
|
68
|
-
if tmp.empty?
|
69
|
-
return nil
|
70
|
-
else
|
71
|
-
buffer << tmp
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
chunk_size = buffer.unpack(UINT16_PACK_FORMAT)[0]
|
76
|
-
if !@io.read(chunk_size, buffer)
|
77
|
-
return nil
|
78
|
-
end
|
79
|
-
while buffer.size < chunk_size
|
80
|
-
tmp = @io.read(chunk_size - buffer.size)
|
81
|
-
if tmp.empty?
|
82
|
-
return nil
|
83
|
-
else
|
84
|
-
buffer << tmp
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
message = []
|
89
|
-
offset = 0
|
90
|
-
delimiter_pos = buffer.index(DELIMITER, offset)
|
91
|
-
while !delimiter_pos.nil?
|
92
|
-
if delimiter_pos == 0
|
93
|
-
message << ''
|
94
|
-
else
|
95
|
-
message << buffer[offset..delimiter_pos - 1]
|
96
|
-
end
|
97
|
-
offset = delimiter_pos + 1
|
98
|
-
delimiter_pos = buffer.index(DELIMITER, offset)
|
99
|
-
end
|
100
|
-
message
|
101
|
-
rescue Errno::ECONNRESET
|
102
|
-
nil
|
103
|
-
end
|
104
|
-
|
105
|
-
# rubocop:enable Metrics/MethodLength, Metrics/CyclomaticComplexity
|
106
|
-
# rubocop:enable Metrics/PerceivedComplexity, Metrics/AbcSize
|
107
|
-
|
108
|
-
# Send an array message, which consists of the given elements, over the
|
109
|
-
# underlying file descriptor. _name_ is the first element in the message,
|
110
|
-
# and _args_ are the other elements. These arguments will internally be
|
111
|
-
# converted to strings by calling to_s().
|
112
|
-
#
|
113
|
-
# Might raise SystemCallError, IOError or SocketError when something
|
114
|
-
# goes wrong.
|
115
|
-
def write(name, *args)
|
116
|
-
check_argument(name)
|
117
|
-
args.each do |arg|
|
118
|
-
check_argument(arg)
|
119
|
-
end
|
120
|
-
|
121
|
-
message = "#{name}#{DELIMITER}"
|
122
|
-
args.each do |arg|
|
123
|
-
message << arg.to_s << DELIMITER
|
124
|
-
end
|
125
|
-
@io.write([message.size].pack('n') << message)
|
126
|
-
@io.flush
|
127
|
-
end
|
128
|
-
|
129
|
-
# Send a scalar message over the underlying IO object.
|
130
|
-
#
|
131
|
-
# Might raise SystemCallError, IOError or SocketError when something
|
132
|
-
# goes wrong.
|
133
|
-
def write_scalar(data)
|
134
|
-
@io.write([data.size].pack('N') << data)
|
135
|
-
@io.flush
|
136
|
-
end
|
137
|
-
|
138
|
-
private
|
139
|
-
|
140
|
-
def check_argument(arg)
|
141
|
-
if arg.to_s.index(DELIMITER)
|
142
|
-
raise ArgumentError,
|
143
|
-
"Message name and arguments may not contain #{DELIMITER_NAME}"
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
if defined?(ByteString)
|
148
|
-
def new_buffer
|
149
|
-
ByteString.new
|
150
|
-
end
|
151
|
-
else
|
152
|
-
def new_buffer
|
153
|
-
''
|
154
|
-
end
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end # module UnionStationHooks
|
@@ -1,150 +0,0 @@
|
|
1
|
-
# Union Station - https://www.unionstationapp.com/
|
2
|
-
# Copyright (c) 2010-2015 Phusion Holding B.V.
|
3
|
-
#
|
4
|
-
# "Union Station" and "Passenger" are trademarks of Phusion Holding B.V.
|
5
|
-
#
|
6
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
-
# of this software and associated documentation files (the "Software"), to deal
|
8
|
-
# in the Software without restriction, including without limitation the rights
|
9
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
-
# copies of the Software, and to permit persons to whom the Software is
|
11
|
-
# furnished to do so, subject to the following conditions:
|
12
|
-
#
|
13
|
-
# The above copyright notice and this permission notice shall be included in
|
14
|
-
# all copies or substantial portions of the Software.
|
15
|
-
#
|
16
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
-
# THE SOFTWARE.
|
23
|
-
|
24
|
-
UnionStationHooks.require_lib 'request_reporter/basics'
|
25
|
-
UnionStationHooks.require_lib 'request_reporter/controllers'
|
26
|
-
UnionStationHooks.require_lib 'request_reporter/view_rendering'
|
27
|
-
UnionStationHooks.require_lib 'request_reporter/misc'
|
28
|
-
|
29
|
-
module UnionStationHooks
|
30
|
-
# A RequestReporter object is used for logging request-specific information
|
31
|
-
# to Union Station. "Information" may include (and are not limited to):
|
32
|
-
#
|
33
|
-
# * Web framework controller and action name.
|
34
|
-
# * Exceptions raised during the request.
|
35
|
-
# * Cache hits and misses.
|
36
|
-
# * Database actions.
|
37
|
-
#
|
38
|
-
# A unique RequestReporter is created by Passenger at the beginning of every
|
39
|
-
# request (by calling {UnionStationHooks.begin_rack_request}). This object is
|
40
|
-
# closed at the end of the same request (after the Rack body object is
|
41
|
-
# closed).
|
42
|
-
#
|
43
|
-
# As an application developer, the RequestReporter is the main class
|
44
|
-
# that you will be interfacing with. See the {UnionStationHooks} module
|
45
|
-
# description for an example of how you can use RequestReporter.
|
46
|
-
#
|
47
|
-
# ## Obtaining a RequestReporter
|
48
|
-
#
|
49
|
-
# You are not supposed to create a RequestReporter object directly.
|
50
|
-
# You are supposed to obtain the RequestReporter object that Passenger creates
|
51
|
-
# for you. This is done through the `union_station_hooks` key in the Rack
|
52
|
-
# environment hash, as well as through the `:union_station_hooks` key in
|
53
|
-
# the current thread's object:
|
54
|
-
#
|
55
|
-
# env['union_station_hooks']
|
56
|
-
# # => RequestReporter object or nil
|
57
|
-
#
|
58
|
-
# Thread.current[:union_station_hooks]
|
59
|
-
# # => RequestReporter object or nil
|
60
|
-
#
|
61
|
-
# Note that Passenger may not have created such an object because of an
|
62
|
-
# error. At present, there are two error conditions that would cause a
|
63
|
-
# RequestReporter object not to be created. However, your code should take
|
64
|
-
# into account that in the future more error conditions may trigger this.
|
65
|
-
#
|
66
|
-
# 1. There is no transaction ID associated with the current request.
|
67
|
-
# When Union Station support is enabled in Passenger, Passenger always
|
68
|
-
# assigns a transaction ID. However, administrators can also
|
69
|
-
# {https://www.phusionpassenger.com/library/admin/nginx/request_individual_processes.html
|
70
|
-
# access Ruby processes directly} through process-private HTTP sockets,
|
71
|
-
# bypassing Passenger's load balancing mechanism. In that case, no
|
72
|
-
# transaction ID will be assigned.
|
73
|
-
# 2. An error occurred recently while sending data to the UstRouter, either
|
74
|
-
# because the UstRouter crashed or because of some other kind of
|
75
|
-
# communication error occurred. This error condition isn't cleared until
|
76
|
-
# certain a timeout has passed.
|
77
|
-
#
|
78
|
-
# The UstRouter is a Passenger process which runs locally and is
|
79
|
-
# responsible for aggregating Union Station log data from multiple
|
80
|
-
# processes, with the goal of sending the aggregate data over the network
|
81
|
-
# to the Union Station service.
|
82
|
-
#
|
83
|
-
# This kind of error is automatically recovered from after a certain
|
84
|
-
# period of time.
|
85
|
-
#
|
86
|
-
# ## Null mode
|
87
|
-
#
|
88
|
-
# The error condition 2 described above may also cause an existing
|
89
|
-
# RequestReporter object to enter the "null mode". When this mode is entered,
|
90
|
-
# any further actions on the RequestReporter object will become no-ops.
|
91
|
-
# You can check whether the null mode is active by calling {#null?}.
|
92
|
-
#
|
93
|
-
# Closing a RequestReporter also causes it to enter the null mode.
|
94
|
-
#
|
95
|
-
# ## Thread-safety
|
96
|
-
#
|
97
|
-
# RequestReporter is *not* thread-safe. If you access it concurrently, be sure
|
98
|
-
# to wrap its operations in a mutex.
|
99
|
-
class RequestReporter
|
100
|
-
# Returns a new RequestReporter object. You should not call
|
101
|
-
# `RequestReporter.new` directly. See "Obtaining a RequestReporter"
|
102
|
-
# in the {RequestReporter class description}.
|
103
|
-
#
|
104
|
-
# @api private
|
105
|
-
def initialize(context, txn_id, app_group_name, key)
|
106
|
-
raise ArgumentError, 'Transaction ID must be given' if txn_id.nil?
|
107
|
-
raise ArgumentError, 'App group name must be given' if app_group_name.nil?
|
108
|
-
raise ArgumentError, 'Union Station key must be given' if key.nil?
|
109
|
-
@context = context
|
110
|
-
@txn_id = txn_id
|
111
|
-
@app_group_name = app_group_name
|
112
|
-
@key = key
|
113
|
-
@transaction = continue_transaction
|
114
|
-
@next_view_rendering_number = 1
|
115
|
-
@next_user_activity_number = 1
|
116
|
-
@next_benchmark_number = 1
|
117
|
-
@next_database_query_number = 1
|
118
|
-
end
|
119
|
-
|
120
|
-
# Indicates that no further information will be logged for this
|
121
|
-
# request.
|
122
|
-
#
|
123
|
-
# @api private
|
124
|
-
def close
|
125
|
-
@transaction.close
|
126
|
-
end
|
127
|
-
|
128
|
-
# Returns whether is this RequestReporter object is in null mode.
|
129
|
-
# See the {RequestReporter class description} for more information.
|
130
|
-
def null?
|
131
|
-
@transaction.null?
|
132
|
-
end
|
133
|
-
|
134
|
-
# Other methods are implemented in the files in the
|
135
|
-
# 'request_reporter/' subdirectory.
|
136
|
-
|
137
|
-
private
|
138
|
-
|
139
|
-
def continue_transaction
|
140
|
-
@context.continue_transaction(@txn_id, @app_group_name,
|
141
|
-
:requests, @key)
|
142
|
-
end
|
143
|
-
|
144
|
-
# Called when one of the methods return early upon detecting null
|
145
|
-
# mode. Used by tests to verify that methods return early.
|
146
|
-
def do_nothing_on_null(_source)
|
147
|
-
# Do nothing by default. Tests will stub this.
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
@@ -1,199 +0,0 @@
|
|
1
|
-
# Union Station - https://www.unionstationapp.com/
|
2
|
-
# Copyright (c) 2010-2015 Phusion Holding B.V.
|
3
|
-
#
|
4
|
-
# "Union Station" and "Passenger" are trademarks of Phusion Holding B.V.
|
5
|
-
#
|
6
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
-
# of this software and associated documentation files (the "Software"), to deal
|
8
|
-
# in the Software without restriction, including without limitation the rights
|
9
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
-
# copies of the Software, and to permit persons to whom the Software is
|
11
|
-
# furnished to do so, subject to the following conditions:
|
12
|
-
#
|
13
|
-
# The above copyright notice and this permission notice shall be included in
|
14
|
-
# all copies or substantial portions of the Software.
|
15
|
-
#
|
16
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
-
# THE SOFTWARE.
|
23
|
-
|
24
|
-
require 'thread'
|
25
|
-
|
26
|
-
module UnionStationHooks
|
27
|
-
class RequestReporter
|
28
|
-
###### Logging basic request information ######
|
29
|
-
|
30
|
-
# A mutex for synchronizing GC stats reporting. We do this because in
|
31
|
-
# multithreaded situations we don't want to interleave GC stats access with
|
32
|
-
# calls to `GC.clear_stats`. Not that GC stats are very helpful in
|
33
|
-
# multithreaded situations, but this is better than nothing.
|
34
|
-
#
|
35
|
-
# @private
|
36
|
-
GC_MUTEX = Mutex.new
|
37
|
-
|
38
|
-
# @private
|
39
|
-
OBJECT_SPACE_SUPPORTS_LIVE_OBJECTS = ObjectSpace.respond_to?(:live_objects)
|
40
|
-
|
41
|
-
# @private
|
42
|
-
OBJECT_SPACE_SUPPORTS_ALLOCATED_OBJECTS =
|
43
|
-
ObjectSpace.respond_to?(:allocated_objects)
|
44
|
-
|
45
|
-
# @private
|
46
|
-
OBJECT_SPACE_SUPPORTS_COUNT_OBJECTS =
|
47
|
-
ObjectSpace.respond_to?(:count_objects)
|
48
|
-
|
49
|
-
# @private
|
50
|
-
GC_SUPPORTS_TIME = GC.respond_to?(:time)
|
51
|
-
|
52
|
-
# @private
|
53
|
-
GC_SUPPORTS_CLEAR_STATS = GC.respond_to?(:clear_stats)
|
54
|
-
|
55
|
-
# Logs the beginning of a Rack request. This is automatically called
|
56
|
-
# from {UnionStationHooks.begin_rack_request} (and thus automatically
|
57
|
-
# from Passenger).
|
58
|
-
#
|
59
|
-
# @private
|
60
|
-
def log_request_begin
|
61
|
-
return do_nothing_on_null(:log_request_begin) if null?
|
62
|
-
@transaction.log_activity_begin('app request handler processing')
|
63
|
-
end
|
64
|
-
|
65
|
-
# Logs the end of a Rack request. This means that the Rack response body
|
66
|
-
# has been written out, and that the `#close` has been called on the Rack
|
67
|
-
# response body.
|
68
|
-
#
|
69
|
-
# This does not necessarily indicate that any buffering mechanism in
|
70
|
-
# between the app and the client (e.g. Nginx, or the Passenger core) is
|
71
|
-
# done flushing the response to the client.
|
72
|
-
#
|
73
|
-
# This is automatically called from {UnionStationHooks.begin_rack_request}
|
74
|
-
# (and thus automatically from Passenger).
|
75
|
-
#
|
76
|
-
# @private
|
77
|
-
def log_request_end(uncaught_exception_raised_during_request = false)
|
78
|
-
return do_nothing_on_null(:log_request_end) if null?
|
79
|
-
@transaction.log_activity_end('app request handler processing',
|
80
|
-
UnionStationHooks.now, uncaught_exception_raised_during_request)
|
81
|
-
end
|
82
|
-
|
83
|
-
# rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
84
|
-
|
85
|
-
# @private
|
86
|
-
def log_gc_stats_on_request_begin
|
87
|
-
return do_nothing_on_null(:log_gc_stats_on_request_begin) if null?
|
88
|
-
|
89
|
-
# See the docs for MUTEX on why we synchronize this.
|
90
|
-
GC_MUTEX.synchronize do
|
91
|
-
if OBJECT_SPACE_SUPPORTS_LIVE_OBJECTS
|
92
|
-
@transaction.message('Initial objects on heap: ' \
|
93
|
-
"#{ObjectSpace.live_objects}")
|
94
|
-
end
|
95
|
-
if OBJECT_SPACE_SUPPORTS_ALLOCATED_OBJECTS
|
96
|
-
@transaction.message('Initial objects allocated so far: ' \
|
97
|
-
"#{ObjectSpace.allocated_objects}")
|
98
|
-
elsif OBJECT_SPACE_SUPPORTS_COUNT_OBJECTS
|
99
|
-
count = ObjectSpace.count_objects
|
100
|
-
@transaction.message('Initial objects allocated so far: ' \
|
101
|
-
"#{count[:TOTAL] - count[:FREE]}")
|
102
|
-
end
|
103
|
-
if GC_SUPPORTS_TIME
|
104
|
-
@transaction.message("Initial GC time: #{GC.time}")
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
# @private
|
110
|
-
def log_gc_stats_on_request_end
|
111
|
-
return do_nothing_on_null(:log_gc_stats_on_request_end) if null?
|
112
|
-
|
113
|
-
# See the docs for MUTEX on why we synchronize this.
|
114
|
-
GC_MUTEX.synchronize do
|
115
|
-
if OBJECT_SPACE_SUPPORTS_LIVE_OBJECTS
|
116
|
-
@transaction.message('Final objects on heap: ' \
|
117
|
-
"#{ObjectSpace.live_objects}")
|
118
|
-
end
|
119
|
-
if OBJECT_SPACE_SUPPORTS_ALLOCATED_OBJECTS
|
120
|
-
@transaction.message('Final objects allocated so far: ' \
|
121
|
-
"#{ObjectSpace.allocated_objects}")
|
122
|
-
elsif OBJECT_SPACE_SUPPORTS_COUNT_OBJECTS
|
123
|
-
count = ObjectSpace.count_objects
|
124
|
-
@transaction.message('Final objects allocated so far: ' \
|
125
|
-
"#{count[:TOTAL] - count[:FREE]}")
|
126
|
-
end
|
127
|
-
if GC_SUPPORTS_TIME
|
128
|
-
@transaction.message("Final GC time: #{GC.time}")
|
129
|
-
end
|
130
|
-
if GC_SUPPORTS_CLEAR_STATS
|
131
|
-
# Clear statistics to void integer wraps.
|
132
|
-
GC.clear_stats
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
# rubocop:enable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
138
|
-
|
139
|
-
# Logs that the application server is about to write out the Rack
|
140
|
-
# response body.
|
141
|
-
#
|
142
|
-
# This call *must* be followed by a call to {#log_writing_rack_body_end}
|
143
|
-
# some time later.
|
144
|
-
#
|
145
|
-
# This is automatically called by Passenger's Rack handler.
|
146
|
-
#
|
147
|
-
# @private
|
148
|
-
# @return An ID to be passed later to {#log_writing_rack_body_end}, or nil
|
149
|
-
# on error.
|
150
|
-
def log_writing_rack_body_begin
|
151
|
-
return do_nothing_on_null(:log_writing_rack_body_begin) if null?
|
152
|
-
@transaction.log_activity_begin('app writing out response body')
|
153
|
-
:writing_rack_body # Random non-nil ID
|
154
|
-
end
|
155
|
-
|
156
|
-
# Logs that the application server is done writing out the Rack
|
157
|
-
# response body. This does not necessarily indicate that any buffering
|
158
|
-
# mechanism in between the app and the client (e.g. Nginx, or the Passenger
|
159
|
-
# core) is done flushing the response to the client.
|
160
|
-
#
|
161
|
-
# This is automatically called by Passenger's Rack handler.
|
162
|
-
#
|
163
|
-
# @private
|
164
|
-
def log_writing_rack_body_end(id)
|
165
|
-
return do_nothing_on_null(:log_writing_rack_body_end) if null?
|
166
|
-
return if id.nil?
|
167
|
-
@transaction.log_activity_end('app writing out response body')
|
168
|
-
end
|
169
|
-
|
170
|
-
# Logs that the application server is about to call `#close` on the
|
171
|
-
# Rack body object.
|
172
|
-
#
|
173
|
-
# This call *must* be followed by a call to {#log_closing_rack_body_end}
|
174
|
-
# some time later.
|
175
|
-
#
|
176
|
-
# This is automatically called by Passenger's Rack handler.
|
177
|
-
#
|
178
|
-
# @private
|
179
|
-
# @return An ID to be passed later to {#log_closing_rack_body_end}, or nil
|
180
|
-
# on error.
|
181
|
-
def log_closing_rack_body_begin
|
182
|
-
return do_nothing_on_null(:log_closing_rack_body_begin) if null?
|
183
|
-
@transaction.log_activity_begin('closing rack body object')
|
184
|
-
:closing_rack_body # Random non-nil ID
|
185
|
-
end
|
186
|
-
|
187
|
-
# Logs that the application server is done calling `#close` on the
|
188
|
-
# Rack body object.
|
189
|
-
#
|
190
|
-
# This is automatically called by Passenger's Rack handler.
|
191
|
-
#
|
192
|
-
# @private
|
193
|
-
def log_closing_rack_body_end(id)
|
194
|
-
return do_nothing_on_null(:log_closing_rack_body_end) if null?
|
195
|
-
return if id.nil?
|
196
|
-
@transaction.log_activity_end('closing rack body object')
|
197
|
-
end
|
198
|
-
end
|
199
|
-
end
|