passenger 6.2.0 → 6.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (650) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +33 -1
  3. data/CONTRIBUTING.md +7 -311
  4. data/CONTRIBUTORS +1 -0
  5. data/LICENSE +1 -1
  6. data/README.md +1 -1
  7. data/Rakefile +1 -1
  8. data/bin/passenger +1 -1
  9. data/bin/passenger-config +1 -1
  10. data/bin/passenger-install-apache2-module +1 -1
  11. data/bin/passenger-install-nginx-module +4 -9
  12. data/bin/passenger-memory-stats +1 -1
  13. data/bin/passenger-status +1 -1
  14. data/build/agent.rb +13 -15
  15. data/build/apache2.rb +13 -16
  16. data/build/basics.rb +10 -13
  17. data/build/common_library.rb +5 -9
  18. data/build/cxx_tests.rb +37 -12
  19. data/build/integration_tests.rb +5 -2
  20. data/build/misc.rb +1 -1
  21. data/build/nginx.rb +1 -1
  22. data/build/node_tests.rb +1 -1
  23. data/build/oxt_tests.rb +6 -8
  24. data/build/packaging.rb +1 -1
  25. data/build/ruby_extension.rb +1 -1
  26. data/build/ruby_tests.rb +1 -1
  27. data/build/schema_printer.rb +13 -15
  28. data/build/support/cplusplus.rb +61 -69
  29. data/build/support/cxx_dependency_map.rb +2 -1
  30. data/build/support/general.rb +1 -1
  31. data/build/support/vendor/cxx_hinted_parser/LICENSE.md +1 -1
  32. data/build/support/vendor/cxx_hinted_parser/lib/cxx_hinted_parser/parser.rb +1 -1
  33. data/build/support/vendor/cxx_hinted_parser/lib/cxx_hinted_parser.rb +1 -1
  34. data/build/support/vendor/cxxcodebuilder/LICENSE.md +1 -1
  35. data/build/support/vendor/cxxcodebuilder/lib/cxxcodebuilder/builder.rb +1 -1
  36. data/build/support/vendor/cxxcodebuilder/lib/cxxcodebuilder/initializer_builder.rb +1 -1
  37. data/build/support/vendor/cxxcodebuilder/lib/cxxcodebuilder.rb +1 -1
  38. data/build/test_basics.rb +1 -1
  39. data/dev/copy_boost_headers +1 -1
  40. data/dev/index_cxx_dependencies.rb +5 -1
  41. data/dev/libev-changes.patch +108 -0
  42. data/dev/nginx_version_sha256 +1 -1
  43. data/dev/ruby_server.rb +1 -6
  44. data/dev/upgrading_libuv.sh +16 -0
  45. data/doc/BasicArchitectureOverview.md +55 -0
  46. data/doc/BuildCaching.md +23 -0
  47. data/doc/BuildSystem.md +49 -0
  48. data/doc/DebuggingAndStressTesting.md +2 -0
  49. data/doc/DesignAspects/LimitedGemDependencies.md +1 -0
  50. data/doc/DevEnvironmentSetup.md +46 -0
  51. data/doc/DevHandbook.md +28 -0
  52. data/doc/Packaging.md +1 -1
  53. data/doc/RunningTests.md +88 -0
  54. data/doc/{TempFileHandling.md → SecureTempFileHandling.md} +1 -1
  55. data/doc/{CxxTestingGuide.md → WritingCxxTests.md} +1 -20
  56. data/src/agent/AgentMain.cpp +1 -1
  57. data/src/agent/Core/ApiServer.h +1 -1
  58. data/src/agent/Core/ApplicationPool/AbstractSession.h +1 -1
  59. data/src/agent/Core/ApplicationPool/BasicGroupInfo.h +1 -1
  60. data/src/agent/Core/ApplicationPool/BasicProcessInfo.h +1 -1
  61. data/src/agent/Core/ApplicationPool/Common.h +1 -1
  62. data/src/agent/Core/ApplicationPool/Context.h +1 -1
  63. data/src/agent/Core/ApplicationPool/Group/InitializationAndShutdown.cpp +1 -1
  64. data/src/agent/Core/ApplicationPool/Group/InternalUtils.cpp +1 -1
  65. data/src/agent/Core/ApplicationPool/Group/LifetimeAndBasics.cpp +1 -1
  66. data/src/agent/Core/ApplicationPool/Group/Miscellaneous.cpp +1 -1
  67. data/src/agent/Core/ApplicationPool/Group/OutOfBandWork.cpp +1 -1
  68. data/src/agent/Core/ApplicationPool/Group/ProcessListManagement.cpp +1 -1
  69. data/src/agent/Core/ApplicationPool/Group/SessionManagement.cpp +1 -1
  70. data/src/agent/Core/ApplicationPool/Group/SpawningAndRestarting.cpp +1 -1
  71. data/src/agent/Core/ApplicationPool/Group/StateInspection.cpp +1 -1
  72. data/src/agent/Core/ApplicationPool/Group/Verification.cpp +1 -1
  73. data/src/agent/Core/ApplicationPool/Group.h +1 -1
  74. data/src/agent/Core/ApplicationPool/Implementation.cpp +1 -1
  75. data/src/agent/Core/ApplicationPool/Options.h +1 -1
  76. data/src/agent/Core/ApplicationPool/Pool/AnalyticsCollection.cpp +1 -1
  77. data/src/agent/Core/ApplicationPool/Pool/GarbageCollection.cpp +1 -1
  78. data/src/agent/Core/ApplicationPool/Pool/GeneralUtils.cpp +1 -1
  79. data/src/agent/Core/ApplicationPool/Pool/GroupUtils.cpp +1 -1
  80. data/src/agent/Core/ApplicationPool/Pool/InitializationAndShutdown.cpp +1 -1
  81. data/src/agent/Core/ApplicationPool/Pool/Miscellaneous.cpp +1 -1
  82. data/src/agent/Core/ApplicationPool/Pool/ProcessUtils.cpp +1 -1
  83. data/src/agent/Core/ApplicationPool/Pool/StateInspection.cpp +1 -1
  84. data/src/agent/Core/ApplicationPool/Pool.h +1 -1
  85. data/src/agent/Core/ApplicationPool/Process.cpp +1 -1
  86. data/src/agent/Core/ApplicationPool/Process.h +1 -1
  87. data/src/agent/Core/ApplicationPool/Session.h +1 -1
  88. data/src/agent/Core/ApplicationPool/Socket.h +1 -1
  89. data/src/agent/Core/ApplicationPool/TestSession.h +1 -1
  90. data/src/agent/Core/Config.h +3 -2
  91. data/src/agent/Core/ConfigChange.cpp +1 -1
  92. data/src/agent/Core/ConfigChange.h +1 -1
  93. data/src/agent/Core/Controller/AppResponse.h +1 -1
  94. data/src/agent/Core/Controller/BufferBody.cpp +1 -1
  95. data/src/agent/Core/Controller/CheckoutSession.cpp +8 -5
  96. data/src/agent/Core/Controller/Client.h +1 -1
  97. data/src/agent/Core/Controller/Config.cpp +1 -1
  98. data/src/agent/Core/Controller/Config.h +2 -2
  99. data/src/agent/Core/Controller/ForwardResponse.cpp +2 -2
  100. data/src/agent/Core/Controller/Hooks.cpp +12 -9
  101. data/src/agent/Core/Controller/Implementation.cpp +1 -1
  102. data/src/agent/Core/Controller/InitRequest.cpp +1 -1
  103. data/src/agent/Core/Controller/InitializationAndShutdown.cpp +1 -1
  104. data/src/agent/Core/Controller/InternalUtils.cpp +1 -1
  105. data/src/agent/Core/Controller/Miscellaneous.cpp +1 -1
  106. data/src/agent/Core/Controller/Request.h +1 -1
  107. data/src/agent/Core/Controller/SendRequest.cpp +1 -1
  108. data/src/agent/Core/Controller/StateInspection.cpp +1 -1
  109. data/src/agent/Core/Controller/TurboCaching.h +1 -1
  110. data/src/agent/Core/Controller.h +1 -1
  111. data/src/agent/Core/CoreMain.cpp +1 -1
  112. data/src/agent/Core/OptionParser.h +1 -1
  113. data/src/agent/Core/ResponseCache.h +1 -1
  114. data/src/agent/Core/SecurityUpdateChecker.h +1 -1
  115. data/src/agent/Core/SpawningKit/Config/AutoGeneratedCode.h +1 -1
  116. data/src/agent/Core/SpawningKit/Config/AutoGeneratedCode.h.cxxcodebuilder +1 -1
  117. data/src/agent/Core/SpawningKit/Config.h +1 -1
  118. data/src/agent/Core/SpawningKit/Context.h +1 -1
  119. data/src/agent/Core/SpawningKit/DirectSpawner.h +1 -1
  120. data/src/agent/Core/SpawningKit/DummySpawner.h +1 -1
  121. data/src/agent/Core/SpawningKit/ErrorRenderer.h +1 -1
  122. data/src/agent/Core/SpawningKit/Exceptions.h +63 -2
  123. data/src/agent/Core/SpawningKit/Factory.h +1 -1
  124. data/src/agent/Core/SpawningKit/Handshake/BackgroundIOCapturer.h +1 -1
  125. data/src/agent/Core/SpawningKit/Handshake/Perform.h +3 -2
  126. data/src/agent/Core/SpawningKit/Handshake/Prepare.h +1 -1
  127. data/src/agent/Core/SpawningKit/Handshake/Session.h +1 -1
  128. data/src/agent/Core/SpawningKit/Handshake/WorkDir.h +1 -1
  129. data/src/agent/Core/SpawningKit/Journey.h +1 -1
  130. data/src/agent/Core/SpawningKit/PipeWatcher.h +1 -1
  131. data/src/agent/Core/SpawningKit/README.md +3 -3
  132. data/src/agent/Core/SpawningKit/Result/AutoGeneratedCode.h +1 -1
  133. data/src/agent/Core/SpawningKit/Result/AutoGeneratedCode.h.cxxcodebuilder +1 -1
  134. data/src/agent/Core/SpawningKit/Result.h +1 -1
  135. data/src/agent/Core/SpawningKit/SmartSpawner.h +17 -17
  136. data/src/agent/Core/SpawningKit/Spawner.h +1 -1
  137. data/src/agent/Core/SpawningKit/UserSwitchingRules.h +1 -1
  138. data/src/agent/Core/TelemetryCollector.h +1 -1
  139. data/src/agent/ExecHelper/ExecHelperMain.cpp +1 -1
  140. data/src/agent/FileReadHelper/FileReadHelperMain.cpp +1 -1
  141. data/src/agent/MainFunctions.h +1 -1
  142. data/src/agent/Shared/ApiAccountUtils.h +4 -3
  143. data/src/agent/Shared/ApiServerUtils.h +1 -2
  144. data/src/agent/Shared/ApplicationPoolApiKey.h +1 -1
  145. data/src/agent/Shared/Fundamentals/AbortHandler.cpp +1 -1
  146. data/src/agent/Shared/Fundamentals/AbortHandler.h +1 -1
  147. data/src/agent/Shared/Fundamentals/Initialization.cpp +1 -1
  148. data/src/agent/Shared/Fundamentals/Initialization.h +1 -1
  149. data/src/agent/Shared/Fundamentals/Utils.cpp +1 -1
  150. data/src/agent/Shared/Fundamentals/Utils.h +1 -1
  151. data/src/agent/SpawnEnvSetupper/SpawnEnvSetupperMain.cpp +1 -1
  152. data/src/agent/SystemMetrics/SystemMetricsMain.cpp +1 -1
  153. data/src/agent/TempDirToucher/TempDirToucherMain.cpp +1 -1
  154. data/src/agent/Watchdog/ApiServer.h +7 -6
  155. data/src/agent/Watchdog/Config.h +2 -2
  156. data/src/apache2_module/Bucket.cpp +1 -1
  157. data/src/apache2_module/Bucket.h +1 -1
  158. data/src/apache2_module/CBindings.cpp +1 -1
  159. data/src/apache2_module/Config.cpp +1 -1
  160. data/src/apache2_module/Config.h +1 -1
  161. data/src/apache2_module/ConfigGeneral/AutoGeneratedDefinitions.cpp +104 -104
  162. data/src/apache2_module/ConfigGeneral/AutoGeneratedDefinitions.cpp.cxxcodebuilder +2 -2
  163. data/src/apache2_module/ConfigGeneral/AutoGeneratedManifestDefaultsInitialization.cpp +1 -1
  164. data/src/apache2_module/ConfigGeneral/AutoGeneratedManifestDefaultsInitialization.cpp.cxxcodebuilder +1 -1
  165. data/src/apache2_module/ConfigGeneral/AutoGeneratedSetterFuncs.cpp +1 -1
  166. data/src/apache2_module/ConfigGeneral/AutoGeneratedSetterFuncs.cpp.cxxcodebuilder +1 -1
  167. data/src/apache2_module/ConfigGeneral/Common.h +1 -1
  168. data/src/apache2_module/ConfigGeneral/ManifestGeneration.h +1 -1
  169. data/src/apache2_module/ConfigGeneral/SetterFuncs.h +1 -1
  170. data/src/apache2_module/DirConfig/AutoGeneratedCreateFunction.cpp +1 -1
  171. data/src/apache2_module/DirConfig/AutoGeneratedCreateFunction.cpp.cxxcodebuilder +1 -1
  172. data/src/apache2_module/DirConfig/AutoGeneratedHeaderSerialization.cpp +1 -1
  173. data/src/apache2_module/DirConfig/AutoGeneratedHeaderSerialization.cpp.cxxcodebuilder +1 -1
  174. data/src/apache2_module/DirConfig/AutoGeneratedManifestGeneration.cpp +1 -1
  175. data/src/apache2_module/DirConfig/AutoGeneratedManifestGeneration.cpp.cxxcodebuilder +1 -1
  176. data/src/apache2_module/DirConfig/AutoGeneratedMergeFunction.cpp +1 -1
  177. data/src/apache2_module/DirConfig/AutoGeneratedMergeFunction.cpp.cxxcodebuilder +1 -1
  178. data/src/apache2_module/DirConfig/AutoGeneratedStruct.h +1 -1
  179. data/src/apache2_module/DirConfig/AutoGeneratedStruct.h.cxxcodebuilder +1 -1
  180. data/src/apache2_module/DirectoryMapper.h +1 -1
  181. data/src/apache2_module/Hooks.cpp +8 -2
  182. data/src/apache2_module/Hooks.h +1 -1
  183. data/src/apache2_module/ServerConfig/AutoGeneratedManifestGeneration.cpp +1 -1
  184. data/src/apache2_module/ServerConfig/AutoGeneratedManifestGeneration.cpp.cxxcodebuilder +1 -1
  185. data/src/apache2_module/ServerConfig/AutoGeneratedStruct.h +1 -1
  186. data/src/apache2_module/ServerConfig/AutoGeneratedStruct.h.cxxcodebuilder +1 -1
  187. data/src/apache2_module/Utils.h +1 -1
  188. data/src/apache2_module/mod_passenger.c +1 -1
  189. data/src/cxx_supportlib/Algorithms/Hasher.cpp +1 -1
  190. data/src/cxx_supportlib/Algorithms/Hasher.h +1 -1
  191. data/src/cxx_supportlib/Algorithms/MovingAverage.h +1 -1
  192. data/src/cxx_supportlib/AppLocalConfigFileUtils.h +1 -1
  193. data/src/cxx_supportlib/AppTypeDetector/CBindings.cpp +1 -1
  194. data/src/cxx_supportlib/AppTypeDetector/CBindings.h +1 -1
  195. data/src/cxx_supportlib/AppTypeDetector/Detector.h +1 -1
  196. data/src/cxx_supportlib/BackgroundEventLoop.cpp +1 -1
  197. data/src/cxx_supportlib/BackgroundEventLoop.h +1 -1
  198. data/src/cxx_supportlib/ConfigKit/AsyncUtils.h +1 -1
  199. data/src/cxx_supportlib/ConfigKit/Common.h +1 -1
  200. data/src/cxx_supportlib/ConfigKit/ConfigKit.h +1 -1
  201. data/src/cxx_supportlib/ConfigKit/DummyTranslator.h +1 -1
  202. data/src/cxx_supportlib/ConfigKit/IN_PRACTICE.md +1 -3
  203. data/src/cxx_supportlib/ConfigKit/PrefixTranslator.h +3 -3
  204. data/src/cxx_supportlib/ConfigKit/Schema.h +1 -1
  205. data/src/cxx_supportlib/ConfigKit/SchemaUtils.h +1 -1
  206. data/src/cxx_supportlib/ConfigKit/Store.h +1 -1
  207. data/src/cxx_supportlib/ConfigKit/SubComponentUtils.h +1 -1
  208. data/src/cxx_supportlib/ConfigKit/TableTranslator.h +1 -1
  209. data/src/cxx_supportlib/ConfigKit/Translator.h +1 -1
  210. data/src/cxx_supportlib/ConfigKit/Utils.h +1 -1
  211. data/src/cxx_supportlib/Constants.h +2 -2
  212. data/src/cxx_supportlib/Constants.h.cxxcodebuilder +1 -1
  213. data/src/cxx_supportlib/DataStructures/HashedStaticString.h +1 -1
  214. data/src/cxx_supportlib/DataStructures/LString.cpp +1 -1
  215. data/src/cxx_supportlib/DataStructures/LString.h +1 -1
  216. data/src/cxx_supportlib/DataStructures/StringKeyTable.h +1 -1
  217. data/src/cxx_supportlib/DataStructures/StringMap.h +1 -1
  218. data/src/cxx_supportlib/Exceptions.cpp +1 -1
  219. data/src/cxx_supportlib/Exceptions.h +1 -1
  220. data/src/cxx_supportlib/FileDescriptor.h +1 -1
  221. data/src/cxx_supportlib/FileTools/FileManip.cpp +1 -1
  222. data/src/cxx_supportlib/FileTools/FileManip.h +1 -1
  223. data/src/cxx_supportlib/FileTools/PathManip.cpp +1 -1
  224. data/src/cxx_supportlib/FileTools/PathManip.h +1 -1
  225. data/src/cxx_supportlib/FileTools/PathManipCBindings.cpp +1 -1
  226. data/src/cxx_supportlib/FileTools/PathManipCBindings.h +1 -1
  227. data/src/cxx_supportlib/FileTools/PathSecurityCheck.cpp +1 -1
  228. data/src/cxx_supportlib/FileTools/PathSecurityCheck.h +1 -1
  229. data/src/cxx_supportlib/Hooks.h +1 -1
  230. data/src/cxx_supportlib/IOTools/BufferedIO.h +1 -1
  231. data/src/cxx_supportlib/IOTools/IOUtils.cpp +10 -10
  232. data/src/cxx_supportlib/IOTools/IOUtils.h +1 -1
  233. data/src/cxx_supportlib/IOTools/MessageIO.h +1 -1
  234. data/src/cxx_supportlib/IOTools/MessageSerialization.h +1 -1
  235. data/src/cxx_supportlib/InstanceDirectory.h +1 -1
  236. data/src/cxx_supportlib/Integrations/LibevJsonUtils.h +1 -1
  237. data/src/cxx_supportlib/JsonTools/Autocast.h +1 -1
  238. data/src/cxx_supportlib/JsonTools/CBindings.cpp +1 -1
  239. data/src/cxx_supportlib/JsonTools/CBindings.h +1 -1
  240. data/src/cxx_supportlib/JsonTools/JsonUtils.h +1 -1
  241. data/src/cxx_supportlib/LoggingKit/Assert.h +1 -1
  242. data/src/cxx_supportlib/LoggingKit/Config.h +2 -1
  243. data/src/cxx_supportlib/LoggingKit/Context.h +1 -1
  244. data/src/cxx_supportlib/LoggingKit/Forward.h +1 -1
  245. data/src/cxx_supportlib/LoggingKit/Implementation.cpp +11 -1
  246. data/src/cxx_supportlib/LoggingKit/Logging.h +1 -1
  247. data/src/cxx_supportlib/LoggingKit/LoggingKit.h +1 -1
  248. data/src/cxx_supportlib/LveLoggingDecorator.h +1 -1
  249. data/src/cxx_supportlib/MemoryKit/mbuf.cpp +1 -1
  250. data/src/cxx_supportlib/MemoryKit/mbuf.h +1 -1
  251. data/src/cxx_supportlib/MemoryKit/palloc.cpp +1 -1
  252. data/src/cxx_supportlib/MemoryKit/palloc.h +1 -1
  253. data/src/cxx_supportlib/ProcessManagement/Ruby.cpp +1 -1
  254. data/src/cxx_supportlib/ProcessManagement/Ruby.h +1 -1
  255. data/src/cxx_supportlib/ProcessManagement/Spawn.cpp +1 -1
  256. data/src/cxx_supportlib/ProcessManagement/Spawn.h +1 -1
  257. data/src/cxx_supportlib/ProcessManagement/Utils.cpp +1 -1
  258. data/src/cxx_supportlib/ProcessManagement/Utils.h +1 -1
  259. data/src/cxx_supportlib/RandomGenerator.h +1 -1
  260. data/src/cxx_supportlib/ResourceLocator.h +1 -1
  261. data/src/cxx_supportlib/SafeLibev.h +1 -1
  262. data/src/cxx_supportlib/SecurityKit/Crypto.cpp +9 -27
  263. data/src/cxx_supportlib/SecurityKit/Crypto.h +2 -2
  264. data/src/cxx_supportlib/SecurityKit/MemZeroGuard.h +1 -1
  265. data/src/cxx_supportlib/ServerKit/AcceptLoadBalancer.h +1 -1
  266. data/src/cxx_supportlib/ServerKit/Channel.h +1 -1
  267. data/src/cxx_supportlib/ServerKit/Client.h +1 -1
  268. data/src/cxx_supportlib/ServerKit/ClientRef.h +1 -1
  269. data/src/cxx_supportlib/ServerKit/Config.h +1 -1
  270. data/src/cxx_supportlib/ServerKit/Context.h +1 -1
  271. data/src/cxx_supportlib/ServerKit/CookieUtils.h +1 -1
  272. data/src/cxx_supportlib/ServerKit/Errors.h +1 -1
  273. data/src/cxx_supportlib/ServerKit/FdSinkChannel.h +1 -1
  274. data/src/cxx_supportlib/ServerKit/FdSourceChannel.h +1 -1
  275. data/src/cxx_supportlib/ServerKit/FileBufferedChannel.h +54 -2
  276. data/src/cxx_supportlib/ServerKit/FileBufferedFdSinkChannel.h +1 -1
  277. data/src/cxx_supportlib/ServerKit/HeaderTable.h +1 -1
  278. data/src/cxx_supportlib/ServerKit/Hooks.h +1 -1
  279. data/src/cxx_supportlib/ServerKit/HttpChunkedBodyParser.h +1 -1
  280. data/src/cxx_supportlib/ServerKit/HttpChunkedBodyParserState.h +1 -1
  281. data/src/cxx_supportlib/ServerKit/HttpClient.h +1 -1
  282. data/src/cxx_supportlib/ServerKit/HttpHeaderParser.h +1 -1
  283. data/src/cxx_supportlib/ServerKit/HttpHeaderParserState.h +1 -1
  284. data/src/cxx_supportlib/ServerKit/HttpRequest.h +1 -1
  285. data/src/cxx_supportlib/ServerKit/HttpRequestRef.h +1 -1
  286. data/src/cxx_supportlib/ServerKit/HttpServer.h +1 -1
  287. data/src/cxx_supportlib/ServerKit/Implementation.cpp +1 -1
  288. data/src/cxx_supportlib/ServerKit/Server.h +4 -2
  289. data/src/cxx_supportlib/StaticString.h +1 -1
  290. data/src/cxx_supportlib/StrIntTools/DateParsing.h +1 -1
  291. data/src/cxx_supportlib/StrIntTools/StrIntUtils.cpp +1 -1
  292. data/src/cxx_supportlib/StrIntTools/StrIntUtils.h +1 -1
  293. data/src/cxx_supportlib/StrIntTools/StrIntUtilsNoStrictAliasing.cpp +1 -1
  294. data/src/cxx_supportlib/StrIntTools/StringScanning.h +1 -1
  295. data/src/cxx_supportlib/StrIntTools/Template.h +1 -1
  296. data/src/cxx_supportlib/SystemTools/ContainerHelpers.h +1 -1
  297. data/src/cxx_supportlib/SystemTools/ProcessMetricsCollector.h +1 -1
  298. data/src/cxx_supportlib/SystemTools/SystemMetricsCollector.h +1 -1
  299. data/src/cxx_supportlib/SystemTools/SystemTime.cpp +1 -1
  300. data/src/cxx_supportlib/SystemTools/SystemTime.h +1 -1
  301. data/src/cxx_supportlib/SystemTools/UserDatabase.cpp +1 -1
  302. data/src/cxx_supportlib/SystemTools/UserDatabase.h +1 -1
  303. data/src/cxx_supportlib/Utils/AnsiColorConstants.h +1 -1
  304. data/src/cxx_supportlib/Utils/AsyncSignalSafeUtils.h +1 -1
  305. data/src/cxx_supportlib/Utils/BlockingQueue.h +1 -1
  306. data/src/cxx_supportlib/Utils/CachedFileStat.cpp +1 -1
  307. data/src/cxx_supportlib/Utils/CachedFileStat.h +1 -1
  308. data/src/cxx_supportlib/Utils/CachedFileStat.hpp +1 -1
  309. data/src/cxx_supportlib/Utils/ClassUtils.h +1 -1
  310. data/src/cxx_supportlib/Utils/Curl.h +1 -1
  311. data/src/cxx_supportlib/Utils/FastStringStream.h +1 -1
  312. data/src/cxx_supportlib/Utils/FileChangeChecker.h +1 -1
  313. data/src/cxx_supportlib/Utils/HttpConstants.h +1 -1
  314. data/src/cxx_supportlib/Utils/IniFile.h +1 -1
  315. data/src/cxx_supportlib/Utils/MessagePassing.h +1 -1
  316. data/src/cxx_supportlib/Utils/OptionParsing.h +1 -1
  317. data/src/cxx_supportlib/Utils/ReleaseableScopedPointer.h +1 -1
  318. data/src/cxx_supportlib/Utils/ScopeGuard.h +1 -1
  319. data/src/cxx_supportlib/Utils/SpeedMeter.h +1 -1
  320. data/src/cxx_supportlib/Utils/Timer.h +1 -1
  321. data/src/cxx_supportlib/Utils/VariantMap.h +1 -1
  322. data/src/cxx_supportlib/Utils.cpp +1 -1
  323. data/src/cxx_supportlib/Utils.h +1 -1
  324. data/src/cxx_supportlib/WatchdogLauncher.cpp +1 -1
  325. data/src/cxx_supportlib/WatchdogLauncher.h +1 -1
  326. data/src/cxx_supportlib/WrapperRegistry/CBindings.cpp +1 -1
  327. data/src/cxx_supportlib/WrapperRegistry/CBindings.h +1 -1
  328. data/src/cxx_supportlib/WrapperRegistry/Entry.h +1 -1
  329. data/src/cxx_supportlib/WrapperRegistry/Registry.h +1 -1
  330. data/src/cxx_supportlib/oxt/backtrace.hpp +1 -1
  331. data/src/cxx_supportlib/oxt/detail/backtrace_disabled.hpp +1 -1
  332. data/src/cxx_supportlib/oxt/detail/backtrace_enabled.hpp +1 -1
  333. data/src/cxx_supportlib/oxt/detail/context.hpp +1 -1
  334. data/src/cxx_supportlib/oxt/detail/tracable_exception_disabled.hpp +1 -1
  335. data/src/cxx_supportlib/oxt/detail/tracable_exception_enabled.hpp +1 -1
  336. data/src/cxx_supportlib/oxt/dynamic_thread_group.hpp +1 -1
  337. data/src/cxx_supportlib/oxt/implementation.cpp +1 -1
  338. data/src/cxx_supportlib/oxt/initialize.hpp +1 -1
  339. data/src/cxx_supportlib/oxt/macros.hpp +1 -1
  340. data/src/cxx_supportlib/oxt/spin_lock.hpp +1 -1
  341. data/src/cxx_supportlib/oxt/system_calls.cpp +1 -1
  342. data/src/cxx_supportlib/oxt/system_calls.hpp +1 -1
  343. data/src/cxx_supportlib/oxt/thread.hpp +1 -1
  344. data/src/cxx_supportlib/oxt/tracable_exception.hpp +1 -1
  345. data/src/cxx_supportlib/vendor-copy/adhoc_lve.h +1 -1
  346. data/src/cxx_supportlib/vendor-copy/libuv/AUTHORS +353 -3
  347. data/src/cxx_supportlib/vendor-copy/libuv/ChangeLog +3981 -2
  348. data/src/cxx_supportlib/vendor-copy/libuv/LICENSE +1 -28
  349. data/src/cxx_supportlib/vendor-copy/libuv/LICENSE-docs +396 -0
  350. data/src/cxx_supportlib/vendor-copy/libuv/LICENSE-extra +36 -0
  351. data/src/cxx_supportlib/vendor-copy/libuv/Makefile.am +275 -58
  352. data/src/cxx_supportlib/vendor-copy/libuv/Makefile.in +4380 -2125
  353. data/src/cxx_supportlib/vendor-copy/libuv/aclocal.m4 +425 -221
  354. data/src/cxx_supportlib/vendor-copy/libuv/ar-lib +30 -10
  355. data/src/cxx_supportlib/vendor-copy/libuv/compile +31 -14
  356. data/src/cxx_supportlib/vendor-copy/libuv/config.guess +1084 -690
  357. data/src/cxx_supportlib/vendor-copy/libuv/config.sub +1844 -1297
  358. data/src/cxx_supportlib/vendor-copy/libuv/configure +6935 -3664
  359. data/src/cxx_supportlib/vendor-copy/libuv/configure.ac +43 -19
  360. data/src/cxx_supportlib/vendor-copy/libuv/depcomp +12 -11
  361. data/src/cxx_supportlib/vendor-copy/libuv/include/{uv-darwin.h → uv/darwin.h} +3 -3
  362. data/src/cxx_supportlib/vendor-copy/libuv/include/{uv-errno.h → uv/errno.h} +119 -60
  363. data/src/cxx_supportlib/vendor-copy/libuv/include/{uv-linux.h → uv/linux.h} +1 -1
  364. data/src/cxx_supportlib/vendor-copy/libuv/include/uv/os390.h +33 -0
  365. data/src/cxx_supportlib/vendor-copy/libuv/include/uv/posix.h +31 -0
  366. data/src/cxx_supportlib/vendor-copy/libuv/include/{uv-threadpool.h → uv/threadpool.h} +1 -1
  367. data/src/cxx_supportlib/vendor-copy/libuv/include/{tree.h → uv/tree.h} +3 -250
  368. data/src/cxx_supportlib/vendor-copy/libuv/include/{uv-unix.h → uv/unix.h} +186 -60
  369. data/src/cxx_supportlib/vendor-copy/libuv/include/{uv-version.h → uv/version.h} +3 -3
  370. data/src/cxx_supportlib/vendor-copy/libuv/include/uv/win.h +703 -0
  371. data/src/cxx_supportlib/vendor-copy/libuv/include/uv.h +528 -40
  372. data/src/cxx_supportlib/vendor-copy/libuv/install-sh +110 -70
  373. data/src/cxx_supportlib/vendor-copy/libuv/libuv-static.pc.in +12 -0
  374. data/src/cxx_supportlib/vendor-copy/libuv/libuv.pc.in +4 -2
  375. data/src/cxx_supportlib/vendor-copy/libuv/ltmain.sh +995 -619
  376. data/src/cxx_supportlib/vendor-copy/libuv/m4/ax_pthread.m4 +485 -0
  377. data/src/cxx_supportlib/vendor-copy/libuv/m4/libtool.m4 +438 -289
  378. data/src/cxx_supportlib/vendor-copy/libuv/m4/libuv-check-flags.m4 +21 -4
  379. data/src/cxx_supportlib/vendor-copy/libuv/m4/libuv-check-versions.m4 +7 -0
  380. data/src/cxx_supportlib/vendor-copy/libuv/m4/ltoptions.m4 +69 -39
  381. data/src/cxx_supportlib/vendor-copy/libuv/m4/ltsugar.m4 +1 -1
  382. data/src/cxx_supportlib/vendor-copy/libuv/m4/ltversion.m4 +7 -6
  383. data/src/cxx_supportlib/vendor-copy/libuv/m4/lt~obsolete.m4 +2 -2
  384. data/src/cxx_supportlib/vendor-copy/libuv/missing +55 -34
  385. data/src/cxx_supportlib/vendor-copy/libuv/src/fs-poll.c +52 -20
  386. data/src/cxx_supportlib/vendor-copy/libuv/src/idna.c +560 -0
  387. data/src/cxx_supportlib/vendor-copy/libuv/src/idna.h +31 -0
  388. data/src/cxx_supportlib/vendor-copy/libuv/src/inet.c +5 -16
  389. data/src/cxx_supportlib/vendor-copy/libuv/src/queue.h +68 -86
  390. data/src/cxx_supportlib/vendor-copy/libuv/src/random.c +123 -0
  391. data/src/cxx_supportlib/vendor-copy/libuv/src/strscpy.c +38 -0
  392. data/src/cxx_supportlib/vendor-copy/libuv/src/strscpy.h +39 -0
  393. data/src/cxx_supportlib/vendor-copy/libuv/src/strtok.c +52 -0
  394. data/src/cxx_supportlib/vendor-copy/libuv/src/strtok.h +27 -0
  395. data/src/cxx_supportlib/vendor-copy/libuv/src/thread-common.c +175 -0
  396. data/src/cxx_supportlib/vendor-copy/libuv/src/threadpool.c +172 -57
  397. data/src/cxx_supportlib/vendor-copy/libuv/src/{unix/timer.c → timer.c} +57 -29
  398. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/aix-common.c +89 -0
  399. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/aix.c +418 -256
  400. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/async.c +168 -129
  401. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/bsd-ifaddrs.c +163 -0
  402. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/bsd-proctitle.c +99 -0
  403. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/core.c +1312 -378
  404. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/cygwin.c +93 -0
  405. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/darwin-proctitle.c +18 -32
  406. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/darwin-stub.h +97 -0
  407. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/darwin-syscalls.h +17 -0
  408. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/darwin.c +41 -139
  409. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/dl.c +1 -1
  410. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/freebsd.c +75 -235
  411. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/fs.c +1308 -299
  412. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/fsevents.c +150 -148
  413. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/getaddrinfo.c +58 -8
  414. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/getnameinfo.c +3 -2
  415. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/haiku.c +172 -0
  416. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/hurd.c +172 -0
  417. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/ibmi.c +542 -0
  418. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/internal.h +297 -106
  419. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/kqueue.c +325 -94
  420. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/linux.c +2708 -0
  421. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/loop-watcher.c +11 -11
  422. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/loop.c +105 -24
  423. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/netbsd.c +51 -157
  424. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/no-fsevents.c +42 -0
  425. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/no-proctitle.c +45 -0
  426. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/openbsd.c +42 -183
  427. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/os390-proctitle.c +136 -0
  428. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/os390-syscalls.c +536 -0
  429. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/os390-syscalls.h +75 -0
  430. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/os390.c +1070 -0
  431. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/pipe.c +324 -55
  432. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/poll.c +58 -11
  433. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/posix-hrtime.c +36 -0
  434. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/posix-poll.c +385 -0
  435. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/process.c +795 -248
  436. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/procfs-exepath.c +45 -0
  437. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/proctitle.c +77 -22
  438. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/qnx.c +142 -0
  439. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/random-devurandom.c +93 -0
  440. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/random-getentropy.c +57 -0
  441. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/random-getrandom.c +86 -0
  442. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/random-sysctl-linux.c +99 -0
  443. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/signal.c +147 -39
  444. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/stream.c +426 -474
  445. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/sunos.c +240 -98
  446. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/sysinfo-loadavg.c +36 -0
  447. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/sysinfo-memory.c +42 -0
  448. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/tcp.c +402 -91
  449. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/thread.c +497 -145
  450. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/tty.c +269 -45
  451. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/udp.c +695 -165
  452. data/src/cxx_supportlib/vendor-copy/libuv/src/uv-common.c +463 -61
  453. data/src/cxx_supportlib/vendor-copy/libuv/src/uv-common.h +248 -44
  454. data/src/cxx_supportlib/vendor-copy/libuv/src/uv-data-getter-setters.c +119 -0
  455. data/src/cxx_supportlib/vendor-copy/libuv/tsansupp.txt +2 -0
  456. data/src/cxx_supportlib/vendor-modified/libev/Changes +109 -0
  457. data/src/cxx_supportlib/vendor-modified/libev/Makefile.am +2 -1
  458. data/src/cxx_supportlib/vendor-modified/libev/Makefile.in +47 -33
  459. data/src/cxx_supportlib/vendor-modified/libev/README +2 -1
  460. data/src/cxx_supportlib/vendor-modified/libev/aclocal.m4 +1653 -1224
  461. data/src/cxx_supportlib/vendor-modified/libev/config.guess +376 -316
  462. data/src/cxx_supportlib/vendor-modified/libev/config.h.in +13 -2
  463. data/src/cxx_supportlib/vendor-modified/libev/config.sub +156 -154
  464. data/src/cxx_supportlib/vendor-modified/libev/configure +1431 -940
  465. data/src/cxx_supportlib/vendor-modified/libev/configure.ac +3 -3
  466. data/src/cxx_supportlib/vendor-modified/libev/depcomp +5 -5
  467. data/src/cxx_supportlib/vendor-modified/libev/ev++.h +109 -107
  468. data/src/cxx_supportlib/vendor-modified/libev/ev.c +807 -319
  469. data/src/cxx_supportlib/vendor-modified/libev/ev.h +111 -105
  470. data/src/cxx_supportlib/vendor-modified/libev/ev_epoll.c +42 -29
  471. data/src/cxx_supportlib/vendor-modified/libev/ev_iouring.c +694 -0
  472. data/src/cxx_supportlib/vendor-modified/libev/ev_kqueue.c +15 -9
  473. data/src/cxx_supportlib/vendor-modified/libev/ev_linuxaio.c +620 -0
  474. data/src/cxx_supportlib/vendor-modified/libev/ev_poll.c +19 -14
  475. data/src/cxx_supportlib/vendor-modified/libev/ev_port.c +8 -5
  476. data/src/cxx_supportlib/vendor-modified/libev/ev_select.c +6 -6
  477. data/src/cxx_supportlib/vendor-modified/libev/ev_vars.h +48 -3
  478. data/src/cxx_supportlib/vendor-modified/libev/ev_win32.c +2 -2
  479. data/src/cxx_supportlib/vendor-modified/libev/ev_wrap.h +72 -0
  480. data/src/cxx_supportlib/vendor-modified/libev/install-sh +23 -13
  481. data/src/cxx_supportlib/vendor-modified/libev/libev.m4 +6 -1
  482. data/src/cxx_supportlib/vendor-modified/libev/ltmain.sh +3581 -1993
  483. data/src/cxx_supportlib/vendor-modified/libev/missing +8 -8
  484. data/src/cxx_supportlib/vendor-modified/libev/mkinstalldirs +3 -3
  485. data/src/cxx_supportlib/vendor-modified/modp_b64_strict_aliasing.cpp +1 -1
  486. data/src/helper-scripts/backtrace-sanitizer.rb +1 -1
  487. data/src/helper-scripts/crash-watch.rb +1 -1
  488. data/src/helper-scripts/download_binaries/extconf.rb +1 -1
  489. data/src/helper-scripts/meteor-loader.rb +1 -1
  490. data/src/helper-scripts/node-loader.js +1 -1
  491. data/src/helper-scripts/prespawn +1 -1
  492. data/src/helper-scripts/rack-loader.rb +1 -1
  493. data/src/helper-scripts/rack-preloader.rb +1 -1
  494. data/src/helper-scripts/wsgi-loader.py +1 -1
  495. data/src/nginx_module/ConfigGeneral/AutoGeneratedDefinitions.c +1 -1
  496. data/src/nginx_module/ConfigGeneral/AutoGeneratedDefinitions.c.cxxcodebuilder +1 -1
  497. data/src/nginx_module/ConfigGeneral/AutoGeneratedManifestDefaultsInitialization.c +1 -1
  498. data/src/nginx_module/ConfigGeneral/AutoGeneratedManifestDefaultsInitialization.c.cxxcodebuilder +1 -1
  499. data/src/nginx_module/ConfigGeneral/AutoGeneratedSetterFuncs.c +1 -1
  500. data/src/nginx_module/ConfigGeneral/AutoGeneratedSetterFuncs.c.cxxcodebuilder +1 -1
  501. data/src/nginx_module/Configuration.c +1 -1
  502. data/src/nginx_module/Configuration.h +1 -1
  503. data/src/nginx_module/ContentHandler.c +1 -1
  504. data/src/nginx_module/ContentHandler.h +1 -1
  505. data/src/nginx_module/LocationConfig/AutoGeneratedCreateFunction.c +1 -1
  506. data/src/nginx_module/LocationConfig/AutoGeneratedCreateFunction.c.cxxcodebuilder +1 -1
  507. data/src/nginx_module/LocationConfig/AutoGeneratedHeaderSerialization.c +1 -1
  508. data/src/nginx_module/LocationConfig/AutoGeneratedHeaderSerialization.c.cxxcodebuilder +1 -1
  509. data/src/nginx_module/LocationConfig/AutoGeneratedManifestGeneration.c +1 -1
  510. data/src/nginx_module/LocationConfig/AutoGeneratedManifestGeneration.c.cxxcodebuilder +1 -1
  511. data/src/nginx_module/LocationConfig/AutoGeneratedMergeFunction.c +1 -1
  512. data/src/nginx_module/LocationConfig/AutoGeneratedMergeFunction.c.cxxcodebuilder +1 -1
  513. data/src/nginx_module/LocationConfig/AutoGeneratedStruct.h +1 -1
  514. data/src/nginx_module/LocationConfig/AutoGeneratedStruct.h.cxxcodebuilder +1 -1
  515. data/src/nginx_module/MainConfig/AutoGeneratedCreateFunction.c +1 -1
  516. data/src/nginx_module/MainConfig/AutoGeneratedCreateFunction.c.cxxcodebuilder +1 -1
  517. data/src/nginx_module/MainConfig/AutoGeneratedManifestGeneration.c +1 -1
  518. data/src/nginx_module/MainConfig/AutoGeneratedManifestGeneration.c.cxxcodebuilder +1 -1
  519. data/src/nginx_module/MainConfig/AutoGeneratedStruct.h +1 -1
  520. data/src/nginx_module/MainConfig/AutoGeneratedStruct.h.cxxcodebuilder +1 -1
  521. data/src/nginx_module/StaticContentHandler.c +1 -1
  522. data/src/nginx_module/StaticContentHandler.h +1 -1
  523. data/src/nginx_module/ngx_http_passenger_module.c +1 -1
  524. data/src/nginx_module/ngx_http_passenger_module.h +1 -1
  525. data/src/nodejs_supportlib/phusion_passenger/line_reader.js +1 -1
  526. data/src/ruby_native_extension/extconf.rb +1 -1
  527. data/src/ruby_native_extension/passenger_native_support.c +1 -1
  528. data/src/ruby_supportlib/phusion_passenger/abstract_installer.rb +1 -1
  529. data/src/ruby_supportlib/phusion_passenger/admin_tools/instance.rb +1 -1
  530. data/src/ruby_supportlib/phusion_passenger/admin_tools/instance_registry.rb +1 -1
  531. data/src/ruby_supportlib/phusion_passenger/admin_tools/memory_stats.rb +2 -12
  532. data/src/ruby_supportlib/phusion_passenger/admin_tools.rb +1 -1
  533. data/src/ruby_supportlib/phusion_passenger/apache2/config_options.rb +1 -1
  534. data/src/ruby_supportlib/phusion_passenger/apache2/config_utils.rb +1 -1
  535. data/src/ruby_supportlib/phusion_passenger/common_library.rb +8 -10
  536. data/src/ruby_supportlib/phusion_passenger/config/about_command.rb +1 -1
  537. data/src/ruby_supportlib/phusion_passenger/config/agent_compiler.rb +1 -1
  538. data/src/ruby_supportlib/phusion_passenger/config/api_call_command.rb +1 -1
  539. data/src/ruby_supportlib/phusion_passenger/config/build_native_support_command.rb +1 -1
  540. data/src/ruby_supportlib/phusion_passenger/config/command.rb +1 -1
  541. data/src/ruby_supportlib/phusion_passenger/config/compile_agent_command.rb +1 -1
  542. data/src/ruby_supportlib/phusion_passenger/config/compile_nginx_engine_command.rb +1 -1
  543. data/src/ruby_supportlib/phusion_passenger/config/detach_process_command.rb +1 -1
  544. data/src/ruby_supportlib/phusion_passenger/config/download_agent_command.rb +1 -1
  545. data/src/ruby_supportlib/phusion_passenger/config/download_nginx_engine_command.rb +1 -1
  546. data/src/ruby_supportlib/phusion_passenger/config/install_agent_command.rb +1 -1
  547. data/src/ruby_supportlib/phusion_passenger/config/install_standalone_runtime_command.rb +1 -1
  548. data/src/ruby_supportlib/phusion_passenger/config/installation_utils.rb +1 -1
  549. data/src/ruby_supportlib/phusion_passenger/config/list_instances_command.rb +1 -1
  550. data/src/ruby_supportlib/phusion_passenger/config/main.rb +1 -1
  551. data/src/ruby_supportlib/phusion_passenger/config/nginx_engine_compiler.rb +3 -2
  552. data/src/ruby_supportlib/phusion_passenger/config/reopen_logs_command.rb +6 -1
  553. data/src/ruby_supportlib/phusion_passenger/config/restart_app_command.rb +1 -1
  554. data/src/ruby_supportlib/phusion_passenger/config/system_metrics_command.rb +1 -1
  555. data/src/ruby_supportlib/phusion_passenger/config/system_properties_command.rb +1 -1
  556. data/src/ruby_supportlib/phusion_passenger/config/utils.rb +1 -1
  557. data/src/ruby_supportlib/phusion_passenger/config/validate_install_command.rb +1 -1
  558. data/src/ruby_supportlib/phusion_passenger/console_text_template.rb +1 -1
  559. data/src/ruby_supportlib/phusion_passenger/constants.rb +1 -1
  560. data/src/ruby_supportlib/phusion_passenger/debug_logging.rb +1 -1
  561. data/src/ruby_supportlib/phusion_passenger/loader_shared_helpers.rb +1 -1
  562. data/src/ruby_supportlib/phusion_passenger/message_channel.rb +1 -1
  563. data/src/ruby_supportlib/phusion_passenger/message_client.rb +1 -1
  564. data/src/ruby_supportlib/phusion_passenger/native_support.rb +1 -1
  565. data/src/ruby_supportlib/phusion_passenger/nginx/config_options.rb +1 -1
  566. data/src/ruby_supportlib/phusion_passenger/packaging.rb +4 -3
  567. data/src/ruby_supportlib/phusion_passenger/platform_info/apache.rb +1 -1
  568. data/src/ruby_supportlib/phusion_passenger/platform_info/apache_detector.rb +1 -1
  569. data/src/ruby_supportlib/phusion_passenger/platform_info/binary_compatibility.rb +1 -1
  570. data/src/ruby_supportlib/phusion_passenger/platform_info/compiler.rb +195 -11
  571. data/src/ruby_supportlib/phusion_passenger/platform_info/crypto.rb +1 -1
  572. data/src/ruby_supportlib/phusion_passenger/platform_info/curl.rb +1 -1
  573. data/src/ruby_supportlib/phusion_passenger/platform_info/cxx_portability.rb +1 -1
  574. data/src/ruby_supportlib/phusion_passenger/platform_info/linux.rb +1 -1
  575. data/src/ruby_supportlib/phusion_passenger/platform_info/networking.rb +1 -1
  576. data/src/ruby_supportlib/phusion_passenger/platform_info/openssl.rb +1 -1
  577. data/src/ruby_supportlib/phusion_passenger/platform_info/operating_system.rb +1 -1
  578. data/src/ruby_supportlib/phusion_passenger/platform_info/pcre.rb +1 -1
  579. data/src/ruby_supportlib/phusion_passenger/platform_info/ruby.rb +1 -1
  580. data/src/ruby_supportlib/phusion_passenger/platform_info/zlib.rb +1 -1
  581. data/src/ruby_supportlib/phusion_passenger/platform_info.rb +1 -1
  582. data/src/ruby_supportlib/phusion_passenger/plugin.rb +1 -1
  583. data/src/ruby_supportlib/phusion_passenger/preloader_shared_helpers.rb +1 -1
  584. data/src/ruby_supportlib/phusion_passenger/public_api.rb +1 -1
  585. data/src/ruby_supportlib/phusion_passenger/rack/handler.rb +1 -1
  586. data/src/ruby_supportlib/phusion_passenger/rack/out_of_band_gc.rb +1 -1
  587. data/src/ruby_supportlib/phusion_passenger/rack/thread_handler_extension.rb +1 -1
  588. data/src/ruby_supportlib/phusion_passenger/rack_handler.rb +1 -1
  589. data/src/ruby_supportlib/phusion_passenger/request_handler/thread_handler.rb +2 -7
  590. data/src/ruby_supportlib/phusion_passenger/request_handler.rb +1 -1
  591. data/src/ruby_supportlib/phusion_passenger/ruby_core_enhancements.rb +1 -1
  592. data/src/ruby_supportlib/phusion_passenger/ruby_core_io_enhancements.rb +1 -1
  593. data/src/ruby_supportlib/phusion_passenger/simple_benchmarking.rb +1 -1
  594. data/src/ruby_supportlib/phusion_passenger/standalone/app_finder.rb +1 -1
  595. data/src/ruby_supportlib/phusion_passenger/standalone/command.rb +1 -1
  596. data/src/ruby_supportlib/phusion_passenger/standalone/config_options_list.rb +1 -1
  597. data/src/ruby_supportlib/phusion_passenger/standalone/config_utils.rb +1 -1
  598. data/src/ruby_supportlib/phusion_passenger/standalone/control_utils.rb +1 -1
  599. data/src/ruby_supportlib/phusion_passenger/standalone/main.rb +1 -1
  600. data/src/ruby_supportlib/phusion_passenger/standalone/start_command/builtin_engine.rb +2 -2
  601. data/src/ruby_supportlib/phusion_passenger/standalone/start_command/nginx_engine.rb +4 -8
  602. data/src/ruby_supportlib/phusion_passenger/standalone/start_command.rb +1 -1
  603. data/src/ruby_supportlib/phusion_passenger/standalone/status_command.rb +1 -1
  604. data/src/ruby_supportlib/phusion_passenger/standalone/stop_command.rb +1 -1
  605. data/src/ruby_supportlib/phusion_passenger/standalone/version_command.rb +1 -1
  606. data/src/ruby_supportlib/phusion_passenger/utils/ansi_colors.rb +1 -1
  607. data/src/ruby_supportlib/phusion_passenger/utils/download.rb +1 -1
  608. data/src/ruby_supportlib/phusion_passenger/utils/file_system_watcher.rb +1 -1
  609. data/src/ruby_supportlib/phusion_passenger/utils/hosts_file_parser.rb +1 -1
  610. data/src/ruby_supportlib/phusion_passenger/utils/lock.rb +1 -1
  611. data/src/ruby_supportlib/phusion_passenger/utils/native_support_utils.rb +1 -1
  612. data/src/ruby_supportlib/phusion_passenger/utils/progress_bar.rb +1 -1
  613. data/src/ruby_supportlib/phusion_passenger/utils/strscan.rb +1 -1
  614. data/src/ruby_supportlib/phusion_passenger/utils/terminal_choice_menu.rb +1 -1
  615. data/src/ruby_supportlib/phusion_passenger/utils/unseekable_socket.rb +3 -13
  616. data/src/ruby_supportlib/phusion_passenger/utils.rb +1 -1
  617. data/src/ruby_supportlib/phusion_passenger/vendor/crash_watch/app.rb +1 -1
  618. data/src/ruby_supportlib/phusion_passenger/vendor/crash_watch/base.rb +1 -1
  619. data/src/ruby_supportlib/phusion_passenger/vendor/crash_watch/gdb_controller.rb +1 -1
  620. data/src/ruby_supportlib/phusion_passenger/vendor/crash_watch/lldb_controller.rb +1 -1
  621. data/src/ruby_supportlib/phusion_passenger/vendor/crash_watch/utils.rb +1 -1
  622. data/src/ruby_supportlib/phusion_passenger/vendor/crash_watch/version.rb +1 -1
  623. data/src/ruby_supportlib/phusion_passenger/vendor/daemon_controller/lock_file.rb +8 -6
  624. data/src/ruby_supportlib/phusion_passenger/vendor/daemon_controller/spawn.rb +4 -3
  625. data/src/ruby_supportlib/phusion_passenger/vendor/daemon_controller/version.rb +6 -4
  626. data/src/ruby_supportlib/phusion_passenger/vendor/daemon_controller.rb +395 -579
  627. data/src/ruby_supportlib/phusion_passenger.rb +8 -8
  628. data/src/schema_printer/SchemaPrinterMain.cpp +1 -1
  629. data/src/schema_printer/SchemaPrinterMain.cpp.cxxcodebuilder +1 -1
  630. metadata +69 -32
  631. data/doc/DeveloperQuickstart.md +0 -70
  632. data/src/README.md +0 -7
  633. data/src/cxx_supportlib/vendor-copy/libuv/README.md +0 -245
  634. data/src/cxx_supportlib/vendor-copy/libuv/checksparse.sh +0 -234
  635. data/src/cxx_supportlib/vendor-copy/libuv/common.gypi +0 -210
  636. data/src/cxx_supportlib/vendor-copy/libuv/gyp_uv.py +0 -93
  637. data/src/cxx_supportlib/vendor-copy/libuv/include/android-ifaddrs.h +0 -54
  638. data/src/cxx_supportlib/vendor-copy/libuv/include/pthread-fixes.h +0 -72
  639. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/android-ifaddrs.c +0 -703
  640. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/atomic-ops.h +0 -77
  641. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/linux-core.c +0 -899
  642. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/linux-inotify.c +0 -285
  643. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/linux-syscalls.c +0 -471
  644. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/linux-syscalls.h +0 -158
  645. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/pthread-fixes.c +0 -104
  646. data/src/cxx_supportlib/vendor-copy/libuv/src/unix/spinlock.h +0 -53
  647. data/src/cxx_supportlib/vendor-copy/libuv/uv.gyp +0 -508
  648. /data/src/cxx_supportlib/vendor-copy/libuv/include/{uv-aix.h → uv/aix.h} +0 -0
  649. /data/src/cxx_supportlib/vendor-copy/libuv/include/{uv-bsd.h → uv/bsd.h} +0 -0
  650. /data/src/cxx_supportlib/vendor-copy/libuv/include/{uv-sunos.h → uv/sunos.h} +0 -0
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # daemon_controller, library for robust daemon management
2
- # Copyright (c) 2010-2025 Asynchronous B.V.
4
+ # Copyright (c) 2010-2026 Asynchronous B.V.
3
5
  #
