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,17 +0,0 @@
|
|
1
|
-
source 'https://rubygems.org/'
|
2
|
-
|
3
|
-
gem 'rake'
|
4
|
-
gem 'rspec'
|
5
|
-
gem 'timecop'
|
6
|
-
|
7
|
-
gem 'simplecov', :require => false
|
8
|
-
gem 'rubocop', :groups => [:notravis]
|
9
|
-
|
10
|
-
group :doc, :notravis do
|
11
|
-
gem 'yard'
|
12
|
-
gem 'redcarpet'
|
13
|
-
end
|
14
|
-
|
15
|
-
group :travis do
|
16
|
-
gem 'rack'
|
17
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: https://rubygems.org/
|
3
|
-
specs:
|
4
|
-
ast (2.1.0)
|
5
|
-
astrolabe (1.3.1)
|
6
|
-
parser (~> 2.2)
|
7
|
-
diff-lcs (1.2.5)
|
8
|
-
docile (1.1.3)
|
9
|
-
multi_json (1.11.2)
|
10
|
-
parser (2.2.2.6)
|
11
|
-
ast (>= 1.1, < 3.0)
|
12
|
-
powerpack (0.1.1)
|
13
|
-
rack (1.6.4)
|
14
|
-
rainbow (2.0.0)
|
15
|
-
rake (10.4.2)
|
16
|
-
redcarpet (3.2.2)
|
17
|
-
rspec (3.3.0)
|
18
|
-
rspec-core (~> 3.3.0)
|
19
|
-
rspec-expectations (~> 3.3.0)
|
20
|
-
rspec-mocks (~> 3.3.0)
|
21
|
-
rspec-core (3.3.2)
|
22
|
-
rspec-support (~> 3.3.0)
|
23
|
-
rspec-expectations (3.3.1)
|
24
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
25
|
-
rspec-support (~> 3.3.0)
|
26
|
-
rspec-mocks (3.3.2)
|
27
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
28
|
-
rspec-support (~> 3.3.0)
|
29
|
-
rspec-support (3.3.0)
|
30
|
-
rubocop (0.33.0)
|
31
|
-
astrolabe (~> 1.3)
|
32
|
-
parser (>= 2.2.2.5, < 3.0)
|
33
|
-
powerpack (~> 0.1)
|
34
|
-
rainbow (>= 1.99.1, < 3.0)
|
35
|
-
ruby-progressbar (~> 1.4)
|
36
|
-
ruby-progressbar (1.7.5)
|
37
|
-
simplecov (0.8.2)
|
38
|
-
docile (~> 1.1.0)
|
39
|
-
multi_json
|
40
|
-
simplecov-html (~> 0.8.0)
|
41
|
-
simplecov-html (0.8.0)
|
42
|
-
timecop (0.5.3)
|
43
|
-
yard (0.8.7.6)
|
44
|
-
|
45
|
-
PLATFORMS
|
46
|
-
ruby
|
47
|
-
|
48
|
-
DEPENDENCIES
|
49
|
-
rack
|
50
|
-
rake
|
51
|
-
redcarpet
|
52
|
-
rspec
|
53
|
-
rubocop
|
54
|
-
simplecov
|
55
|
-
timecop
|
56
|
-
yard
|
57
|
-
|
58
|
-
BUNDLED WITH
|
59
|
-
1.10.6
|
@@ -1,5 +0,0 @@
|
|
1
|
-
# union_station_hooks_core: public API
|
2
|
-
|
3
|
-
Welcome to the `union_station_hooks_core` API documentation. Please visit the {UnionStationHooks} module description to begin. That module is the entry point to the API.
|
4
|
-
|
5
|
-
**Not familiar with `union_station_hooks_core`? Please read the [README](https://github.com/phusion/union_station_hooks_core) for an introduction.**
|
@@ -1,117 +0,0 @@
|
|
1
|
-
# Union Station Ruby hooks core
|
2
|
-
|
3
|
-
[![Build Status](https://travis-ci.org/phusion/union_station_hooks_core.svg?branch=master)](https://travis-ci.org/phusion/union_station_hooks_core)
|
4
|
-
|
5
|
-
[Union Station](https://www.unionstationapp.com) is a web application monitoring and performance analytics platform for Ruby. In order for Union Station to analyze your application, your application must send data to Union Station. This gem allows you to do that.
|
6
|
-
|
7
|
-
`union_station_hooks_core` is a web-framework-agnostic gem that **hooks into various Ruby internals** in order to send generic Ruby application analytics information to Union Station. Not all information can be automatically inferred by hooking into the Ruby internals, so this gem also provides an **API** that you can call at key places in the codebase to supply the right information.
|
8
|
-
|
9
|
-
### Using Ruby on Rails?
|
10
|
-
|
11
|
-
If your application is a Rails application, then you should use the [union_station_hooks_rails](https://github.com/phusion/union_station_hooks_rails) gem instead of this gem. `union_station_hooks_rails` automatically hooks into Rails to send the right information to Union Station, so that you don't have to call any APIs. Under the hood, `union_station_hooks_rails` makes use of the `union_station_hooks_core` API.
|
12
|
-
|
13
|
-
**Resources:** [About Union Station](https://www.unionstationapp.com) | [Github](https://github.com/phusion/union_station_hooks_core) | [API docs](http://www.rubydoc.info/github/phusion/union_station_hooks_core/UnionStationHooks)
|
14
|
-
|
15
|
-
**Table of contents**
|
16
|
-
|
17
|
-
* [Installation](#installation)
|
18
|
-
- [Using with Passenger](#using-with-passenger)
|
19
|
-
- [Overriding Passenger's version](#overriding-passengers-version)
|
20
|
-
- [Using without Passenger](#using-without-passenger)
|
21
|
-
* [API](#api)
|
22
|
-
* [Legacy code](#legacy-code)
|
23
|
-
* [Contributing](contributing)
|
24
|
-
|
25
|
-
---
|
26
|
-
|
27
|
-
## Installation
|
28
|
-
|
29
|
-
### Using with Passenger
|
30
|
-
|
31
|
-
**Note: This documentation section only applies to Passenger 5.0.20 or later!**
|
32
|
-
|
33
|
-
If you use [Passenger](https://www.phusionpassenger.com/), then you do not need to install the `union_station_hooks_core` gem. `union_station_hooks_core` is bundled with Passenger.
|
34
|
-
|
35
|
-
The only thing you need to do is to ensure that the code is called during application startup:
|
36
|
-
|
37
|
-
if defined?(UnionStationHooks)
|
38
|
-
UnionStationHooks.initialize!
|
39
|
-
end
|
40
|
-
|
41
|
-
(Are you already calling `PhusionPassenger.install_framework_extensions!` from somewhere in your codebase? Please read [Legacy code](#legacy-code) for important information.)
|
42
|
-
|
43
|
-
A good place to call this is in your Rackup file, `config.ru`. Or if you are using Rails, you should create a file `config/initializers/union_station.rb` in which you call this.
|
44
|
-
|
45
|
-
When you have this call in place, enable Union Station support in Passenger. Here are some examples:
|
46
|
-
|
47
|
-
* _Passenger with Nginx integration mode_<br>
|
48
|
-
|
49
|
-
Insert the following config in your virtual host configuration, then restart Nginx:
|
50
|
-
|
51
|
-
union_station_support on;
|
52
|
-
union_station_key <YOUR KEY HERE>;
|
53
|
-
|
54
|
-
* _Passenger with Apache integration mode_<br>
|
55
|
-
|
56
|
-
Insert the following config in your virtual host configuration, then restart Apache:
|
57
|
-
|
58
|
-
UnionStationSupport on
|
59
|
-
UnionStationKey <YOUR KEY HERE>
|
60
|
-
|
61
|
-
* _Passenger Standalone_<br>
|
62
|
-
|
63
|
-
Start Passenger with the `--union-station-key` parameter:
|
64
|
-
|
65
|
-
$ passenger start --union-station-key <YOUR KEY HERE>
|
66
|
-
|
67
|
-
Or set the `union_station_key` configuration option in Passengerfile.json:
|
68
|
-
|
69
|
-
{
|
70
|
-
"union_station_key": "<YOUR KEY HERE>"
|
71
|
-
}
|
72
|
-
|
73
|
-
### Overriding Passenger's version
|
74
|
-
|
75
|
-
**_Note: Are you using `union_station_hooks_rails`? Read [these instructions](https://github.com/phusion/union_station_hooks_rails#overriding-passengers-version) instead._**
|
76
|
-
|
77
|
-
Each version of Passenger bundles its own version of the `union_station_hooks_core` gem. The Passenger maintainers regularly update their bundled version with the latest version. Sometimes, you may wish to use a specific version of `union_station_hooks_core`, overriding the version that came bundled with Passenger. For example, we have may published a new version of `union_station_hooks_core` with some bug fixes, even though Passenger hasn't been updated yet.
|
78
|
-
|
79
|
-
You can override Passenger's bundled version as follows.
|
80
|
-
|
81
|
-
1. Add `union_station_hooks_core` to your Gemfile, like this:
|
82
|
-
|
83
|
-
gem 'union_station_hooks_core'
|
84
|
-
|
85
|
-
2. Install your gem bundle:
|
86
|
-
|
87
|
-
bundle install
|
88
|
-
|
89
|
-
3. Ensure that your application calls `require 'union_station_hooks_core'` during startup, before you access anything in the `UnionStationHooks` module (so before the `UnionStationHooks.initialize!` call).
|
90
|
-
|
91
|
-
If you are using Rails, then Rails takes care of that automatically by calling `Bundler.require` in `config/application.rb`, so in that case you don't need to follow this step.
|
92
|
-
|
93
|
-
### Using without Passenger
|
94
|
-
|
95
|
-
It is currently not possible to use Union Station without Passenger. If you would like to have this feature, please let us know.
|
96
|
-
|
97
|
-
## API
|
98
|
-
|
99
|
-
Please refer to [the API documentation website](http://www.rubydoc.info/github/phusion/union_station_hooks_core/UnionStationHooks).
|
100
|
-
|
101
|
-
## Legacy code
|
102
|
-
|
103
|
-
Before Passenger 5.0.20, the Union Station setup instructions used to tell you to create a `config/initializers/passenger.rb` in which you call the following code:
|
104
|
-
|
105
|
-
PhusionPassenger.install_framework_extensions! if defined?(PhusionPassenger)
|
106
|
-
|
107
|
-
Since Passenger 5.0.20, `PhusionPassenger.install_framework_extensions!` has become an alias for `UnionStationHooks.initialize!`, but the former is considered deprecated. Please replace the above code with:
|
108
|
-
|
109
|
-
if defined?(UnionStationHooks)
|
110
|
-
UnionStationHooks.initialize!
|
111
|
-
end
|
112
|
-
|
113
|
-
And please also rename `config/initializers/passenger.rb` to `config/initializers/union_station.rb`.
|
114
|
-
|
115
|
-
## Contributing
|
116
|
-
|
117
|
-
Looking to contribute to this gem? Please read the documentation in the [hacking/](https://github.com/phusion/union_station_hooks_core/blob/master/hacking) directory.
|
@@ -1,115 +0,0 @@
|
|
1
|
-
# Union Station - https://www.unionstationapp.com/
|
2
|
-
# Copyright (c) 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 'shellwords'
|
25
|
-
|
26
|
-
TRAVIS_PASSENGER_BRANCH = 'master'
|
27
|
-
|
28
|
-
desc 'Run tests'
|
29
|
-
task :spec do
|
30
|
-
pattern = ENV['E']
|
31
|
-
if pattern
|
32
|
-
args = "-e #{Shellwords.escape(pattern)}"
|
33
|
-
end
|
34
|
-
sh 'rm -rf coverage'
|
35
|
-
sh "bundle exec rspec -c -f d spec/*_spec.rb #{args}"
|
36
|
-
end
|
37
|
-
|
38
|
-
task :test => :spec
|
39
|
-
|
40
|
-
desc 'Run tests in Travis'
|
41
|
-
task "spec:travis" do
|
42
|
-
if !ENV['PASSENGER_CONFIG']
|
43
|
-
Rake::Task['travis:install_passenger'].invoke
|
44
|
-
end
|
45
|
-
if ENV['TRAVIS_WITH_SUDO']
|
46
|
-
sh 'cp ruby_versions.yml.travis-with-sudo ruby_versions.yml'
|
47
|
-
else
|
48
|
-
sh 'cp ruby_versions.yml.travis ruby_versions.yml'
|
49
|
-
end
|
50
|
-
Rake::Task['spec'].invoke
|
51
|
-
end
|
52
|
-
|
53
|
-
desc 'Build gem'
|
54
|
-
task :gem do
|
55
|
-
sh 'gem build union_station_hooks_core.gemspec'
|
56
|
-
end
|
57
|
-
|
58
|
-
desc 'Check coding style'
|
59
|
-
task :rubocop do
|
60
|
-
sh 'bundle exec rubocop -D lib'
|
61
|
-
end
|
62
|
-
|
63
|
-
desc 'Generate API documentation'
|
64
|
-
task :doc do
|
65
|
-
sh 'rm -rf doc'
|
66
|
-
sh 'bundle exec yard'
|
67
|
-
end
|
68
|
-
|
69
|
-
namespace :travis do
|
70
|
-
task :install_passenger do
|
71
|
-
if File.exist?('../../../../../bin/passenger-config')
|
72
|
-
# We are vendored into Passenger
|
73
|
-
Rake::Task['travis:install_passenger_vendor'].invoke
|
74
|
-
else
|
75
|
-
Rake::Task['travis:install_passenger_git'].invoke
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
task :install_passenger_vendor do
|
80
|
-
passenger_config = File.expand_path('../../../../../bin/passenger-config')
|
81
|
-
ENV['PASSENGER_CONFIG'] = passenger_config
|
82
|
-
sh "#{passenger_config} install-agent --auto"
|
83
|
-
end
|
84
|
-
|
85
|
-
task :install_passenger_git do
|
86
|
-
if !File.exist?('passenger/.git')
|
87
|
-
sh "git clone --recursive --branch #{TRAVIS_PASSENGER_BRANCH} git://github.com/phusion/passenger.git"
|
88
|
-
else
|
89
|
-
puts 'cd passenger'
|
90
|
-
Dir.chdir('passenger') do
|
91
|
-
sh 'git fetch'
|
92
|
-
sh 'rake clean'
|
93
|
-
sh "git reset --hard origin/#{TRAVIS_PASSENGER_BRANCH}"
|
94
|
-
sh 'git submodule update --init --recursive'
|
95
|
-
end
|
96
|
-
puts 'cd ..'
|
97
|
-
end
|
98
|
-
|
99
|
-
passenger_config = "#{Dir.pwd}/passenger/bin/passenger-config"
|
100
|
-
envs = {
|
101
|
-
'PASSENGER_CONFIG' => passenger_config,
|
102
|
-
'CC' => 'ccache cc',
|
103
|
-
'CXX' => 'ccache c++',
|
104
|
-
'CCACHE_COMPRESS' => '1',
|
105
|
-
'CCACHE_COMPRESS_LEVEL' => '3',
|
106
|
-
'CCACHE_DIR' => "#{Dir.pwd}/passenger/.ccache"
|
107
|
-
}
|
108
|
-
envs.each_pair do |key, val|
|
109
|
-
ENV[key] = val
|
110
|
-
puts "$ export #{key}='#{val}'"
|
111
|
-
end
|
112
|
-
sh 'mkdir -p passenger/.ccache'
|
113
|
-
sh "#{passenger_config} install-agent --auto"
|
114
|
-
end
|
115
|
-
end
|
@@ -1,423 +0,0 @@
|
|
1
|
-
# Union Station - https://www.unionstationapp.com/
|
2
|
-
# Copyright (c) 2015-2016 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
|
-
if defined?(UnionStationHooks::VERSION_STRING)
|
25
|
-
if UnionStationHooks.initialized?
|
26
|
-
raise 'Attempted to load union_station_hooks_core even though an ' \
|
27
|
-
'alternative version was already loaded and initialized'
|
28
|
-
end
|
29
|
-
if UnionStationHooks.vendored?
|
30
|
-
# Passenger loaded its vendored Union Station hooks code, but the
|
31
|
-
# application has also included 'union_station_hooks_*' in its Gemfile. We
|
32
|
-
# want the version in the Gemfile to take precedence, so we unload the old
|
33
|
-
# version. At this point, the Union Station hooks aren't installed yet, so
|
34
|
-
# removing the module is enough to unload the old version.
|
35
|
-
#
|
36
|
-
# See also hacking/Vendoring.md
|
37
|
-
config_from_vendored_ush = UnionStationHooks.config
|
38
|
-
initializers_from_vendored_ush = UnionStationHooks.initializers
|
39
|
-
Object.send(:remove_const, :UnionStationHooks)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
# The UnionStationHooks module is the entry point to the
|
44
|
-
# `union_station_hooks_core` gem's public API. Note that this API is only
|
45
|
-
# available since Passenger 5.0.20!
|
46
|
-
#
|
47
|
-
# **_Not familiar with `union_station_hooks_core`? Please read the
|
48
|
-
# [README](https://github.com/phusion/union_station_hooks_core)
|
49
|
-
# for an introduction._**
|
50
|
-
#
|
51
|
-
# ## Places of interest
|
52
|
-
#
|
53
|
-
# You will probably be most interested in these:
|
54
|
-
#
|
55
|
-
# * {UnionStationHooks.initialize!}
|
56
|
-
# * {UnionStationHooks.begin_rack_request} and
|
57
|
-
# {UnionStationHooks.end_rack_request}
|
58
|
-
# * {UnionStationHooks::RequestReporter}
|
59
|
-
# * {UnionStationHooks.log_exception}
|
60
|
-
#
|
61
|
-
# ## Rack example
|
62
|
-
#
|
63
|
-
# Here is a small example showing to use `union_station_hooks_core` with a
|
64
|
-
# bare Rack application. There are three main things you see in this example:
|
65
|
-
#
|
66
|
-
# 1. The `union_station_hooks_*` gems are initialized.
|
67
|
-
# 2. Obtaining a RequestReporter object, which is the main object that you
|
68
|
-
# will be using as an application developer to log information to Union
|
69
|
-
# Station.
|
70
|
-
# 3. Using the RequestReporter object by calling methods on it.
|
71
|
-
#
|
72
|
-
# Example code follows:
|
73
|
-
#
|
74
|
-
# # (1) Initialize all `union_station_hooks_*` gems.
|
75
|
-
# UnionStationHooks.initialize!
|
76
|
-
#
|
77
|
-
# # Define application object.
|
78
|
-
# app = lambda do |env|
|
79
|
-
# body, rendering_time = process_this_request(env)
|
80
|
-
#
|
81
|
-
# # (2) You can obtain a RequestReporter object as follows. With that
|
82
|
-
# # object, you can log to Union Station information about the current
|
83
|
-
# # request.
|
84
|
-
# reporter = env['union_station_hooks']
|
85
|
-
# # -OR- (if you don't have access to the Rack env):
|
86
|
-
# reporter = Thread.current[:union_station_hooks]
|
87
|
-
#
|
88
|
-
# # The reporter object may be nil because of various error conditions,
|
89
|
-
# # so you must check for it.
|
90
|
-
# if reporter
|
91
|
-
# # (3) For example you can log the amount of time it took to render
|
92
|
-
# # the view.
|
93
|
-
# reporter.log_total_view_rendering_time(rendering_time)
|
94
|
-
# end
|
95
|
-
#
|
96
|
-
# [200, { "Content-Type" => "text/plain" }, body]
|
97
|
-
# end
|
98
|
-
#
|
99
|
-
# # Tell the application server to run this application object.
|
100
|
-
# run app
|
101
|
-
module UnionStationHooks
|
102
|
-
# The path to the `union_station_hooks_core` Ruby library directory.
|
103
|
-
#
|
104
|
-
# @private
|
105
|
-
LIBROOT = File.expand_path(File.dirname(__FILE__))
|
106
|
-
|
107
|
-
# The path to the `union_station_hooks_core` gem root directory.
|
108
|
-
#
|
109
|
-
# @private
|
110
|
-
ROOT = File.dirname(LIBROOT)
|
111
|
-
|
112
|
-
class << self
|
113
|
-
# This error is raised by {UnionStationHooks.initialize!} if a required
|
114
|
-
# {UnionStationHooks.config configuration option} is missing.
|
115
|
-
class ConfigurationError < StandardError
|
116
|
-
end
|
117
|
-
|
118
|
-
# @private
|
119
|
-
@@config = {}
|
120
|
-
# @private
|
121
|
-
@@context = nil
|
122
|
-
# @private
|
123
|
-
@@initializers = []
|
124
|
-
# @private
|
125
|
-
@@initialized = false
|
126
|
-
# @private
|
127
|
-
@@app_group_name = nil
|
128
|
-
# @private
|
129
|
-
@@key = nil
|
130
|
-
# @private
|
131
|
-
@@vendored = false
|
132
|
-
|
133
|
-
# Initializes the Union Station hooks. If there are any other
|
134
|
-
# `union_station_hooks_*` gems loaded, then they are initialized too.
|
135
|
-
#
|
136
|
-
# Applications must call this during startup. Hooks aren't actually
|
137
|
-
# installed until this method is called, so until you call this you cannot
|
138
|
-
# use the public APIs of any `union_station_hooks_*` gems (besides trivial
|
139
|
-
# things such as {UnionStationHooks.initialized?}).
|
140
|
-
#
|
141
|
-
# A good place to call this is in the Rackup file `config.ru`. Or, if your
|
142
|
-
# application is a Rails app, then you should create an initializer file
|
143
|
-
# `config/initializers/union_station.rb` in which you call this.
|
144
|
-
#
|
145
|
-
# If this method successfully initializes, then it returns true.
|
146
|
-
#
|
147
|
-
# Calling this method may or may not actually initialize the hooks. If
|
148
|
-
# this gem determines that initialization is not desired, then this method
|
149
|
-
# won't do anything and will return `false`. See
|
150
|
-
# {UnionStationHooks#should_initialize?}.
|
151
|
-
#
|
152
|
-
# Initialization takes place according to parameters set in the
|
153
|
-
# {UnionStationHooks.config configuration hash}. If a required
|
154
|
-
# configuration option is missing, then this method will raise a
|
155
|
-
# {ConfigurationError}.
|
156
|
-
#
|
157
|
-
# Initializing twice is a no-op. It only causes this method to return true.
|
158
|
-
#
|
159
|
-
# @raise [ConfigurationError] A required configuration option is missing.
|
160
|
-
# @return [Boolean] Whether initialization was successful.
|
161
|
-
def initialize!
|
162
|
-
return false if !should_initialize?
|
163
|
-
return true if initialized?
|
164
|
-
|
165
|
-
finalize_and_validate_config
|
166
|
-
require_lib('api')
|
167
|
-
create_context
|
168
|
-
install_postfork_hook
|
169
|
-
install_event_pre_hook
|
170
|
-
initialize_other_union_station_hooks_gems
|
171
|
-
finalize_install
|
172
|
-
|
173
|
-
true
|
174
|
-
end
|
175
|
-
|
176
|
-
# Returns whether the Union Station hooks are initialized.
|
177
|
-
def initialized?
|
178
|
-
@@initialized
|
179
|
-
end
|
180
|
-
|
181
|
-
# Returns whether the Union Station hooks should be initialized. If this
|
182
|
-
# method returns false, then {UnionStationHooks.initialize!} doesn't do
|
183
|
-
# anything.
|
184
|
-
#
|
185
|
-
# At present, this method only returns true when the app is running inside
|
186
|
-
# Passenger. This may change if and when in the future Union Station
|
187
|
-
# supports application servers besides Passenger.
|
188
|
-
def should_initialize?
|
189
|
-
if defined?(PhusionPassenger)
|
190
|
-
PhusionPassenger::App.options['analytics']
|
191
|
-
else
|
192
|
-
false
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
|
-
# Returns whether this `union_station_hooks_core` gem is bundled with
|
197
|
-
# Passenger (as opposed to a standalone gem added to the Gemfile).
|
198
|
-
# See the README and the file `hacking/Vendoring.md` for information
|
199
|
-
# about how Passenger bundles `union_station_hooks_*` gems.
|
200
|
-
#
|
201
|
-
# @private
|
202
|
-
def vendored?
|
203
|
-
@@vendored
|
204
|
-
end
|
205
|
-
|
206
|
-
# @private
|
207
|
-
def vendored=(val)
|
208
|
-
@@vendored = val
|
209
|
-
end
|
210
|
-
|
211
|
-
# @private
|
212
|
-
def require_lib(name)
|
213
|
-
require("#{LIBROOT}/union_station_hooks_core/#{name}")
|
214
|
-
end
|
215
|
-
|
216
|
-
# Returns the configuration hash. This configuration is used by all
|
217
|
-
# `union_station_hooks_*` gems. You are supposed to set this hash
|
218
|
-
# before calling {UnionStationHooks.initialize!}.
|
219
|
-
#
|
220
|
-
# At present, none of the `union_station_hooks_*` gems require
|
221
|
-
# additional configuration. All necessary configuration is pulled from
|
222
|
-
# Passenger. This may change if and when Union Station in the future
|
223
|
-
# supports application servers besides Passenger.
|
224
|
-
#
|
225
|
-
# This hash is supposed to only contain symbol keys, not string keys.
|
226
|
-
# When {UnionStationHooks.initialize!} is called, that method will
|
227
|
-
# convert all string keys to symbol keys before doing anything else
|
228
|
-
# with the config hash, so assigning string keys works even though
|
229
|
-
# we don't recommend it. Furthermore, the config hash is frozen after
|
230
|
-
# initialization.
|
231
|
-
#
|
232
|
-
# @return [Hash]
|
233
|
-
def config
|
234
|
-
@@config
|
235
|
-
end
|
236
|
-
|
237
|
-
# The singleton {Context} object, created during initialization.
|
238
|
-
# All the `union_station_hooks_*` gem internals make use of this context
|
239
|
-
# object.
|
240
|
-
#
|
241
|
-
# @private
|
242
|
-
def context
|
243
|
-
@@context
|
244
|
-
end
|
245
|
-
|
246
|
-
# An array of objects on which `#initialize!` will be called when
|
247
|
-
# {UnionStationHooks.initialize!} is called. Other `union_station_hooks_*`
|
248
|
-
# gems register themselves in this list when they are loaded, so that
|
249
|
-
# a call to {UnionStationHooks.initialize!} will initialize them too.
|
250
|
-
#
|
251
|
-
# @private
|
252
|
-
def initializers
|
253
|
-
@@initializers
|
254
|
-
end
|
255
|
-
|
256
|
-
# @private
|
257
|
-
def app_group_name
|
258
|
-
@@app_group_name
|
259
|
-
end
|
260
|
-
|
261
|
-
# The currently active Union Station key. This is pulled from the
|
262
|
-
# {UnionStationHooks.config configuration}.
|
263
|
-
#
|
264
|
-
# @private
|
265
|
-
def key
|
266
|
-
@@key
|
267
|
-
end
|
268
|
-
|
269
|
-
# @private
|
270
|
-
def call_event_pre_hook(_event)
|
271
|
-
raise 'This method may only be called after ' \
|
272
|
-
'UnionStationHooks.initialize! is called'
|
273
|
-
end
|
274
|
-
|
275
|
-
# Called by Passenger after loading the application, to check whether or
|
276
|
-
# not the application developer forgot to call
|
277
|
-
# {UnionStationHooks.initialize!}. If so, it logs the problem and
|
278
|
-
# initializes now.
|
279
|
-
#
|
280
|
-
# @private
|
281
|
-
def check_initialized
|
282
|
-
return if !should_initialize? || initialized?
|
283
|
-
return if !config.fetch(:check_initialized, true)
|
284
|
-
|
285
|
-
if defined?(::Rails)
|
286
|
-
message = 'The Union Station hooks are not initialized. Please ensure ' \
|
287
|
-
'that you have an initializer file ' \
|
288
|
-
'`config/initializers/union_station.rb` in which you call ' \
|
289
|
-
"this:\n\n" \
|
290
|
-
" if defined?(UnionStationHooks)\n" \
|
291
|
-
" UnionStationHooks.initialize!\n" \
|
292
|
-
" end"
|
293
|
-
else
|
294
|
-
message = 'The Union Station hooks are not initialized. Please ensure ' \
|
295
|
-
'that the following code is called during application ' \
|
296
|
-
"startup:\n\n" \
|
297
|
-
" if defined?(UnionStationHooks)\n" \
|
298
|
-
" UnionStationHooks.initialize!\n" \
|
299
|
-
" end"
|
300
|
-
end
|
301
|
-
|
302
|
-
STDERR.puts(" *** WARNING: #{message}")
|
303
|
-
@@config[:initialize_from_check] = true
|
304
|
-
initialize!
|
305
|
-
report_internal_information('HOOKS_NOT_INITIALIZED', message)
|
306
|
-
end
|
307
|
-
|
308
|
-
def now
|
309
|
-
# When `initialize!` is called, the definition in
|
310
|
-
# `api.rb` will override this implementation.
|
311
|
-
nil
|
312
|
-
end
|
313
|
-
|
314
|
-
def begin_rack_request(_rack_env)
|
315
|
-
# When `initialize!` is called, the definition in
|
316
|
-
# `api.rb` will override this implementation.
|
317
|
-
nil
|
318
|
-
end
|
319
|
-
|
320
|
-
def end_rack_request(_rack_env,
|
321
|
-
_uncaught_exception_raised_during_request = false)
|
322
|
-
# When `initialize!` is called, the definition in
|
323
|
-
# `api.rb` will override this implementation.
|
324
|
-
nil
|
325
|
-
end
|
326
|
-
|
327
|
-
def log_exception(_exception)
|
328
|
-
# When `initialize!` is called, the definition in
|
329
|
-
# `api.rb` will override this implementation.
|
330
|
-
nil
|
331
|
-
end
|
332
|
-
|
333
|
-
def get_delta_monotonic
|
334
|
-
# When `initialize!` is called, the definition in
|
335
|
-
# `api.rb` will override this implementation.
|
336
|
-
nil
|
337
|
-
end
|
338
|
-
|
339
|
-
private
|
340
|
-
|
341
|
-
def finalize_and_validate_config
|
342
|
-
final_config = {}
|
343
|
-
|
344
|
-
if defined?(PhusionPassenger)
|
345
|
-
import_into_final_config(final_config, PhusionPassenger::App.options)
|
346
|
-
end
|
347
|
-
import_into_final_config(final_config, config)
|
348
|
-
|
349
|
-
validate_final_config(final_config)
|
350
|
-
|
351
|
-
@@config = final_config
|
352
|
-
end
|
353
|
-
|
354
|
-
def import_into_final_config(dest, source)
|
355
|
-
source.each_pair do |key, val|
|
356
|
-
dest[key.to_sym] = val
|
357
|
-
end
|
358
|
-
end
|
359
|
-
|
360
|
-
def validate_final_config(config)
|
361
|
-
require_non_empty_config_key(config, :union_station_key)
|
362
|
-
require_non_empty_config_key(config, :app_group_name)
|
363
|
-
require_non_empty_config_key(config, :ust_router_address)
|
364
|
-
require_non_empty_config_key(config, :ust_router_password)
|
365
|
-
end
|
366
|
-
|
367
|
-
def require_non_empty_config_key(config, key)
|
368
|
-
if config[key].nil? || config[key].empty?
|
369
|
-
raise ArgumentError,
|
370
|
-
"Union Station hooks configuration option required: #{key}"
|
371
|
-
end
|
372
|
-
end
|
373
|
-
|
374
|
-
def require_simple_json
|
375
|
-
if defined?(PhusionPassenger)
|
376
|
-
begin
|
377
|
-
PhusionPassenger.require_passenger_lib('utils/json')
|
378
|
-
UnionStationHooks.const_set(:SimpleJSON, PhusionPassenger::Utils)
|
379
|
-
rescue LoadError
|
380
|
-
end
|
381
|
-
end
|
382
|
-
if !defined?(UnionStationHooks::SimpleJSON)
|
383
|
-
require_lib('simple_json')
|
384
|
-
end
|
385
|
-
end
|
386
|
-
|
387
|
-
def report_internal_information(type, message, data = nil)
|
388
|
-
data ||= {}
|
389
|
-
data[:app_type] ||= :ruby
|
390
|
-
if defined?(::Rails)
|
391
|
-
data[:framework_type] = :rails
|
392
|
-
end
|
393
|
-
|
394
|
-
if defined?(PhusionPassenger)
|
395
|
-
data[:app_server] = {
|
396
|
-
:id => :passenger,
|
397
|
-
:version => PhusionPassenger::VERSION_STRING
|
398
|
-
}
|
399
|
-
end
|
400
|
-
|
401
|
-
body = SimpleJSON::JSON.generate(
|
402
|
-
:type => type,
|
403
|
-
:message => message,
|
404
|
-
:data => data
|
405
|
-
)
|
406
|
-
|
407
|
-
transaction = context.new_transaction(app_group_name,
|
408
|
-
:internal_information, key)
|
409
|
-
begin
|
410
|
-
transaction.message(body)
|
411
|
-
ensure
|
412
|
-
transaction.close
|
413
|
-
end
|
414
|
-
end
|
415
|
-
end
|
416
|
-
end
|
417
|
-
|
418
|
-
UnionStationHooks.require_lib('version')
|
419
|
-
|
420
|
-
if config_from_vendored_ush
|
421
|
-
UnionStationHooks.config.replace(config_from_vendored_ush)
|
422
|
-
UnionStationHooks.initializers.replace(initializers_from_vendored_ush)
|
423
|
-
end
|