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.

Files changed (241) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +13 -0
  3. data/CONTRIBUTORS +5 -1
  4. data/build/agent.rb +22 -2
  5. data/build/cxx_tests.rb +41 -5
  6. data/build/misc.rb +4 -1
  7. data/build/support/cxx_dependency_map.rb +1746 -908
  8. data/build/support/vendor/cxx_hinted_parser/CxxHintedParser.sublime-project +8 -0
  9. data/build/support/vendor/cxx_hinted_parser/Gemfile +5 -0
  10. data/build/support/vendor/cxx_hinted_parser/Gemfile.lock +30 -0
  11. data/{src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core → build/support/vendor/cxx_hinted_parser}/LICENSE.md +1 -1
  12. data/build/support/vendor/cxx_hinted_parser/README.md +95 -0
  13. data/build/support/vendor/cxx_hinted_parser/Rakefile +4 -0
  14. 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
  15. data/build/support/vendor/cxx_hinted_parser/lib/cxx_hinted_parser/parser.rb +239 -0
  16. data/dev/ci/README.md +15 -2
  17. data/dev/ci/lib/set-container-envvars.sh +6 -0
  18. data/dev/ci/lib/setup-container.sh +4 -1
  19. data/dev/ci/scripts/debug-console-wrapper.sh +3 -1
  20. data/dev/ci/setup-host +5 -0
  21. data/dev/ci/tests/binaries/Jenkinsfile +105 -0
  22. data/dev/ci/tests/binaries/build-linux +38 -0
  23. data/dev/ci/tests/binaries/build-macos +40 -0
  24. data/dev/ci/tests/binaries/prepare-macos +38 -0
  25. data/dev/ci/tests/binaries/test-linux +45 -0
  26. data/dev/ci/tests/binaries/test-macos +38 -0
  27. data/dev/ci/tests/debian/Jenkinsfile +2 -2
  28. data/dev/ci/tests/rpm/Jenkinsfile +1 -1
  29. data/dev/configkit-schemas/index.json +3 -24
  30. data/dev/vagrant/nginx_rakefile +0 -1
  31. data/package.json +15 -5
  32. data/resources/templates/error_renderer/.editorconfig +19 -0
  33. data/resources/templates/error_renderer/with_details/README.md +9 -0
  34. data/resources/templates/error_renderer/with_details/dist/bundle.js +33 -0
  35. data/resources/templates/error_renderer/with_details/dist/styles.css +17 -0
  36. data/resources/templates/error_renderer/with_details/src/DetailsView.jsx +52 -0
  37. data/resources/templates/error_renderer/with_details/src/GetHelpView.jsx +61 -0
  38. data/resources/templates/error_renderer/with_details/src/JourneyView.css +50 -0
  39. data/resources/templates/error_renderer/with_details/src/JourneyView.jsx +621 -0
  40. data/resources/templates/error_renderer/with_details/src/PageMain.css +114 -0
  41. data/resources/templates/error_renderer/with_details/src/PageMain.jsx +136 -0
  42. data/resources/templates/error_renderer/with_details/src/ProblemDescriptionView.jsx +14 -0
  43. data/resources/templates/error_renderer/with_details/src/ProcessDetailsView.jsx +56 -0
  44. data/resources/templates/error_renderer/with_details/src/SolutionDescriptionView.css +5 -0
  45. data/resources/templates/error_renderer/with_details/src/SolutionDescriptionView.jsx +15 -0
  46. data/resources/templates/error_renderer/with_details/src/SummaryView.jsx +35 -0
  47. data/resources/templates/error_renderer/with_details/src/SystemComponentView.css +34 -0
  48. data/resources/templates/error_renderer/with_details/src/SystemComponentView.jsx +168 -0
  49. data/resources/templates/error_renderer/with_details/src/SystemComponentsView.css +13 -0
  50. data/resources/templates/error_renderer/with_details/src/SystemComponentsView.jsx +116 -0
  51. data/resources/templates/error_renderer/with_details/src/Tab.jsx +12 -0
  52. data/resources/templates/error_renderer/with_details/src/Tabs.jsx +104 -0
  53. data/resources/templates/error_renderer/with_details/src/bootstrap/bootstrap.css +3446 -0
  54. data/resources/templates/error_renderer/with_details/src/bootstrap/bootstrap.js +293 -0
  55. data/resources/templates/error_renderer/with_details/src/bootstrap/config.json +401 -0
  56. data/resources/templates/error_renderer/with_details/src/index.html.template +22 -0
  57. data/resources/templates/error_renderer/with_details/src/index.jsx +23 -0
  58. data/resources/templates/error_renderer/with_details/webpack.config.js +47 -0
  59. data/resources/templates/error_renderer/without_details/dist/bundle.js +1 -0
  60. data/resources/templates/error_renderer/without_details/dist/styles.css +1 -0
  61. data/resources/templates/{undisclosed_error.html.template → error_renderer/without_details/src/index.html.template} +7 -11
  62. data/resources/templates/error_renderer/without_details/src/index.js +1 -0
  63. data/resources/templates/{error_layout.css → error_renderer/without_details/src/main.css} +5 -2
  64. data/resources/templates/error_renderer/without_details/webpack.config.js +42 -0
  65. data/src/agent/AgentMain.cpp +3 -3
  66. data/src/agent/Core/ApplicationPool/BasicProcessInfo.h +13 -0
  67. data/src/agent/Core/ApplicationPool/Common.h +3 -4
  68. data/src/agent/Core/ApplicationPool/Context.h +27 -17
  69. data/src/agent/Core/ApplicationPool/Group.h +3 -1
  70. data/src/agent/Core/ApplicationPool/Group/InitializationAndShutdown.cpp +2 -12
  71. data/src/agent/Core/ApplicationPool/Group/InternalUtils.cpp +55 -10
  72. data/src/agent/Core/ApplicationPool/Group/LifetimeAndBasics.cpp +1 -1
  73. data/src/agent/Core/ApplicationPool/Group/OutOfBandWork.cpp +1 -1
  74. data/src/agent/Core/ApplicationPool/Group/SpawningAndRestarting.cpp +13 -6
  75. data/src/agent/Core/ApplicationPool/Implementation.cpp +16 -100
  76. data/src/agent/Core/ApplicationPool/Options.h +8 -65
  77. data/src/agent/Core/ApplicationPool/Pool.h +4 -21
  78. data/src/agent/Core/ApplicationPool/Pool/AnalyticsCollection.cpp +1 -60
  79. data/src/agent/Core/ApplicationPool/Pool/GeneralUtils.cpp +10 -13
  80. data/src/agent/Core/ApplicationPool/Pool/InitializationAndShutdown.cpp +3 -8
  81. data/src/agent/Core/ApplicationPool/Pool/Miscellaneous.cpp +2 -34
  82. data/src/agent/Core/ApplicationPool/Pool/StateInspection.cpp +1 -1
  83. data/src/agent/Core/ApplicationPool/Process.cpp +17 -12
  84. data/src/agent/Core/ApplicationPool/Process.h +146 -93
  85. data/src/agent/Core/ApplicationPool/Session.h +2 -2
  86. data/src/agent/Core/ApplicationPool/Socket.h +28 -27
  87. data/src/agent/Core/Config.h +1 -3
  88. data/src/agent/Core/ConfigChange.cpp +2 -4
  89. data/src/agent/Core/Controller.h +2 -8
  90. data/src/agent/Core/Controller/BufferBody.cpp +0 -2
  91. data/src/agent/Core/Controller/CheckoutSession.cpp +12 -24
  92. data/src/agent/Core/Controller/Config.h +1 -9
  93. data/src/agent/Core/Controller/ForwardResponse.cpp +0 -34
  94. data/src/agent/Core/Controller/Hooks.cpp +0 -7
  95. data/src/agent/Core/Controller/InitRequest.cpp +0 -43
  96. data/src/agent/Core/Controller/InitializationAndShutdown.cpp +0 -4
  97. data/src/agent/Core/Controller/Request.h +1 -35
  98. data/src/agent/Core/Controller/SendRequest.cpp +0 -32
  99. data/src/agent/Core/CoreMain.cpp +19 -32
  100. data/src/agent/Core/SpawningKit/Config.h +329 -55
  101. data/src/agent/Core/SpawningKit/Config/AutoGeneratedCode.h +369 -0
  102. data/src/agent/Core/SpawningKit/Config/AutoGeneratedCode.h.cxxcodebuilder +307 -0
  103. data/src/agent/Core/SpawningKit/Context.h +211 -0
  104. data/src/agent/Core/SpawningKit/DirectSpawner.h +112 -122
  105. data/src/agent/Core/SpawningKit/DummySpawner.h +59 -20
  106. data/src/agent/Core/SpawningKit/ErrorRenderer.h +117 -0
  107. data/src/agent/Core/SpawningKit/Exceptions.h +1157 -0
  108. data/src/agent/Core/SpawningKit/Factory.h +24 -17
  109. data/src/agent/Core/SpawningKit/{BackgroundIOCapturer.h → Handshake/BackgroundIOCapturer.h} +48 -18
  110. data/src/agent/Core/SpawningKit/Handshake/Perform.h +1650 -0
  111. data/src/agent/Core/SpawningKit/Handshake/Prepare.h +582 -0
  112. data/src/agent/Core/SpawningKit/Handshake/Session.h +91 -0
  113. data/src/agent/Core/SpawningKit/Handshake/WorkDir.h +100 -0
  114. data/src/agent/Core/SpawningKit/Journey.h +561 -0
  115. data/src/agent/Core/SpawningKit/PipeWatcher.h +41 -18
  116. data/src/agent/Core/SpawningKit/README.md +534 -0
  117. data/src/agent/Core/SpawningKit/Result.h +182 -7
  118. data/src/agent/Core/SpawningKit/Result/AutoGeneratedCode.h +69 -0
  119. data/src/agent/Core/SpawningKit/Result/AutoGeneratedCode.h.cxxcodebuilder +110 -0
  120. data/src/agent/Core/SpawningKit/SmartSpawner.h +1027 -562
  121. data/src/agent/Core/SpawningKit/Spawner.h +70 -1134
  122. data/src/agent/Core/SpawningKit/UserSwitchingRules.h +3 -33
  123. data/src/agent/README.md +2 -3
  124. data/src/agent/Shared/ApiServerUtils.h +2 -3
  125. data/src/agent/SpawnEnvSetupper/SpawnEnvSetupperMain.cpp +932 -0
  126. data/src/agent/Watchdog/Config.h +1 -3
  127. data/src/agent/Watchdog/WatchdogMain.cpp +2 -1
  128. data/src/apache2_module/ConfigGeneral/AutoGeneratedDefinitions.cpp +5 -0
  129. data/src/apache2_module/ConfigGeneral/AutoGeneratedManifestDefaultsInitialization.cpp +5 -0
  130. data/src/apache2_module/ConfigGeneral/ManifestGeneration.h +22 -13
  131. data/src/apache2_module/DirConfig/AutoGeneratedCreateFunction.cpp +5 -0
  132. data/src/apache2_module/DirConfig/AutoGeneratedHeaderSerialization.cpp +3 -0
  133. data/src/apache2_module/DirConfig/AutoGeneratedManifestGeneration.cpp +13 -0
  134. data/src/apache2_module/DirConfig/AutoGeneratedMergeFunction.cpp +7 -0
  135. data/src/apache2_module/DirConfig/AutoGeneratedStruct.h +13 -0
  136. data/src/cxx_supportlib/Constants.h +3 -1
  137. data/src/cxx_supportlib/Exceptions.h +0 -121
  138. data/src/cxx_supportlib/LoggingKit/Implementation.cpp +7 -6
  139. data/src/cxx_supportlib/LoggingKit/Logging.h +3 -1
  140. data/src/cxx_supportlib/Utils.cpp +42 -0
  141. data/src/cxx_supportlib/Utils.h +7 -0
  142. data/src/cxx_supportlib/Utils/IOUtils.cpp +58 -0
  143. data/src/cxx_supportlib/Utils/IOUtils.h +13 -0
  144. data/src/cxx_supportlib/Utils/JsonUtils.h +130 -23
  145. data/src/cxx_supportlib/Utils/ScopeGuard.h +9 -4
  146. data/src/cxx_supportlib/Utils/StrIntUtils.cpp +7 -0
  147. data/src/cxx_supportlib/Utils/StrIntUtils.h +1 -0
  148. data/src/cxx_supportlib/Utils/SystemTime.h +1 -1
  149. data/src/cxx_supportlib/Utils/Timer.h +1 -1
  150. data/src/cxx_supportlib/WebSocketCommandReverseServer.h +6 -4
  151. data/src/cxx_supportlib/vendor-copy/adhoc_lve.h +1 -0
  152. data/src/helper-scripts/node-loader.js +54 -59
  153. data/src/helper-scripts/rack-loader.rb +63 -60
  154. data/src/helper-scripts/rack-preloader.rb +125 -72
  155. data/src/helper-scripts/wsgi-loader.py +100 -43
  156. data/src/nginx_module/ConfigGeneral/AutoGeneratedDefinitions.c +120 -112
  157. data/src/nginx_module/ConfigGeneral/AutoGeneratedManifestDefaultsInitialization.c +15 -8
  158. data/src/nginx_module/ConfigGeneral/AutoGeneratedSetterFuncs.c +142 -142
  159. data/src/nginx_module/ConfigGeneral/ManifestGeneration.c +26 -15
  160. data/src/nginx_module/ConfigGeneral/ManifestGeneration.h +3 -0
  161. data/src/nginx_module/LocationConfig/AutoGeneratedCreateFunction.c +76 -70
  162. data/src/nginx_module/LocationConfig/AutoGeneratedHeaderSerialization.c +114 -99
  163. data/src/nginx_module/LocationConfig/AutoGeneratedManifestGeneration.c +170 -156
  164. data/src/nginx_module/LocationConfig/AutoGeneratedMergeFunction.c +38 -35
  165. data/src/nginx_module/LocationConfig/AutoGeneratedStruct.h +5 -1
  166. data/src/ruby_supportlib/phusion_passenger.rb +5 -5
  167. data/src/ruby_supportlib/phusion_passenger/admin_tools/instance.rb +14 -1
  168. data/src/ruby_supportlib/phusion_passenger/apache2/config_options.rb +8 -0
  169. data/src/ruby_supportlib/phusion_passenger/common_library.rb +0 -3
  170. data/src/ruby_supportlib/phusion_passenger/config/nginx_engine_compiler.rb +0 -1
  171. data/src/ruby_supportlib/phusion_passenger/constants.rb +2 -0
  172. data/src/ruby_supportlib/phusion_passenger/loader_shared_helpers.rb +646 -238
  173. data/src/ruby_supportlib/phusion_passenger/nginx/config_options.rb +117 -95
  174. data/src/ruby_supportlib/phusion_passenger/packaging.rb +0 -1
  175. data/src/ruby_supportlib/phusion_passenger/platform_info/depcheck_specs/apache2.rb +5 -1
  176. data/src/ruby_supportlib/phusion_passenger/preloader_shared_helpers.rb +92 -69
  177. data/src/ruby_supportlib/phusion_passenger/public_api.rb +0 -17
  178. data/src/ruby_supportlib/phusion_passenger/rack/thread_handler_extension.rb +0 -3
  179. data/src/ruby_supportlib/phusion_passenger/request_handler.rb +4 -5
  180. data/src/ruby_supportlib/phusion_passenger/request_handler/thread_handler.rb +0 -22
  181. metadata +64 -67
  182. data/resources/templates/error_layout.html.template +0 -86
  183. data/resources/templates/general_error.html.template +0 -1
  184. data/resources/templates/general_error_with_html.html.template +0 -1
  185. data/src/agent/Core/ApplicationPool/ErrorRenderer.h +0 -131
  186. data/src/agent/Core/SpawningKit/Options.h +0 -41
  187. data/src/agent/Core/UnionStation/Connection.h +0 -173
  188. data/src/agent/Core/UnionStation/Context.h +0 -536
  189. data/src/agent/Core/UnionStation/StopwatchLog.h +0 -147
  190. data/src/agent/Core/UnionStation/Transaction.h +0 -249
  191. data/src/agent/SpawnPreparer/SpawnPreparerMain.cpp +0 -208
  192. data/src/cxx_supportlib/UnionStationFilterSupport.cpp +0 -67
  193. data/src/cxx_supportlib/UnionStationFilterSupport.h +0 -1622
  194. data/src/nodejs_supportlib/phusion_passenger/log_express.js +0 -106
  195. data/src/nodejs_supportlib/phusion_passenger/log_mongodb.js +0 -202
  196. data/src/nodejs_supportlib/phusion_passenger/ustreporter.js +0 -227
  197. data/src/nodejs_supportlib/phusion_passenger/ustrouter_connector.js +0 -448
  198. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/CONFIG.md +0 -37
  199. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/Gemfile +0 -17
  200. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/Gemfile.lock +0 -59
  201. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/README-API.md +0 -5
  202. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/README.md +0 -117
  203. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/Rakefile +0 -115
  204. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core.rb +0 -423
  205. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/api.rb +0 -238
  206. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/connection.rb +0 -67
  207. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/context.rb +0 -281
  208. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/lock.rb +0 -62
  209. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/log.rb +0 -66
  210. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/message_channel.rb +0 -157
  211. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter.rb +0 -150
  212. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/basics.rb +0 -199
  213. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/controllers.rb +0 -187
  214. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/misc.rb +0 -303
  215. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/view_rendering.rb +0 -91
  216. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/simple_json.rb +0 -396
  217. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/spec_helper.rb +0 -279
  218. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/time_point.rb +0 -39
  219. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/transaction.rb +0 -173
  220. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/utils.rb +0 -177
  221. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/version.rb +0 -32
  222. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/version_data.rb +0 -44
  223. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/ruby_versions.yml.example +0 -16
  224. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/ruby_versions.yml.travis +0 -20
  225. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/ruby_versions.yml.travis-with-sudo +0 -18
  226. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/union_station_hooks_core.gemspec +0 -23
  227. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/Gemfile +0 -14
  228. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/Gemfile.lock +0 -45
  229. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/LICENSE.md +0 -19
  230. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/README.md +0 -104
  231. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/Rakefile +0 -160
  232. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails.rb +0 -200
  233. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/action_controller_extension.rb +0 -45
  234. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/action_view_subscriber.rb +0 -55
  235. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/active_record_subscriber.rb +0 -41
  236. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/active_support_benchmarkable_extension.rb +0 -47
  237. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/active_support_cache_subscriber.rb +0 -79
  238. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/exception_logger.rb +0 -57
  239. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/version.rb +0 -32
  240. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/version_data.rb +0 -44
  241. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/union_station_hooks_rails.gemspec +0 -34