4
6
  # Permission is hereby granted, free of charge, to any person obtaining a copy
5
7
  # of this software and associated documentation files (the "Software"), to deal
@@ -19,16 +21,14 @@
19
21
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
22
  # THE SOFTWARE.
21
23
 
22
- require 'tempfile'
23
- require 'fcntl'
24
- require 'socket'
25
- require 'pathname'
26
- require 'timeout'
27
- if Process.respond_to?(:spawn)
28
- require 'rbconfig'
29
- end
24
+ require "tempfile"
25
+ require "fcntl"
26
+ require "socket"
27
+ require "pathname"
28
+ require "timeout"
29
+ require "rbconfig"
30
30
 
31
- PhusionPassenger.require_passenger_lib 'vendor/daemon_controller/lock_file'
31
+ require_relative "daemon_controller/lock_file"
32
32
 
33
33
  module PhusionPassenger
34
34
 
@@ -38,184 +38,66 @@ class DaemonController
38
38
  Errno::ETIMEDOUT, Errno::ECONNRESET, Errno::EINVAL,
39
39
  Errno::EADDRNOTAVAIL ]
40
40
 
41
- SPAWNER_FILE = File.expand_path(File.join(File.dirname(__FILE__),
41
+ SPAWNER_FILE = File.absolute_path(File.join(File.dirname(__FILE__),
42
42
  "daemon_controller", "spawn.rb"))
43
43
 
44
44
  class Error < StandardError
45
45
  end
46
+
46
47
  class TimeoutError < Error
47
48
  end
49
+
48
50
  class AlreadyStarted < Error
49
51
  end
52
+
50
53
  class StartError < Error
51
54
  end
55
+
52
56
  class StartTimeout < TimeoutError
53
57
  end
58
+
54
59
  class StopError < Error
55
60
  end
61
+
56
62
  class StopTimeout < TimeoutError
57
63
  end
64
+
58
65
  class ConnectError < Error
59
66
  end
60
- class DaemonizationTimeout < TimeoutError
61
- end
67
+
68
+ InternalCommandOkResult = Struct.new(:pid, :output)
69
+ InternalCommandErrorResult = Struct.new(:pid, :output, :exit_status)
70
+ InternalCommandTimeoutResult = Struct.new(:pid, :output)
62
71
 
63
72
  # Create a new DaemonController object.
64
73
  #
65
- # === Mandatory options
66
- #
67
- # [:identifier]
68
- # A human-readable, unique name for this daemon, e.g. "Sphinx search server".
69
- # This identifier will be used in some error messages. On some platforms, it will
70
- # be used for concurrency control: on such platforms, no two DaemonController
71
- # objects will operate on the same identifier on the same time.
72
- #
73
- # [:start_command]
74
- # The command to start the daemon. This must be a a String, e.g.
75
- # "mongrel_rails start -e production", or a Proc which returns a String.
76
- #
77
- # If the value is a Proc, and the +before_start+ option is given too, then
78
- # the +start_command+ Proc is guaranteed to be called after the +before_start+
79
- # Proc is called.
80
- #
81
- # [:ping_command]
82
- # The ping command is used to check whether the daemon can be connected to.
83
- # It is also used to ensure that #start only returns when the daemon can be
84
- # connected to.
85
- #
86
- # The value may be a command string. This command must exit with an exit code of
87
- # 0 if the daemon can be successfully connected to, or exit with a non-0 exit
88
- # code on failure.
89
- #
90
- # The value may also be an Array which specifies the socket address of the daemon.
91
- # It must be in one of the following forms:
92
- # - [:tcp, host_name, port]
93
- # - [:unix, filename]
94
- #
95
- # The value may also be a Proc, which returns an expression that evaluates to
96
- # true (indicating that the daemon can be connected to) or false (failure).
97
- # If the Proc raises Errno::ECONNREFUSED, Errno::ENETUNREACH, Errno::ETIMEDOUT
98
- # Errno::ECONNRESET, Errno::EINVAL or Errno::EADDRNOTAVAIL then that also
99
- # means that the daemon cannot be connected to.
100
- # <b>NOTE:</b> if the ping command returns an object which responds to
101
- # <tt>#close</tt>, then that method will be called on it.
102
- # This makes it possible to specify a ping command such as
103
- # <tt>lambda { TCPSocket.new('localhost', 1234) }</tt>, without having to worry
104
- # about closing it afterwards.
105
- # Any exceptions raised by #close are ignored.
106
- #
107
- # [:pid_file]
108
- # The PID file that the daemon will write to. Used to check whether the daemon
109
- # is running.
110
- #
111
- # [:lock_file]
112
- # The lock file to use for serializing concurrent daemon management operations.
113
- # Defaults to "(filename of PID file).lock".
114
- #
115
- # [:log_file]
116
- # The log file that the daemon will write to. It will be consulted to see
117
- # whether the daemon has printed any error messages during startup.
118
- #
119
- # === Optional options
120
- # [:stop_command]
121
- # A command to stop the daemon with, e.g. "/etc/rc.d/nginx stop". If no stop
122
- # command is given (i.e. +nil+), then DaemonController will stop the daemon
123
- # by killing the PID written in the PID file.
124
- #
125
- # The default value is +nil+.
126
- #
127
- # [:restart_command]
128
- # A command to restart the daemon with, e.g. "/etc/rc.d/nginx restart". If
129
- # no restart command is given (i.e. +nil+), then DaemonController will
130
- # restart the daemon by calling #stop and #start.
131
- #
132
- # The default value is +nil+.
133
- #
134
- # [:before_start]
135
- # This may be a Proc. It will be called just before running the start command.
136
- # The before_start proc is not subject to the start timeout.
137
- #
138
- # [:start_timeout]
139
- # The maximum amount of time, in seconds, that #start may take to start
140
- # the daemon. Since #start also waits until the daemon can be connected to,
141
- # that wait time is counted as well. If the daemon does not start in time,
142
- # then #start will raise an exception.
143
- #
144
- # The default value is 15.
145
- #
146
- # [:stop_timeout]
147
- # The maximum amount of time, in seconds, that #stop may take to stop
148
- # the daemon. Since #stop also waits until the daemon is no longer running,
149
- # that wait time is counted as well. If the daemon does not stop in time,
150
- # then #stop will raise an exception.
151
- #
152
- # The default value is 15.
153
- #
154
- # [:log_file_activity_timeout]
155
- # Once a daemon has gone into the background, it will become difficult to
156
- # know for certain whether it is still initializing or whether it has
157
- # failed and exited, until it has written its PID file. Suppose that it
158
- # failed with an error after daemonizing but before it has written its PID file;
159
- # not many system administrators want to wait 15 seconds (the default start
160
- # timeout) to be notified of whether the daemon has terminated with an error.
161
- #
162
- # An alternative way to check whether the daemon has terminated with an error,
163
- # is by checking whether its log file has been recently updated. If, after the
164
- # daemon has started, the log file hasn't been updated for the amount of seconds
165
- # given by the :log_file_activity_timeout option, then the daemon is assumed to
166
- # have terminated with an error.
167
- #
168
- # The default value is 7.
169
- #
170
- # [:dont_stop_if_pid_file_invalid]
171
- # If the :stop_command option is given, then normally daemon_controller will
172
- # always execute this command upon calling #stop. But if :dont_stop_if_pid_file_invalid
173
- # is given, then daemon_controller will not do that if the PID file does not contain
174
- # a valid number.
175
- #
176
- # The default is false.
177
- #
178
- # [:daemonize_for_me]
179
- # Normally daemon_controller will wait until the daemon has daemonized into the
180
- # background, in order to capture any errors that it may print on stdout or
181
- # stderr before daemonizing. However, if the daemon doesn't support daemonization
182
- # for some reason, then setting this option to true will cause daemon_controller
183
- # to do the daemonization for the daemon.
184
- #
185
- # The default is false.
186
- #
187
- # [:keep_ios]
188
- # Upon spawning the daemon, daemon_controller will normally close all file
189
- # descriptors except stdin, stdout and stderr. However if there are any file
190
- # descriptors you want to keep open, specify the IO objects here. This must be
191
- # an array of IO objects.
192
- #
193
- # [:env]
194
- # This must be a Hash. The hash will contain the environment variables available
195
- # to be made available to the daemon. Hash keys must be strings, not symbols.
196
- def initialize(options)
197
- [ :identifier, :start_command, :ping_command, :pid_file, :log_file ].each do |option|
198
- if !options.has_key?(option)
199
- raise ArgumentError, "The ':#{option}' option is mandatory."
200
- end
201
- end
202
- @identifier = options[:identifier]
203
- @start_command = options[:start_command]
204
- @stop_command = options[:stop_command]
205
- @ping_command = options[:ping_command]
206
- @restart_command = options[:restart_command]
207
- @ping_interval = options[:ping_interval] || 0.1
208
- @pid_file = options[:pid_file]
209
- @log_file = options[:log_file]
210
- @before_start = options[:before_start]
211
- @start_timeout = options[:start_timeout] || 15
212
- @stop_timeout = options[:stop_timeout] || 15
213
- @log_file_activity_timeout = options[:log_file_activity_timeout] || 7
214
- @dont_stop_if_pid_file_invalid = options[:dont_stop_if_pid_file_invalid]
215
- @daemonize_for_me = options[:daemonize_for_me]
216
- @keep_ios = options[:keep_ios] || []
217
- @lock_file = determine_lock_file(options, @identifier, @pid_file)
218
- @env = options[:env] || {}
74
+ # See doc/OPTIONS.md for options docs.
75
+ def initialize(identifier:, start_command:, ping_command:, pid_file:, log_file:,
76
+ lock_file: nil, stop_command: nil, restart_command: nil, before_start: nil,
77
+ start_timeout: 30, start_abort_timeout: 10, stop_timeout: 30,
78
+ log_file_activity_timeout: 10, ping_interval: 0.1, stop_graceful_signal: "TERM", dont_stop_if_pid_file_invalid: false,
79
+ daemonize_for_me: false, keep_ios: nil, env: {}, logger: nil)
80
+ @identifier = identifier
81
+ @start_command = start_command
82
+ @ping_command = ping_command
83
+ @pid_file = pid_file
84
+ @log_file = log_file
85
+
86
+ @lock_file = determine_lock_file(lock_file, identifier, pid_file)
87
+ @stop_command = stop_command
88
+ @restart_command = restart_command
89
+ @before_start = before_start
90
+ @start_timeout = start_timeout
91
+ @start_abort_timeout = start_abort_timeout
92
+ @stop_timeout = stop_timeout
93
+ @log_file_activity_timeout = log_file_activity_timeout
94
+ @ping_interval = ping_interval
95
+ @stop_graceful_signal = stop_graceful_signal
96
+ @dont_stop_if_pid_file_invalid = dont_stop_if_pid_file_invalid
97
+ @daemonize_for_me = daemonize_for_me
98
+ @keep_ios = keep_ios
99
+ @env = env
100
+ @logger = logger
219
101
  end
220
102
 
221
103
  # Start the daemon and wait until it can be pinged.
@@ -254,15 +136,13 @@ class DaemonController
254
136
  def connect
255
137
  connection = nil
256
138
  @lock_file.shared_lock do
257
- begin
258
- connection = yield
259
- rescue *ALLOWED_CONNECT_EXCEPTIONS
260
- connection = nil
261
- end
139
+ connection = yield
140
+ rescue *ALLOWED_CONNECT_EXCEPTIONS
141
+ connection = nil
262
142
  end
263
143
  if connection.nil?
264
144
  @lock_file.exclusive_lock do
265
- if !daemon_is_running?
145
+ unless daemon_is_running?
266
146
  start_without_locking
267
147
  end
268
148
  connect_exception = nil
@@ -299,17 +179,17 @@ class DaemonController
299
179
  # - StopTimeout - the daemon didn't stop in time.
300
180
  def stop
301
181
  @lock_file.exclusive_lock do
302
- begin
303
- Timeout.timeout(@stop_timeout, Timeout::Error) do
304
- kill_daemon if daemon_is_running?
305
- wait_until do
306
- !daemon_is_running?
307
- end
182
+ timeoutable(@stop_timeout) do
183
+ allow_timeout do
184
+ kill_daemon
185
+ wait_until { !daemon_is_running? }
308
186
  end
309
- rescue Timeout::Error
310
- raise StopTimeout, "Daemon '#{@identifier}' did not exit in time"
311
187
  end
312
188
  end
189
+ rescue Timeout::Error
190
+ kill_daemon_with_signal(force: true)
191
+ wait_until { !daemon_is_running? }
192
+ raise StopTimeout, "Daemon '#{@identifier}' did not exit in time (force killed)"
313
193
  end
314
194
 
315
195
  # Restarts the daemon. Uses the restart_command if provided, otherwise
@@ -355,71 +235,89 @@ class DaemonController
355
235
  RUBY_PLATFORM != "java"
356
236
  end
357
237
 
358
- private
238
+ private
239
+
359
240
  def start_without_locking
360
- if daemon_is_running?
361
- raise AlreadyStarted, "Daemon '#{@identifier}' is already started"
362
- end
241
+ raise AlreadyStarted, "Daemon '#{@identifier}' is already started" if daemon_is_running?
242
+
363
243
  save_log_file_information
364
244
  delete_pid_file
245
+ spawn_result = nil
246
+
365
247
  begin
366
- started = false
367
- before_start
368
- Timeout.timeout(@start_timeout, Timeout::Error) do
369
- done = false
370
- spawn_daemon
248
+ _, remaining_time = timeoutable(@start_timeout) do
249
+ allow_timeout { before_start }
250
+ spawn_result = allow_timeout { spawn_daemon }
251
+ daemon_spawned
371
252
  record_activity
372
253
 
373
- # We wait until the PID file is available and until
374
- # the daemon responds to pings, but we wait no longer
375
- # than @start_timeout seconds in total (including daemon
376
- # spawn time).
377
- # Furthermore, if the log file hasn't changed for
378
- # @log_file_activity_timeout seconds, and the PID file
379
- # still isn't available or the daemon still doesn't
380
- # respond to pings, then assume that the daemon has
381
- # terminated with an error.
382
- wait_until do
383
- if log_file_has_changed?
384
- record_activity
385
- elsif no_activity?(@log_file_activity_timeout)
386
- raise Timeout::Error, "Daemon seems to have exited"
387
- end
388
- pid_file_available?
389
- end
390
- wait_until(@ping_interval) do
391
- if log_file_has_changed?
392
- record_activity
393
- elsif no_activity?(@log_file_activity_timeout)
394
- raise Timeout::Error, "Daemon seems to have exited"
254
+ if spawn_result.is_a?(InternalCommandOkResult)
255
+ allow_timeout do
256
+ # We wait until the PID file is available and until
257
+ # the daemon responds to pings, but we wait no longer
258
+ # than @start_timeout seconds in total (including daemon
259
+ # spawn time).
260
+ # Furthermore, if the log file hasn't changed for
261
+ # @log_file_activity_timeout seconds, and the PID file
262
+ # still isn't available or the daemon still doesn't
263
+ # respond to pings, then assume that the daemon has
264
+ # terminated with an error.
265
+ wait_until do
266
+ if log_file_has_changed?
267
+ record_activity
268
+ elsif no_activity?(@log_file_activity_timeout)
269
+ raise Timeout::Error, "Log file inactivity"
270
+ end
271
+ pid_file_available?
272
+ end
273
+ wait_until(sleep_interval: @ping_interval) do
274
+ if log_file_has_changed?
275
+ record_activity
276
+ elsif no_activity?(@log_file_activity_timeout)
277
+ raise Timeout::Error, "Log file inactivity"
278
+ end
279
+ run_ping_command || !daemon_is_running?
280
+ end
395
281
  end
396
- run_ping_command || !daemon_is_running?
397
282
  end
398
- started = run_ping_command
399
- end
400
- result = started
401
- rescue DaemonizationTimeout, Timeout::Error => e
402
- start_timed_out
403
- if pid_file_available?
404
- kill_daemon_with_signal(true)
405
- end
406
- if e.is_a?(DaemonizationTimeout)
407
- result = :daemonization_timeout
283
+
284
+ spawn_result
285
+ end
286
+ rescue Timeout::Error
287
+ # If we got here then it means either the #before_start timed out (= no PID),
288
+ # or the code after #spawn_daemon timed out (already daemonized, so use PID file).
289
+ # #spawn_daemon itself won't trigger Timeout:Error because that's handled as
290
+ # InternalCommandTimeoutResult.
291
+ pid = spawn_result ? read_pid_file : nil
292
+ start_timed_out(pid)
293
+ debug "Timeout waiting for daemon to be ready, PID #{pid.inspect}"
294
+ abort_start(pid: pid, is_direct_child: false) if pid
295
+ raise StartTimeout, concat_spawn_output_and_logs(spawn_result ? spawn_result.output : nil,
296
+ differences_in_log_file, nil, "timed out")
297
+ end
298
+
299
+ case spawn_result
300
+ when InternalCommandOkResult
301
+ success, _ = timeoutable(remaining_time) { allow_timeout { run_ping_command } }
302
+ if success
303
+ true
408
304
  else
409
- result = :start_timeout
305
+ raise StartError, concat_spawn_output_and_logs(spawn_result.output, differences_in_log_file)
410
306
  end
411
- end
412
- if !result
413
- raise(StartError, differences_in_log_file ||
414
- "Daemon '#{@identifier}' failed to start.")
415
- elsif result == :daemonization_timeout
416
- raise(StartTimeout, differences_in_log_file ||
417
- "Daemon '#{@identifier}' didn't daemonize in time.")
418
- elsif result == :start_timeout
419
- raise(StartTimeout, differences_in_log_file ||
420
- "Daemon '#{@identifier}' failed to start in time.")
307
+
308
+ when InternalCommandErrorResult
309
+ raise StartError, concat_spawn_output_and_logs(spawn_result.output,
310
+ differences_in_log_file, spawn_result.exit_status)
311
+
312
+ when InternalCommandTimeoutResult
313
+ daemonization_timed_out(spawn_result.pid)
314
+ abort_start(pid: spawn_result.pid, is_direct_child: true)
315
+ debug "Timeout waiting for daemon to fork, PID #{spawn_result.pid}"
316
+ raise StartTimeout, concat_spawn_output_and_logs(spawn_result.output,
317
+ differences_in_log_file, nil, "timed out")
318
+
421
319
  else
422
- true
320
+ raise "Bug: unexpected result from #spawn_daemon: #{spawn_result.inspect}"
423
321
  end
424
322
  end
425
323
 
@@ -439,42 +337,39 @@ private
439
337
 
440
338
  def kill_daemon
441
339
  if @stop_command
442
- if @dont_stop_if_pid_file_invalid && read_pid_file.nil?
443
- return
444
- end
445
- begin
446
- run_command(@stop_command)
447
- rescue StartError => e
448
- raise StopError, e.message
340
+ return if @dont_stop_if_pid_file_invalid && read_pid_file.nil?
341
+
342
+ result = run_command(@stop_command)
343
+ case result
344
+ when InternalCommandOkResult
345
+ # Success
346
+ when InternalCommandErrorResult
347
+ raise StopError, concat_spawn_output_and_logs(result.output, nil, result.exit_status)
348
+ when InternalCommandTimeoutResult
349
+ raise StopError, concat_spawn_output_and_logs(result.output, nil, nil, "timed out")
350
+ else
351
+ raise "Bug: unexpected result from #run_command: #{result.inspect}"
449
352
  end
450
353
  else
451
354
  kill_daemon_with_signal
452
355
  end
453
356
  end
454
357
 
455
- def kill_daemon_with_signal(force = false)
456
- pid = read_pid_file
457
- if pid
358
+ def kill_daemon_with_signal(force: false)
359
+ if (pid = read_pid_file)
458
360
  if force
459
- Process.kill('SIGKILL', pid)
361
+ Process.kill("SIGKILL", pid)
460
362
  else
461
- Process.kill('SIGTERM', pid)
363
+ Process.kill(normalize_signal_name(@stop_graceful_signal), pid)
462
364
  end
463
365
  end
464
366
  rescue Errno::ESRCH, Errno::ENOENT
465
367
  end
466
368
 
467
369
  def daemon_is_running?
468
- begin
469
- pid = read_pid_file
470
- rescue Errno::ENOENT
471
- # The PID file may not exist, or another thread/process
472
- # executing #running? may have just deleted the PID file.
473
- # So we catch this error.
474
- pid = nil
475
- end
370
+ pid = read_pid_file
476
371
  if pid.nil?
477
- false
372
+ nil
478
373
  elsif check_pid(pid)
479
374
  true
480
375
  else
@@ -484,16 +379,11 @@ private
484
379
  end
485
380
 
486
381
  def read_pid_file
487
- begin
488
- pid = File.read(@pid_file).strip
489
- rescue Errno::ENOENT
490
- return nil
491
- end
492
- if pid =~ /\A\d+\Z/
382
+ pid = File.read(@pid_file).strip
383
+ if /\A\d+\Z/.match?(pid)
493
384
  pid.to_i
494
- else
495
- nil
496
385
  end
386
+ rescue Errno::ENOENT
497
387
  end
498
388
 
499
389
  def delete_pid_file
@@ -514,21 +404,21 @@ private
514
404
  true
515
405
  end
516
406
 
517
- def wait_until(sleep_interval = 0.1)
518
- while !yield
407
+ def wait_until(sleep_interval: 0.1)
408
+ until yield
519
409
  sleep(sleep_interval)
520
410
  end
521
411
  end
522
412
 
523
413
  def wait_until_pid_file_is_available_or_log_file_has_changed
524
- while !(pid_file_available? || log_file_has_changed?)
414
+ until pid_file_available? || log_file_has_changed?
525
415
  sleep 0.1
526
416
  end
527
417
  pid_file_is_available?
528
418
  end
529
419
 
530
420
  def wait_until_daemon_responds_to_ping_or_has_exited_or_log_file_has_changed
531
- while !(run_ping_command || !daemon_is_running? || log_file_has_changed?)
421
+ until run_ping_command || !daemon_is_running? || log_file_has_changed?
532
422
  sleep(@ping_interval)
533
423
  end
534
424
  run_ping_command
@@ -544,28 +434,90 @@ private
544
434
  end
545
435
 
546
436
  def pid_file_available?
547
- File.exist?(@pid_file) && File.stat(@pid_file).size != 0
437
+ File.exist?(@pid_file) && !File.zero?(@pid_file)
548
438
  end
549
439
 
550
440
  # This method does nothing and only serves as a hook for the unit test.
551
- def start_timed_out
441
+ def daemon_spawned
552
442
  end
553
443
 
554
444
  # This method does nothing and only serves as a hook for the unit test.
555
- def daemonization_timed_out
445
+ def start_timed_out(pid)
446
+ end
447
+
448
+ # This method does nothing and only serves as a hook for the unit test.
449
+ def daemonization_timed_out(pid)
450
+ end
451
+
452
+ # Aborts a daemon that we tried to start, but timed out.
453
+ def abort_start(pid:, is_direct_child:)
454
+ begin
455
+ debug "Killing process #{pid}"
456
+ Process.kill("SIGTERM", pid)
457
+ rescue SystemCallError
458
+ end
459
+
460
+ begin
461
+ timeoutable(@start_abort_timeout) do
462
+ allow_timeout do
463
+ wait_for_aborted_process(pid: pid, is_direct_child: is_direct_child)
464
+ end
465
+ end
466
+ rescue Timeout::Error
467
+ begin
468
+ Process.kill("SIGKILL", pid)
469
+ rescue SystemCallError
470
+ end
471
+
472
+ allow_timeout do
473
+ wait_for_aborted_process(pid: pid, is_direct_child: is_direct_child)
474
+ end
475
+ end
476
+ end
477
+
478
+ def wait_for_aborted_process(pid:, is_direct_child:)
479
+ if is_direct_child
480
+ begin
481
+ debug "Waiting directly for process #{pid}"
482
+ Process.waitpid(pid)
483
+ rescue SystemCallError
484
+ end
485
+
486
+ # The daemon may have:
487
+ # 1. Written a PID file before forking. We delete this PID file.
488
+ # -OR-
489
+ # 2. It might have forked (and written a PID file) right before
490
+ # we terminated it. We'll want the fork to stay alive rather
491
+ # than going through the (complicated) trouble of killing it.
492
+ # Don't touch the PID file.
493
+ pid2 = read_pid_file
494
+ debug "PID file contains #{pid2.inspect}"
495
+ delete_pid_file if pid == pid2
496
+ else
497
+ debug "Waiting until daemon is no longer running"
498
+ wait_until { !daemon_is_running? }
499
+ end
556
500
  end
557
501
 
558
502
  def save_log_file_information
559
- @original_log_file_stat = File.stat(@log_file) rescue nil
503
+ @original_log_file_stat = begin
504
+ File.stat(@log_file)
505
+ rescue
506
+ nil
507
+ end
560
508
  @current_log_file_stat = @original_log_file_stat
561
509
  end
562
510
 
563
511
  def log_file_has_changed?
564
512
  if @current_log_file_stat
565
- stat = File.stat(@log_file) rescue nil
513
+ stat = begin
514
+ File.stat(@log_file)
515
+ rescue
516
+ nil
517
+ end
566
518
  if stat
567
519
  result = @current_log_file_stat.mtime != stat.mtime ||
568
- @current_log_file_stat.size != stat.size
520
+ @current_log_file_stat.size != stat.size
569
521
  @current_log_file_stat = stat
570
522
  result
571
523
  else
@@ -578,45 +530,88 @@ private
578
530
 
579
531
  def differences_in_log_file
580
532
  if @original_log_file_stat && @original_log_file_stat.file?
581
- File.open(@log_file, 'r') do |f|
533
+ File.open(@log_file, "r") do |f|
582
534
  f.seek(@original_log_file_stat.size, IO::SEEK_SET)
583
- diff = f.read.strip
584
- if diff.empty?
585
- nil
586
- else
587
- diff
588
- end
535
+ f.read.strip
589
536
  end
590
- else
591
- nil
592
537
  end
593
538
  rescue Errno::ENOENT, Errno::ESPIPE
594
539
  # ESPIPE means the log file is a pipe.
595
540
  nil
596
541
  end
597
542
 
598
- def determine_lock_file(options, identifier, pid_file)
599
- if options[:lock_file]
600
- LockFile.new(File.expand_path(options[:lock_file]))
543
+ def determine_lock_file(given_lock_file, identifier, pid_file)
544
+ if given_lock_file
545
+ LockFile.new(File.absolute_path(given_lock_file))
601
546
  else
602
- LockFile.new(File.expand_path(pid_file + ".lock"))
547
+ LockFile.new(File.absolute_path(pid_file + ".lock"))
603
548
  end
604
549
  end
605
550
 
606
- def self.fork_supported?
607
- RUBY_PLATFORM != "java" && RUBY_PLATFORM !~ /win32/
608
- end
609
-
610
- def self.spawn_supported?
611
- # Process.spawn doesn't work very well in JRuby.
612
- Process.respond_to?(:spawn) && RUBY_PLATFORM != "java"
613
- end
614
-
615
551
  def run_command(command)
616
552
  if should_capture_output_while_running_command?
617
- run_command_while_capturing_output(command)
553
+ # Create tempfile for storing the command's output.
554
+ tempfile = Tempfile.new("daemon-output")
555
+ tempfile.chmod(0o666)
556
+ tempfile_path = tempfile.path
557
+ tempfile.close
558
+
559
+ spawn_options = {
560
+ in: "/dev/null",
561
+ out: tempfile_path,
562
+ err: tempfile_path,
563
+ close_others: true,
564
+ }
565
+ else
566
+ spawn_options = {
567
+ in: "/dev/null",
568
+ out: :out,
569
+ err: :err,
570
+ close_others: true,
571
+ }
572
+ end
573
+
574
+ if @keep_ios
575
+ @keep_ios.each do |io|
576
+ spawn_options[io] = io
577
+ end
578
+ end
579
+
580
+ pid = if @daemonize_for_me
581
+ Process.spawn(@env, ruby_interpreter, SPAWNER_FILE,
582
+ command, spawn_options)
583
+ else
584
+ Process.spawn(@env, command, spawn_options)
585
+ end
586
+
587
+ # run_command might be running in a timeout block (like
588
+ # in #start_without_locking).
589
+ begin
590
+ Process.waitpid(pid)
591
+ rescue Errno::ECHILD
592
+ # Maybe a background thread or whatever waitpid()'ed
593
+ # this child process before we had the chance. There's
594
+ # no way to obtain the exit status now. Assume that
595
+ # it started successfully; if it didn't we'll know
596
+ # that later by checking the PID file and by pinging
597
+ # it.
598
+ return InternalCommandOkResult.new(pid, tempfile_path && File.read(tempfile_path).strip)
599
+ rescue Timeout::Error
600
+ return InternalCommandTimeoutResult.new(pid, tempfile_path && File.read(tempfile_path).strip)
601
+ end
602
+
603
+ child_status = $?
604
+ output = File.read(tempfile_path).strip if tempfile_path
605
+ if child_status.success?
606
+ InternalCommandOkResult.new(pid, output)
618
607
  else
619
- run_command_without_capturing_output(command)
608
+ InternalCommandErrorResult.new(pid, output, child_status)
609
+ end
610
+ ensure
611
+ begin
612
+ tempfile.unlink if tempfile
613
+ rescue SystemCallError
614
+ nil
620
615
  end
621
616
  end
622
617
 
@@ -645,192 +640,16 @@ private
645
640
  path =~ %r{\A/proc/([0-9]+|self)/fd/[12]\Z}
646
641
  end
647
642
 
648
- def run_command_while_capturing_output(command)
649
- # Create tempfile for storing the command's output.
650
- tempfile = Tempfile.new('daemon-output')
651
- tempfile.chmod(0666)
652
- tempfile_path = tempfile.path
653
- tempfile.close
654
-
655
- if self.class.fork_supported? || self.class.spawn_supported?
656
- if Process.respond_to?(:spawn)
657
- options = {
658
- in: "/dev/null",
659
- out: tempfile_path,
660
- err: tempfile_path,
661
- close_others: true,
662
- }
663
- @keep_ios.each do |io|
664
- options[io] = io
665
- end
666
- if @daemonize_for_me
667
- pid = Process.spawn(@env, ruby_interpreter, SPAWNER_FILE,
668
- command, options)
669
- else
670
- pid = Process.spawn(@env, command, options)
671
- end
672
- else
673
- pid = safe_fork(@daemonize_for_me) do
674
- ObjectSpace.each_object(IO) do |obj|
675
- if !@keep_ios.include?(obj)
676
- obj.close rescue nil
677
- end
678
- end
679
- STDIN.reopen("/dev/null", "r")
680
- STDOUT.reopen(tempfile_path, "w")
681
- STDERR.reopen(tempfile_path, "w")
682
- ENV.update(@env)
683
- exec(command)
684
- end
685
- end
686
-
687
- # run_command might be running in a timeout block (like
688
- # in #start_without_locking).
689
- begin
690
- interruptable_waitpid(pid)
691
- rescue Errno::ECHILD
692
- # Maybe a background thread or whatever waitpid()'ed
693
- # this child process before we had the chance. There's
694
- # no way to obtain the exit status now. Assume that
695
- # it started successfully; if it didn't we'll know
696
- # that later by checking the PID file and by pinging
697
- # it.
698
- return
699
- rescue Timeout::Error
700
- daemonization_timed_out
701
-
702
- # If the daemon doesn't fork into the background
703
- # in time, then kill it.
704
- begin
705
- Process.kill('SIGTERM', pid)
706
- rescue SystemCallError
707
- end
708
- begin
709
- Timeout.timeout(5, Timeout::Error) do
710
- begin
711
- interruptable_waitpid(pid)
712
- rescue SystemCallError
713
- end
714
- end
715
- rescue Timeout::Error
716
- begin
717
- Process.kill('SIGKILL', pid)
718
- interruptable_waitpid(pid)
719
- rescue SystemCallError
720
- end
721
- end
722
- raise DaemonizationTimeout
723
- end
724
- if $?.exitstatus != 0
725
- raise StartError, File.read(tempfile_path).strip
726
- end
727
- else
728
- if @env && !@env.empty?
729
- raise "Setting the :env option is not supported on this Ruby implementation."
730
- elsif @daemonize_for_me
731
- raise "Setting the :daemonize_for_me option is not supported on this Ruby implementation."
732
- end
733
-
734
- cmd = "#{command} >\"#{tempfile_path}\""
735
- cmd << " 2>\"#{tempfile_path}\"" unless PLATFORM =~ /mswin/
736
- if !system(cmd)
737
- raise StartError, File.read(tempfile_path).strip
738
- end
739
- end
740
- ensure
741
- File.unlink(tempfile_path) rescue nil
742
- end
743
-
744
- def run_command_without_capturing_output(command)
745
- if self.class.fork_supported? || self.class.spawn_supported?
746
- if Process.respond_to?(:spawn)
747
- options = {
748
- in: "/dev/null",
749
- out: :out,
750
- err: :err,
751
- close_others: true,
752
- }
753
- @keep_ios.each do |io|
754
- options[io] = io
755
- end
756
- if @daemonize_for_me
757
- pid = Process.spawn(@env, ruby_interpreter, SPAWNER_FILE,
758
- command, options)
759
- else
760
- pid = Process.spawn(@env, command, options)
761
- end
762
- else
763
- pid = safe_fork(@daemonize_for_me) do
764
- ObjectSpace.each_object(IO) do |obj|
765
- if !@keep_ios.include?(obj)
766
- obj.close rescue nil
767
- end
768
- end
769
- STDIN.reopen("/dev/null", "r")
770
- ENV.update(@env)
771
- exec(command)
772
- end
773
- end
774
-
775
- # run_command might be running in a timeout block (like
776
- # in #start_without_locking).
777
- begin
778
- interruptable_waitpid(pid)
779
- rescue Errno::ECHILD
780
- # Maybe a background thread or whatever waitpid()'ed
781
- # this child process before we had the chance. There's
782
- # no way to obtain the exit status now. Assume that
783
- # it started successfully; if it didn't we'll know
784
- # that later by checking the PID file and by pinging
785
- # it.
786
- return
787
- rescue Timeout::Error
788
- daemonization_timed_out
789
-
790
- # If the daemon doesn't fork into the background
791
- # in time, then kill it.
792
- begin
793
- Process.kill('SIGTERM', pid)
794
- rescue SystemCallError
795
- end
796
- begin
797
- Timeout.timeout(5, Timeout::Error) do
798
- begin
799
- interruptable_waitpid(pid)
800
- rescue SystemCallError
801
- end
802
- end
803
- rescue Timeout::Error
804
- begin
805
- Process.kill('SIGKILL', pid)
806
- interruptable_waitpid(pid)
807
- rescue SystemCallError
808
- end
809
- end
810
- raise DaemonizationTimeout
811
- end
812
- if $?.exitstatus != 0
813
- raise StartError, "Daemon '#{@identifier}' failed to start."
814
- end
815
- else
816
- if @env && !@env.empty?
817
- raise "Setting the :env option is not supported on this Ruby implementation."
818
- elsif @daemonize_for_me
819
- raise "Setting the :daemonize_for_me option is not supported on this Ruby implementation."
820
- end
821
-
822
- if !system(command)
823
- raise StartError, "Daemon '#{@identifier}' failed to start."
824
- end
825
- end
826
- end
827
-
828
643
  def run_ping_command
829
644
  if @ping_command.respond_to?(:call)
830
645
  begin
831
646
  value = @ping_command.call
832
647
  if value.respond_to?(:close)
833
- value.close rescue nil
648
+ begin
649
+ value.close
650
+ rescue
651
+ nil
652
+ end
834
653
  end
835
654
  value
836
655
  rescue *ALLOWED_CONNECT_EXCEPTIONS
@@ -867,27 +686,55 @@ private
867
686
  end
868
687
  end
869
688
 
870
- if !can_ping_unix_sockets?
871
- require 'java'
689
+ if can_ping_unix_sockets?
690
+ def ping_socket(socket_domain, sockaddr)
691
+ socket = Socket.new(socket_domain, Socket::Constants::SOCK_STREAM, 0)
692
+ begin
693
+ socket.connect_nonblock(sockaddr)
694
+ rescue Errno::ENOENT, Errno::EINPROGRESS, Errno::EAGAIN, Errno::EWOULDBLOCK
695
+ if select(nil, [ socket ], nil, 0.1)
696
+ begin
697
+ socket.connect_nonblock(sockaddr)
698
+ rescue Errno::EISCONN
699
+ rescue Errno::EINVAL
700
+ if RUBY_PLATFORM.match?(/freebsd/i)
701
+ raise Errno::ECONNREFUSED
702
+ else
703
+ raise
704
+ end
705
+ end
706
+ else
707
+ raise Errno::ECONNREFUSED
708
+ end
709
+ end
710
+ true
711
+ rescue Errno::ECONNREFUSED, Errno::ENOENT
712
+ false
713
+ ensure
714
+ socket.close if socket
715
+ end
716
+
717
+ def ping_tcp_socket(sockaddr)
718
+ ping_socket(Socket::Constants::AF_INET, sockaddr)
719
+ rescue Errno::EAFNOSUPPORT
720
+ ping_socket(Socket::Constants::AF_INET6, sockaddr)
721
+ end
722
+ else
723
+ require "java"
872
724
 
873
725
  def ping_socket(host_name, port)
874
726
  channel = java.nio.channels.SocketChannel.open
875
727
  begin
876
728
  address = java.net.InetSocketAddress.new(host_name, port)
877
729
  channel.configure_blocking(false)
878
- if channel.connect(address)
879
- return true
880
- end
730
+ return true if channel.connect(address)
881
731
 
882
732
  deadline = Time.now.to_f + 0.1
883
- done = false
884
- while true
733
+ loop do
885
734
  begin
886
- if channel.finish_connect
887
- return true
888
- end
735
+ return true if channel.finish_connect
889
736
  rescue java.net.ConnectException => e
890
- if e.message =~ /Connection refused/i
737
+ if /Connection refused/i.match?(e.message)
891
738
  return false
892
739
  else
893
740
  throw e
@@ -896,116 +743,85 @@ private
896
743
 
897
744
  # Not done connecting and no error.
898
745
  sleep 0.01
899
- if Time.now.to_f >= deadline
900
- return false
901
- end
746
+ return false if Time.now.to_f >= deadline
902
747
  end
903
748
  ensure
904
749
  channel.close
905
750
  end
906
751
  end
907
- else
908
- def ping_socket(socket_domain, sockaddr)
909
- begin
910
- socket = Socket.new(socket_domain, Socket::Constants::SOCK_STREAM, 0)
911
- begin
912
- socket.connect_nonblock(sockaddr)
913
- rescue Errno::ENOENT, Errno::EINPROGRESS, Errno::EAGAIN, Errno::EWOULDBLOCK
914
- if select(nil, [ socket ], nil, 0.1)
915
- begin
916
- socket.connect_nonblock(sockaddr)
917
- rescue Errno::EISCONN
918
- rescue Errno::EINVAL
919
- if RUBY_PLATFORM =~ /freebsd/i
920
- raise Errno::ECONNREFUSED
921
- else
922
- raise
923
- end
924
- end
925
- else
926
- raise Errno::ECONNREFUSED
927
- end
928
- end
929
- true
930
- rescue Errno::ECONNREFUSED, Errno::ENOENT
931
- false
932
- ensure
933
- socket.close if socket
934
- end
935
- end
752
+ end
936
753
 
937
- def ping_tcp_socket(sockaddr)
938
- begin
939
- ping_socket(Socket::Constants::AF_INET, sockaddr)
940
- rescue Errno::EAFNOSUPPORT
941
- ping_socket(Socket::Constants::AF_INET6, sockaddr)
942
- end
754
+ def ruby_interpreter
755
+ File.join(
756
+ RbConfig::CONFIG["bindir"],
757
+ RbConfig::CONFIG.values_at("RUBY_INSTALL_NAME", "EXEEXT").join
758
+ )
759
+ end
760
+
761
+ def timeoutable(amount, &block)
762
+ Thread.handle_interrupt(Timeout::Error => :never) do
763
+ start_time = monotonic_time
764
+ result = Timeout.timeout(amount, Timeout::Error, &block)
765
+ [ result, [ monotonic_time - start_time, 0 ].max ]
943
766
  end
944
767
  end
945
768
 
946
- def ruby_interpreter
947
- if defined?(RbConfig)
948
- rb_config = RbConfig::CONFIG
769
+ def allow_timeout(&block)
770
+ Thread.handle_interrupt(Timeout::Error => :on_blocking, &block)
771
+ end
772
+
773
+ def monotonic_time
774
+ Process.clock_gettime(Process::CLOCK_MONOTONIC)
775
+ end
776
+
777
+ def signal_termination_message(process_status)
778
+ if process_status.signaled?
779
+ "terminated with signal #{signal_name_for(process_status.termsig)}"
949
780
  else
950
- rb_config = Config::CONFIG
781
+ "exited with status #{process_status.exitstatus}"
951
782
  end
952
- File.join(
953
- rb_config['bindir'],
954
- rb_config['RUBY_INSTALL_NAME']
955
- ) + rb_config['EXEEXT']
956
783
  end
957
784
 
958
- def safe_fork(double_fork)
959
- pid = fork
960
- if pid.nil?
961
- begin
962
- if double_fork
963
- pid2 = fork
964
- if pid2.nil?
965
- Process.setsid
966
- yield
967
- end
968
- else
969
- yield
970
- end
971
- rescue Exception => e
972
- message = "*** Exception #{e.class} " <<
973
- "(#{e}) (process #{$$}):\n" <<
974
- "\tfrom " << e.backtrace.join("\n\tfrom ")
975
- STDERR.write(e)
976
- STDERR.flush
977
- exit!
978
- ensure
979
- exit!(0)
980
- end
785
+ def normalize_signal_name(name)
786
+ name.start_with?("SIG") ? name : "SIG#{name}"
787
+ end
788
+
789
+ def signal_name_for(num)
790
+ if (name = Signal.list.key(num))
791
+ "SIG#{name}"
981
792
  else
982
- if double_fork
983
- Process.waitpid(pid) rescue nil
984
- pid
985
- else
986
- pid
987
- end
793
+ num.to_s
988
794
  end
989
795
  end
990
796
 
991
- if RUBY_VERSION < "1.9"
992
- def interruptable_waitpid(pid)
993
- Process.waitpid(pid)
797
+ def concat_spawn_output_and_logs(output, logs, exit_status = nil, suffix_message = nil)
798
+ format_full_suffix_message = lambda do |main_message = nil|
799
+ [
800
+ main_message,
801
+ exit_status ? signal_termination_message(exit_status) : nil,
802
+ suffix_message,
803
+ ].compact.join("; ")
994
804
  end
995
- else
996
- # On Ruby 1.9, Thread#kill (which is called by timeout.rb) may
997
- # not be able to interrupt Process.waitpid. So here we use a
998
- # special version that's a bit less efficient but is at least
999
- # interruptable.
1000
- def interruptable_waitpid(pid)
1001
- result = nil
1002
- while !result
1003
- result = Process.waitpid(pid, Process::WNOHANG)
1004
- sleep 0.01 if !result
805
+
806
+ if output.nil? && logs.nil?
807
+ "(#{format_full_suffix_message.call("logs not available")})"
808
+ elsif (output && output.empty? && logs && logs.empty?) || (output && output.empty? && logs.nil?) || (output.nil? && logs && logs.empty?)
809
+ "(#{format_full_suffix_message.call("logs empty")})"
810
+ else
811
+ full_suffix_message = format_full_suffix_message.call
812
+ if full_suffix_message.empty?
813
+ "#{output}\n#{logs}".strip
814
+ elsif logs && logs.empty?
815
+ "#{output}\n(#{full_suffix_message})".strip
816
+ else
817
+ "#{output}\n#{logs}\n(#{full_suffix_message})".strip
1005
818
  end
1006
- result
1007
819
  end
1008
820
  end
821
+
822
+ def debug(message)
823
+ @logger.debug(message) if @logger
824
+ end
1009
825
  end
1010
826
 
1011
827
  end # module PhusionPassenger