@@ -1,279 +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 'fileutils'
25
- require 'net/http'
26
- require 'uri'
27
-
28
- module UnionStationHooks
29
- # Contains helper methods for use in unit tests across all the
30
- # `union_station_hooks_*` gems.
31
- #
32
- # @private
33
- module SpecHelper
34
- extend self # Make methods available as class methods.
35
-
36
- def self.included(klass)
37
- # When included into another class, make sure that Utils
38
- # methods are made private.
39
- public_instance_methods(false).each do |method_name|
40
- klass.send(:private, method_name)
41
- end
42
- end
43
-
44
- # To be called during initialization of the test suite.
45
- def initialize!
46
- load_passenger
47
- initialize_ush_api
48
- initialize_debugging
49
- undo_bundler
50
- end
51
-
52
- # Lookup the `passenger-config` command, either by respecting the
53
- # `PASSENGER_CONFIG` environment variable, or by looking it up in `PATH`.
54
- # If the command cannot be found, the current process aborts with an
55
- # error message.
56
- def find_passenger_config
57
- passenger_config = ENV['PASSENGER_CONFIG']
58
- if passenger_config.nil? || passenger_config.empty?
59
- passenger_config = find_passenger_config_vendor ||
60
- find_passenger_config_in_path
61
- end
62
- if passenger_config.nil? || passenger_config.empty?
63
- abort 'ERROR: The unit tests are to be run against a specific ' \
64
- 'Passenger version. However, the \'passenger-config\' command is ' \
65
- 'not found. Please install Passenger, or (if you are sure ' \
66
- 'Passenger is installed) set the PASSENGER_CONFIG environment ' \
67
- 'variable to the \'passenger-config\' command.'
68
- end
69
- passenger_config
70
- end
71
-
72
- # Looks for the passenger-config command in PATH, returning nil
73
- # if not found.
74
- def find_passenger_config_in_path
75
- ENV['PATH'].split(':').each do |path|
76
- if File.exist?("#{path}/passenger-config")
77
- return "#{path}/passenger-config"
78
- end
79
- end
80
- end
81
-
82
- # Checks whether this union_station_hooks installation is a copy that
83
- # is vendored into Passenger, and if so, returns the full path to the
84
- # containing Passenger's passenger-config command.
85
- def find_passenger_config_vendor
86
- path = "#{UnionStationHooks::ROOT}/../../../../../bin/passenger-config"
87
- if File.exist?(path)
88
- File.expand_path(path)
89
- else
90
- nil
91
- end
92
- end
93
-
94
- # Uses `find_passenger_config` to lookup a Passenger installation, and
95
- # loads the Passenger Ruby support library associated with that
96
- # installation. All the constants defined in the Passenger Ruby support
97
- # library are loaded. In addition, checks whether the Passenger agent
98
- # executable is installed. If not, the current process aborts with an
99
- # error message.
100
- def load_passenger
101
- passenger_config = find_passenger_config
102
- puts "Using Passenger installation at: #{passenger_config}"
103
- passenger_ruby_libdir = `#{passenger_config} about ruby-libdir`.strip
104
- require("#{passenger_ruby_libdir}/phusion_passenger")
105
- PhusionPassenger.locate_directories
106
- PhusionPassenger.require_passenger_lib 'constants'
107
- puts "Loaded Passenger version #{PhusionPassenger::VERSION_STRING}"
108
-
109
- agent = PhusionPassenger.find_support_binary(PhusionPassenger::AGENT_EXE)
110
- if agent.nil?
111
- abort "ERROR: The Passenger agent isn't installed. Please ensure " \
112
- "that it is installed, e.g. using:\n\n" \
113
- " #{passenger_config} install-agent\n\n"
114
- end
115
- end
116
-
117
- def initialize_ush_api
118
- UnionStationHooks.require_lib('api')
119
- UnionStationHooks.instance_variable_set(:@mono_mutex, Mutex.new)
120
- UnionStationHooks.instance_variable_set(:@delta_monotonic, 0)
121
- end
122
-
123
- def initialize_debugging
124
- @@debug = !ENV['DEBUG'].to_s.empty?
125
- if @@debug
126
- UnionStationHooks.require_lib('log')
127
- UnionStationHooks::Log.debugging = true
128
- end
129
- end
130
-
131
- # Unit tests must undo the Bundler environment so that the gem's
132
- # own Gemfile doesn't affect subprocesses that may have their
133
- # own Gemfile.
134
- def undo_bundler
135
- clean_env = nil
136
- Bundler.with_clean_env do
137
- clean_env = ENV.to_hash
138
- end
139
- ENV.replace(clean_env)
140
- end
141
-
142
- # Checks whether `initialize_debugging` enabled debugging mode.
143
- def debug?
144
- @@debug
145
- end
146
-
147
- # Writes the given content to the file at the given path. If or or more
148
- # parent directories don't exist, then they are created.
149
- def write_file(path, content)
150
- dir = File.dirname(path)
151
- if !File.exist?(dir)
152
- FileUtils.mkdir_p(dir)
153
- end
154
- File.open(path, 'wb') do |f|
155
- f.write(content)
156
- end
157
- end
158
-
159
- def get_response(path)
160
- uri = URI.parse("#{root_url}#{path}")
161
- Net::HTTP.get_response(uri)
162
- end
163
-
164
- def get(path)
165
- response = get_response(path)
166
- return_200_response_body(path, response)
167
- end
168
-
169
- def return_200_response_body(path, response)
170
- if response.code == '200'
171
- response.body
172
- else
173
- raise "HTTP request to #{path} failed.\n" \
174
- "Code: #{response.code}\n" \
175
- "Body:\n" \
176
- "#{response.body}"
177
- end
178
- end
179
-
180
- # Opens a debug shell. By default, the debug shell is opened in the current
181
- # working directory. If the current module has the `prepare_debug_shell`
182
- # method, that method is called before opening the debug shell. The method
183
- # could, for example, change the working directory.
184
- #
185
- # This method does *not* raise an exception if the debug shell exits with
186
- # an error.
187
- def debug_shell
188
- puts '------ Opening debug shell -----'
189
- @orig_dir = Dir.pwd
190
- begin
191
- if respond_to?(:prepare_debug_shell)
192
- prepare_debug_shell
193
- end
194
- system('bash')
195
- ensure
196
- Dir.chdir(@orig_dir)
197
- end
198
- puts '------ Exiting debug shell -----'
199
- end
200
-
201
- # Returns the path of a specific UstRouter dump file.
202
- # Requires that `@dump_dir` is set.
203
- def dump_file_path(category = 'requests')
204
- raise '@dump_dir variable required' if !@dump_dir
205
- "#{@dump_dir}/#{category}"
206
- end
207
-
208
- # Reads the contents of a specific UstRouter dump file.
209
- # Requires that `@dump_dir` is set.
210
- #
211
- # @raise SystemError Something went wrong during reading.
212
- def read_dump_file(category = 'requests')
213
- File.read(dump_file_path(category))
214
- end
215
-
216
- # Waits until the dump file exists. Raises an error if
217
- # this doesn't become true within the default {#eventually}
218
- # timeout.
219
- def wait_for_dump_file_existance(category = 'requests')
220
- eventually do
221
- File.exist?(dump_file_path(category))
222
- end
223
- end
224
-
225
- # Assert that the dump file eventually exists and that its contents
226
- # eventually match the given regex.
227
- def eventually_expect_dump_file_to_match(regex, category = 'requests')
228
- wait_for_dump_file_existance(category)
229
- eventually do
230
- read_dump_file(category) =~ regex
231
- end
232
- end
233
-
234
- # Assert that the dump file (if it ever exists) its contents will never match
235
- # the given regex.
236
- def never_expect_dump_file_to_match(regex, category = 'requests')
237
- should_never_happen do
238
- File.exist?(dump_file_path(category)) &&
239
- read_dump_file(category) =~ regex
240
- end
241
- end
242
-
243
- # Makes `UnionStationHooks::Log.warn` not print anything.
244
- def silence_warnings
245
- UnionStationHooks::Log.warn_callback = lambda { |_message| }
246
- end
247
-
248
- # Asserts that something should eventually happen. This is done by checking
249
- # that the given block eventually returns true. The block is called
250
- # once every `check_interval` msec. If the block does not return true
251
- # within `deadline_duration` secs, then an exception is raised.
252
- def eventually(deadline_duration = 3, check_interval = 0.05)
253
- deadline = Time.now + deadline_duration
254
- while Time.now < deadline
255
- if yield
256
- return
257
- else
258
- sleep(check_interval)
259
- end
260
- end
261
- raise 'Time limit exceeded'
262
- end
263
-
264
- # Asserts that something should never happen. This is done by checking that
265
- # the given block never returns true. The block is called once every
266
- # `check_interval` msec, until `deadline_duration` seconds have passed.
267
- # If the block ever returns true, then an exception is raised.
268
- def should_never_happen(deadline_duration = 0.5, check_interval = 0.05)
269
- deadline = Time.now + deadline_duration
270
- while Time.now < deadline
271
- if yield
272
- raise "That which shouldn't happen happened anyway"
273
- else
274
- sleep(check_interval)
275
- end
276
- end
277
- end
278
- end
279
- end
@@ -1,39 +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
- # See {UnionStationHooks.now} for more information.
27
- class TimePoint
28
- # @api private
29
- attr_reader :monotime, :utime, :stime
30
-
31
- # @api private
32
- def initialize(monotime, utime, stime)
33
- @monotime = monotime
34
- @utime = utime
35
- @stime = stime
36
- end
37
-
38
- end
39
- end
@@ -1,173 +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 'log'
25
- UnionStationHooks.require_lib 'context'
26
- UnionStationHooks.require_lib 'time_point'
27
- UnionStationHooks.require_lib 'utils'
28
-
29
- module UnionStationHooks
30
- # @private
31
- class Transaction
32
- attr_reader :txn_id
33
-
34
- def initialize(connection, txn_id)
35
- @connection = connection
36
- @txn_id = txn_id
37
- if connection
38
- raise ArgumentError, 'Transaction ID required' if txn_id.nil?
39
- connection.ref
40
- end
41
- end
42
-
43
- def null?
44
- !@connection || !@connection.connected?
45
- end
46
-
47
- def message(text)
48
- if !@connection
49
- log_message_to_null(text)
50
- return
51
- end
52
-
53
- @connection.synchronize do
54
- if !@connection.connected?
55
- log_message_to_null(text)
56
- return
57
- end
58
-
59
- UnionStationHooks::Log.debug('[Union Station log] ' \
60
- "#{@txn_id} #{Utils.encoded_timestamp} #{text}")
61
-
62
- io_operation do
63
- @connection.channel.write('log', @txn_id, Utils.encoded_timestamp)
64
- @connection.channel.write_scalar(text)
65
- end
66
- end
67
- end
68
-
69
- def log_activity_block(name, extra_info = nil)
70
- has_error = false
71
- log_activity_begin(name, UnionStationHooks.now, extra_info)
72
- begin
73
- yield
74
- rescue Exception
75
- has_error = true
76
- is_closed = closed?
77
- raise
78
- ensure
79
- if !is_closed
80
- log_activity_end(name, UnionStationHooks.now, has_error)
81
- end
82
- end
83
- end
84
-
85
- def log_activity_begin(name, time = UnionStationHooks.now, extra_info = nil)
86
- if extra_info
87
- extra_info_base64 = Utils.base64(extra_info)
88
- else
89
- extra_info_base64 = nil
90
- end
91
- if time.is_a?(TimePoint)
92
- message "BEGIN: #{name} (#{time.monotime.to_s(36)}," \
93
- "#{time.utime.to_s(36)},#{time.stime.to_s(36)}) " \
94
- "#{extra_info_base64}"
95
- else
96
- message "BEGIN: #{name} (#{Utils.monotime_usec_from_time(time).to_s(36)})" \
97
- " #{extra_info_base64}"
98
- end
99
- end
100
-
101
- def log_activity_end(name, time = UnionStationHooks.now, has_error = false)
102
- if time.is_a?(TimePoint)
103
- if has_error
104
- message "FAIL: #{name} (#{time.monotime.to_s(36)}," \
105
- "#{time.utime.to_s(36)},#{time.stime.to_s(36)})"
106
- else
107
- message "END: #{name} (#{time.monotime.to_s(36)}," \
108
- "#{time.utime.to_s(36)},#{time.stime.to_s(36)})"
109
- end
110
- else
111
- if has_error
112
- message "FAIL: #{name} (#{Utils.monotime_usec_from_time(time).to_s(36)})"
113
- else
114
- message "END: #{name} (#{Utils.monotime_usec_from_time(time).to_s(36)})"
115
- end
116
- end
117
- end
118
-
119
- def log_activity(name, begin_time, end_time, extra_info = nil,
120
- has_error = false)
121
- log_activity_begin(name, begin_time, extra_info)
122
- log_activity_end(name, end_time, has_error)
123
- end
124
-
125
- def close
126
- return if !@connection
127
-
128
- @connection.synchronize do
129
- return if !@connection.connected?
130
-
131
- begin
132
- io_operation do
133
- # We need an ACK here so that we the UstRouter doesn't end up
134
- # processing the Core's openTransaction and closeTransaction pair
135
- # before it has received this process's openTransaction command.
136
- @connection.channel.write('closeTransaction', @txn_id,
137
- Utils.encoded_timestamp, true)
138
- Utils.process_ust_router_reply(@connection.channel,
139
- "Error handling reply for 'closeTransaction' message")
140
- end
141
- ensure
142
- @connection.unref
143
- @connection = nil
144
- end
145
- end
146
- end
147
-
148
- def closed?
149
- return nil if !@connection
150
- @connection.synchronize do
151
- !@connection.connected?
152
- end
153
- end
154
-
155
- private
156
-
157
- def log_message_to_null(text)
158
- UnionStationHooks::Log.debug('[Union Station log to null] ' \
159
- "#{@txn_id} #{Utils.encoded_timestamp} #{text}")
160
- end
161
-
162
- def io_operation
163
- yield
164
- rescue SystemCallError, IOError => e
165
- @connection.disconnect
166
- UnionStationHooks::Log.warn(
167
- "Error communicating with the UstRouter: #{e.message}")
168
- rescue Exception => e
169
- @connection.disconnect
170
- raise e
171
- end
172
- end
173
- end