passenger 5.3.5 → 5.3.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (211) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +13 -0
  3. data/README.md +2 -1
  4. data/Rakefile +0 -5
  5. data/build/agent.rb +2 -1
  6. data/build/cxx_tests.rb +18 -20
  7. data/build/integration_tests.rb +6 -2
  8. data/build/support/cxx_dependency_map.rb +2019 -1966
  9. data/dev/colorize-logs +272 -0
  10. data/src/agent/Core/AdminPanelConnector.h +3 -3
  11. data/src/agent/Core/ApiServer.h +4 -4
  12. data/src/agent/Core/ApplicationPool/BasicProcessInfo.h +2 -2
  13. data/src/agent/Core/ApplicationPool/Group/OutOfBandWork.cpp +2 -2
  14. data/src/agent/Core/ApplicationPool/Implementation.cpp +5 -5
  15. data/src/agent/Core/ApplicationPool/Pool.h +4 -4
  16. data/src/agent/Core/ApplicationPool/Process.h +10 -15
  17. data/src/agent/Core/ApplicationPool/Socket.h +2 -2
  18. data/src/agent/Core/ApplicationPool/TestSession.h +3 -3
  19. data/src/agent/Core/Config.h +4 -2
  20. data/src/agent/Core/Controller.h +4 -4
  21. data/src/agent/Core/Controller/Config.h +1 -1
  22. data/src/agent/Core/Controller/SendRequest.cpp +2 -2
  23. data/src/agent/Core/Controller/TurboCaching.h +2 -2
  24. data/src/agent/Core/CoreMain.cpp +2 -2
  25. data/src/agent/Core/OptionParser.h +2 -2
  26. data/src/agent/Core/ResponseCache.h +3 -3
  27. data/src/agent/Core/SecurityUpdateChecker.h +2 -2
  28. data/src/agent/Core/SpawningKit/Config.h +2 -1
  29. data/src/agent/Core/SpawningKit/Config/AutoGeneratedCode.h +1 -1
  30. data/src/agent/Core/SpawningKit/Context.h +1 -1
  31. data/src/agent/Core/SpawningKit/DirectSpawner.h +3 -3
  32. data/src/agent/Core/SpawningKit/DummySpawner.h +3 -3
  33. data/src/agent/Core/SpawningKit/ErrorRenderer.h +1 -1
  34. data/src/agent/Core/SpawningKit/Exceptions.h +2 -2
  35. data/src/agent/Core/SpawningKit/Factory.h +1 -1
  36. data/src/agent/Core/SpawningKit/Handshake/BackgroundIOCapturer.h +1 -1
  37. data/src/agent/Core/SpawningKit/Handshake/Perform.h +13 -2
  38. data/src/agent/Core/SpawningKit/Handshake/Prepare.h +3 -3
  39. data/src/agent/Core/SpawningKit/Handshake/WorkDir.h +1 -1
  40. data/src/agent/Core/SpawningKit/Journey.h +4 -5
  41. data/src/agent/Core/SpawningKit/PipeWatcher.h +1 -1
  42. data/src/agent/Core/SpawningKit/Result.h +20 -8
  43. data/src/agent/Core/SpawningKit/Result/AutoGeneratedCode.h +1 -1
  44. data/src/agent/Core/SpawningKit/SmartSpawner.h +6 -6
  45. data/src/agent/Core/SpawningKit/Spawner.h +2 -2
  46. data/src/agent/Core/TelemetryCollector.h +13 -7
  47. data/src/agent/ExecHelper/ExecHelperMain.cpp +1 -1
  48. data/src/agent/README.md +1 -1
  49. data/src/agent/Shared/ApiAccountUtils.h +1 -1
  50. data/src/agent/Shared/ApiServerUtils.h +3 -3
  51. data/src/agent/Shared/ApplicationPoolApiKey.h +2 -2
  52. data/src/agent/Shared/Fundamentals/Initialization.cpp +4 -4
  53. data/src/agent/SpawnEnvSetupper/SpawnEnvSetupperMain.cpp +1 -1
  54. data/src/agent/SystemMetrics/SystemMetricsMain.cpp +4 -3
  55. data/src/agent/Watchdog/ApiServer.h +3 -3
  56. data/src/agent/Watchdog/Config.h +3 -2
  57. data/src/agent/Watchdog/CoreWatcher.cpp +2 -2
  58. data/src/agent/Watchdog/WatchdogMain.cpp +93 -27
  59. data/src/apache2_module/Config.cpp +14 -14
  60. data/src/apache2_module/Config.h +8 -16
  61. data/src/apache2_module/ConfigGeneral/AutoGeneratedDefinitions.cpp +505 -491
  62. data/src/apache2_module/ConfigGeneral/AutoGeneratedDefinitions.cpp.cxxcodebuilder +39 -17
  63. data/src/apache2_module/ConfigGeneral/AutoGeneratedSetterFuncs.cpp +24 -1
  64. data/src/apache2_module/ConfigGeneral/AutoGeneratedSetterFuncs.cpp.cxxcodebuilder +31 -1
  65. data/src/{cxx_supportlib/Utils/MemoryBarrier.h → apache2_module/ConfigGeneral/Common.h} +17 -25
  66. data/src/apache2_module/DirConfig/AutoGeneratedCreateFunction.cpp +12 -1
  67. data/src/apache2_module/DirConfig/AutoGeneratedCreateFunction.cpp.cxxcodebuilder +16 -1
  68. data/src/apache2_module/DirConfig/AutoGeneratedHeaderSerialization.cpp +19 -5
  69. data/src/apache2_module/DirConfig/AutoGeneratedHeaderSerialization.cpp.cxxcodebuilder +26 -9
  70. data/src/apache2_module/DirConfig/AutoGeneratedManifestGeneration.cpp +6 -1
  71. data/src/apache2_module/DirConfig/AutoGeneratedManifestGeneration.cpp.cxxcodebuilder +10 -1
  72. data/src/apache2_module/DirConfig/AutoGeneratedMergeFunction.cpp +7 -1
  73. data/src/apache2_module/DirConfig/AutoGeneratedMergeFunction.cpp.cxxcodebuilder +11 -1
  74. data/src/apache2_module/DirConfig/AutoGeneratedStruct.h +23 -1
  75. data/src/apache2_module/DirConfig/AutoGeneratedStruct.h.cxxcodebuilder +34 -1
  76. data/src/apache2_module/Hooks.cpp +3 -3
  77. data/src/apache2_module/ServerConfig/AutoGeneratedStruct.h +24 -1
  78. data/src/apache2_module/ServerConfig/AutoGeneratedStruct.h.cxxcodebuilder +36 -1
  79. data/src/cxx_supportlib/{Utils → Algorithms}/Hasher.cpp +2 -2
  80. data/src/cxx_supportlib/{Utils → Algorithms}/Hasher.h +4 -4
  81. data/src/cxx_supportlib/AppTypeDetector/Detector.h +1 -1
  82. data/src/cxx_supportlib/ConfigKit/Schema.h +2 -2
  83. data/src/cxx_supportlib/ConfigKit/Store.h +1 -1
  84. data/src/cxx_supportlib/Constants.h +1 -1
  85. data/src/cxx_supportlib/{Utils → DataStructures}/HashMap.h +4 -4
  86. data/src/cxx_supportlib/DataStructures/HashedStaticString.h +5 -5
  87. data/src/cxx_supportlib/DataStructures/LString.h +3 -3
  88. data/src/cxx_supportlib/{Utils → DataStructures}/StringMap.h +36 -36
  89. data/src/cxx_supportlib/FileTools/FileManip.cpp +1 -1
  90. data/src/cxx_supportlib/FileTools/PathManip.cpp +2 -2
  91. data/src/cxx_supportlib/FileTools/PathSecurityCheck.cpp +1 -1
  92. data/src/cxx_supportlib/Hooks.h +2 -2
  93. data/src/cxx_supportlib/{Utils → IOTools}/BufferedIO.h +5 -5
  94. data/src/cxx_supportlib/{Utils → IOTools}/IOUtils.cpp +2 -2
  95. data/src/cxx_supportlib/{Utils → IOTools}/IOUtils.h +3 -3
  96. data/src/cxx_supportlib/{Utils → IOTools}/MessageIO.h +7 -7
  97. data/src/cxx_supportlib/{MessageReadersWriters.h → IOTools/MessageSerialization.h} +5 -5
  98. data/src/cxx_supportlib/InstanceDirectory.h +4 -4
  99. data/src/cxx_supportlib/Integrations/LibevJsonUtils.h +3 -3
  100. data/src/cxx_supportlib/{Utils → JsonTools}/JsonUtils.h +5 -5
  101. data/src/cxx_supportlib/LoggingKit/Context.h +2 -2
  102. data/src/cxx_supportlib/LoggingKit/Implementation.cpp +3 -3
  103. data/src/cxx_supportlib/MemoryKit/mbuf.cpp +2 -2
  104. data/src/cxx_supportlib/ProcessManagement/Spawn.cpp +5 -5
  105. data/src/cxx_supportlib/ProcessManagement/Utils.h +10 -0
  106. data/src/cxx_supportlib/RandomGenerator.h +2 -2
  107. data/src/cxx_supportlib/{Crypto.cpp → SecurityKit/Crypto.cpp} +4 -4
  108. data/src/cxx_supportlib/{Crypto.h → SecurityKit/Crypto.h} +4 -4
  109. data/src/cxx_supportlib/{Utils → SecurityKit}/MemZeroGuard.h +0 -0
  110. data/src/cxx_supportlib/ServerKit/AcceptLoadBalancer.h +2 -2
  111. data/src/cxx_supportlib/ServerKit/Channel.h +1 -1
  112. data/src/cxx_supportlib/ServerKit/Context.h +2 -2
  113. data/src/cxx_supportlib/ServerKit/FileBufferedChannel.h +1 -1
  114. data/src/cxx_supportlib/ServerKit/HttpHeaderParser.h +3 -3
  115. data/src/cxx_supportlib/ServerKit/HttpHeaderParserState.h +2 -2
  116. data/src/cxx_supportlib/ServerKit/HttpServer.h +16 -10
  117. data/src/cxx_supportlib/ServerKit/Server.h +3 -3
  118. data/src/cxx_supportlib/{Utils → StrIntTools}/DateParsing.h +5 -5
  119. data/src/cxx_supportlib/{Utils → StrIntTools}/StrIntUtils.cpp +3 -3
  120. data/src/cxx_supportlib/{Utils → StrIntTools}/StrIntUtils.h +0 -0
  121. data/src/cxx_supportlib/{Utils → StrIntTools}/StrIntUtilsNoStrictAliasing.cpp +2 -2
  122. data/src/cxx_supportlib/{Utils → StrIntTools}/StringScanning.h +5 -5
  123. data/src/cxx_supportlib/{Utils → StrIntTools}/Template.h +30 -5
  124. data/src/cxx_supportlib/SystemTools/ContainerHelpers.h +34 -0
  125. data/src/cxx_supportlib/{Utils → SystemTools}/ProcessMetricsCollector.h +6 -6
  126. data/src/cxx_supportlib/{Utils → SystemTools}/SystemMetricsCollector.h +3 -3
  127. data/src/cxx_supportlib/{Utils → SystemTools}/SystemTime.cpp +1 -1
  128. data/src/cxx_supportlib/{Utils → SystemTools}/SystemTime.h +0 -0
  129. data/src/cxx_supportlib/SystemTools/UserDatabase.h +1 -1
  130. data/src/cxx_supportlib/Utils.cpp +2 -2
  131. data/src/cxx_supportlib/Utils/CachedFileStat.hpp +3 -3
  132. data/src/cxx_supportlib/Utils/Curl.h +2 -2
  133. data/src/cxx_supportlib/Utils/FileChangeChecker.h +2 -2
  134. data/src/cxx_supportlib/Utils/MessagePassing.h +1 -1
  135. data/src/cxx_supportlib/Utils/SpeedMeter.h +2 -2
  136. data/src/cxx_supportlib/Utils/Timer.h +2 -2
  137. data/src/cxx_supportlib/Utils/VariantMap.h +3 -3
  138. data/src/cxx_supportlib/WatchdogLauncher.h +3 -3
  139. data/src/cxx_supportlib/WebSocketCommandReverseServer.h +1 -1
  140. data/src/cxx_supportlib/WrapperRegistry/Registry.h +1 -1
  141. data/src/cxx_supportlib/vendor-modified/psg_sysqueue.h +3 -0
  142. data/src/ruby_supportlib/phusion_passenger.rb +1 -1
  143. data/src/ruby_supportlib/phusion_passenger/common_library.rb +11 -11
  144. data/src/ruby_supportlib/phusion_passenger/config/agent_compiler.rb +4 -4
  145. data/src/ruby_supportlib/phusion_passenger/config/nginx_engine_compiler.rb +1 -1
  146. data/src/ruby_supportlib/phusion_passenger/message_channel.rb +2 -2
  147. data/src/ruby_supportlib/phusion_passenger/packaging.rb +20 -19
  148. data/src/ruby_supportlib/phusion_passenger/platform_info/apache.rb +22 -4
  149. data/src/ruby_supportlib/phusion_passenger/platform_info/ruby.rb +33 -13
  150. data/src/schema_printer/SchemaPrinterMain.cpp +2 -0
  151. metadata +28 -86
  152. data/.editorconfig +0 -134
  153. data/CODE_OF_CONDUCT.md +0 -52
  154. data/dev/boost-patches/0001-Patch-boost-thread-so-that-oxt-thread-can-use-it.patch +0 -48
  155. data/dev/boost-patches/0002-Make-boost-thread_interrupted-derive-from-oxt-tracab.patch +0 -33
  156. data/dev/boost-patches/0003-Disable-a-Clang-pragma-to-prevent-warnings-on-OS-X.patch +0 -25
  157. data/dev/ci/README.md +0 -134
  158. data/dev/ci/lib/functions.sh +0 -129
  159. data/dev/ci/lib/set-container-envvars.sh +0 -53
  160. data/dev/ci/lib/setup-container.sh +0 -46
  161. data/dev/ci/run-tests-natively +0 -24
  162. data/dev/ci/run-tests-with-docker +0 -42
  163. data/dev/ci/scripts/debug-console-wrapper.sh +0 -29
  164. data/dev/ci/scripts/docker-entrypoint-stage2.sh +0 -17
  165. data/dev/ci/scripts/docker-entrypoint.sh +0 -17
  166. data/dev/ci/scripts/inituidgid +0 -17
  167. data/dev/ci/scripts/run-tests-natively-stage2.sh +0 -17
  168. data/dev/ci/scripts/setup-host-natively.sh +0 -11
  169. data/dev/ci/setup-host +0 -56
  170. data/dev/ci/tests/apache2/run +0 -6
  171. data/dev/ci/tests/apache2/setup +0 -4
  172. data/dev/ci/tests/binaries/Jenkinsfile +0 -105
  173. data/dev/ci/tests/binaries/build-linux +0 -38
  174. data/dev/ci/tests/binaries/build-macos +0 -40
  175. data/dev/ci/tests/binaries/prepare-macos +0 -38
  176. data/dev/ci/tests/binaries/test-linux +0 -45
  177. data/dev/ci/tests/binaries/test-macos +0 -38
  178. data/dev/ci/tests/cxx/run +0 -9
  179. data/dev/ci/tests/cxx/setup +0 -4
  180. data/dev/ci/tests/debian/Jenkinsfile +0 -89
  181. data/dev/ci/tests/debian/run +0 -60
  182. data/dev/ci/tests/nginx-dynamic/run +0 -20
  183. data/dev/ci/tests/nginx-dynamic/setup +0 -4
  184. data/dev/ci/tests/nginx/run +0 -5
  185. data/dev/ci/tests/nginx/setup +0 -4
  186. data/dev/ci/tests/nodejs/run +0 -4
  187. data/dev/ci/tests/nodejs/setup +0 -4
  188. data/dev/ci/tests/rpm/Jenkinsfile +0 -68
  189. data/dev/ci/tests/rpm/run +0 -63
  190. data/dev/ci/tests/ruby/run +0 -4
  191. data/dev/ci/tests/ruby/setup +0 -4
  192. data/dev/ci/tests/source-packaging/run +0 -4
  193. data/dev/ci/tests/source-packaging/setup +0 -4
  194. data/dev/ci/tests/standalone/run +0 -4
  195. data/dev/ci/tests/standalone/setup +0 -4
  196. data/dev/configkit-schemas/index.json +0 -1850
  197. data/dev/configkit-schemas/update_schema_inline_comments.rb +0 -118
  198. data/dev/rack.test/config.ru +0 -5
  199. data/dev/rack.test/public/asset.txt +0 -1
  200. data/dev/vagrant/apache_default_site.conf +0 -35
  201. data/dev/vagrant/apache_passenger.conf +0 -5
  202. data/dev/vagrant/apache_passenger.load +0 -1
  203. data/dev/vagrant/apache_ports.conf +0 -24
  204. data/dev/vagrant/apache_rack_test.conf +0 -9
  205. data/dev/vagrant/bashrc +0 -23
  206. data/dev/vagrant/nginx.conf +0 -39
  207. data/dev/vagrant/nginx_rakefile +0 -33
  208. data/dev/vagrant/nginx_start +0 -32
  209. data/dev/vagrant/provision.sh +0 -117
  210. data/dev/vagrant/sudoers.conf +0 -5
  211. data/resources/templates/error_renderer/.editorconfig +0 -19
@@ -60,7 +60,7 @@ Passenger::SpawningKit::Result::validate_autoGeneratedCode(vector<StaticString>
60
60
  /*
61
61
  * Excluded:
62
62
  *
63
- * dummy
63
+ * type
64
64
  * codeRevision
65
65
  * stdinFd
66
66
  * stdoutAndErrFd
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Phusion Passenger - https://www.phusionpassenger.com/
3
- * Copyright (c) 2011-2017 Phusion Holding B.V.
3
+ * Copyright (c) 2011-2018 Phusion Holding B.V.
4
4
  *
5
5
  * "Passenger", "Phusion Passenger" and "Union Station" are registered
6
6
  * trademarks of Phusion Holding B.V.
@@ -50,12 +50,12 @@
50
50
  #include <Exceptions.h>
51
51
  #include <DataStructures/StringKeyTable.h>
52
52
  #include <ProcessManagement/Utils.h>
53
+ #include <SystemTools/ProcessMetricsCollector.h>
54
+ #include <SystemTools/SystemTime.h>
53
55
  #include <FileTools/FileManip.h>
54
- #include <Utils/SystemTime.h>
55
- #include <Utils/BufferedIO.h>
56
- #include <Utils/JsonUtils.h>
56
+ #include <IOTools/BufferedIO.h>
57
+ #include <JsonTools/JsonUtils.h>
57
58
  #include <Utils/ScopeGuard.h>
58
- #include <Utils/ProcessMetricsCollector.h>
59
59
  #include <Utils/AsyncSignalSafeUtils.h>
60
60
  #include <LveLoggingDecorator.h>
61
61
  #include <Core/SpawningKit/Spawner.h>
@@ -374,7 +374,7 @@ private:
374
374
  dup2(stdinCopy, 0);
375
375
  dup2(stdoutAndErrCopy, 1);
376
376
  dup2(stdoutAndErrCopy, 2);
377
- closeAllFileDescriptors(2, true);
377
+ closeAllFileDescriptors(2);
378
378
 
379
379
  execlp(agentFilename.c_str(),
380
380
  agentFilename.c_str(),
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Phusion Passenger - https://www.phusionpassenger.com/
3
- * Copyright (c) 2011-2017 Phusion Holding B.V.
3
+ * Copyright (c) 2011-2018 Phusion Holding B.V.
4
4
  *
5
5
  * "Passenger", "Phusion Passenger" and "Union Station" are registered
6
6
  * trademarks of Phusion Holding B.V.
@@ -32,7 +32,7 @@
32
32
  #include <modp_b64.h>
33
33
 
34
34
  #include <LoggingKit/Logging.h>
35
- #include <Utils/SystemTime.h>
35
+ #include <SystemTools/SystemTime.h>
36
36
  #include <Core/SpawningKit/Context.h>
37
37
  #include <Core/SpawningKit/Result.h>
38
38
  #include <Core/SpawningKit/UserSwitchingRules.h>
@@ -46,7 +46,7 @@
46
46
  #include <LoggingKit/LoggingKit.h>
47
47
  #include <ConfigKit/ConfigKit.h>
48
48
  #include <Utils/Curl.h>
49
- #include <Utils/StrIntUtils.h>
49
+ #include <StrIntTools/StrIntUtils.h>
50
50
 
51
51
  namespace Passenger {
52
52
  namespace Core {
@@ -57,15 +57,21 @@ using namespace std;
57
57
  class TelemetryCollector {
58
58
  public:
59
59
  /*
60
- * BEGIN ConfigKit schema: Passenger::TelemetryCollector::Schema
60
+ * BEGIN ConfigKit schema: Passenger::Core::TelemetryCollector::Schema
61
61
  * (do not edit: following text is automatically generated
62
62
  * by 'rake configkit_schemas_inline_comments')
63
63
  *
64
- * (unknown: Passenger::TelemetryCollector::Schema not in dev/configkit-schemas/index.json
65
- * Please run:
66
- * touch src/schema_printer/SchemaPrinterMain.cpp.cxxcodebuilder
67
- * rake configkit_schemas_inline_comments
68
- * )
64
+ * ca_certificate_path string - -
65
+ * debug_curl boolean - default(false)
66
+ * disabled boolean - default(false)
67
+ * final_run_timeout unsigned integer - default(5)
68
+ * first_interval unsigned integer - default(7200)
69
+ * interval unsigned integer - default(21600)
70
+ * interval_jitter unsigned integer - default(7200)
71
+ * proxy_url string - -
72
+ * timeout unsigned integer - default(180)
73
+ * url string - default("https://anontelemetry.phusionpassenger.com/v1/collect.json")
74
+ * verify_server boolean - default(true)
69
75
  *
70
76
  * END
71
77
  */
@@ -40,7 +40,7 @@
40
40
  #include <Constants.h>
41
41
  #include <ProcessManagement/Utils.h>
42
42
  #include <Utils/OptionParsing.h>
43
- #include <Utils/StrIntUtils.h>
43
+ #include <StrIntTools/StrIntUtils.h>
44
44
 
45
45
  namespace Passenger {
46
46
  namespace ExecHelper {
@@ -12,7 +12,7 @@ The most important parts are:
12
12
  ## Minor parts
13
13
 
14
14
  * SpawnEnvSetupper is a tool used internally by `Core/SpawningKit/` to spawn application processes. See the README in that directory for more information.
15
- * SystemMetrics is a tool that shows system metrics such as CPU and memory usage. The main functionality is implemented in src/cxxUtils/SystemMetricsCollector.h. This tool is mainly useful for developing and debugging SystemMetricsCollector.h.
15
+ * SystemMetrics is a tool that shows system metrics such as CPU and memory usage. The main functionality is implemented in src/cxx/SystemTools/SystemMetricsCollector.h. This tool is mainly useful for developing and debugging SystemMetricsCollector.h.
16
16
  * TempDirToucher is a tool used internally by Passenger Standalone to keep a temporary directory's timestamp up-to-date so that it doesn't get removed by /tmp cleaner daemons.
17
17
 
18
18
  ## Shared code
@@ -38,7 +38,7 @@
38
38
  #include <StaticString.h>
39
39
  #include <FileTools/PathManip.h>
40
40
  #include <Utils.h>
41
- #include <Utils/StrIntUtils.h>
41
+ #include <StrIntTools/StrIntUtils.h>
42
42
 
43
43
  namespace Passenger {
44
44
  namespace ApiAccountUtils { // Avoid conflict with classes of the same name in ApiServerUtils.h, until we've migrated everything
@@ -72,9 +72,9 @@
72
72
  #include <LoggingKit/LoggingKit.h>
73
73
  #include <LoggingKit/Context.h>
74
74
  #include <Utils.h>
75
- #include <Utils/IOUtils.h>
76
- #include <Utils/BufferedIO.h>
77
- #include <Utils/StrIntUtils.h>
75
+ #include <IOTools/IOUtils.h>
76
+ #include <IOTools/BufferedIO.h>
77
+ #include <StrIntTools/StrIntUtils.h>
78
78
  #include <Utils/VariantMap.h>
79
79
  #include <Shared/ApplicationPoolApiKey.h>
80
80
 
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Phusion Passenger - https://www.phusionpassenger.com/
3
- * Copyright (c) 2015-2017 Phusion Holding B.V.
3
+ * Copyright (c) 2015-2018 Phusion Holding B.V.
4
4
  *
5
5
  * "Passenger", "Phusion Passenger" and "Union Station" are registered
6
6
  * trademarks of Phusion Holding B.V.
@@ -31,7 +31,7 @@
31
31
  #include <cstring>
32
32
  #include <Exceptions.h>
33
33
  #include <StaticString.h>
34
- #include <Utils/StrIntUtils.h>
34
+ #include <StrIntTools/StrIntUtils.h>
35
35
 
36
36
  namespace Passenger {
37
37
  namespace ApplicationPool2 {
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Phusion Passenger - https://www.phusionpassenger.com/
3
- * Copyright (c) 2010-2017 Phusion Holding B.V.
3
+ * Copyright (c) 2010-2018 Phusion Holding B.V.
4
4
  *
5
5
  * "Passenger", "Phusion Passenger" and "Union Station" are registered
6
6
  * trademarks of Phusion Holding B.V.
@@ -50,9 +50,9 @@
50
50
  #include <ResourceLocator.h>
51
51
  #include <LoggingKit/LoggingKit.h>
52
52
  #include <LoggingKit/Context.h>
53
- #include <Utils/StrIntUtils.h>
54
- #include <Utils/MessageIO.h>
55
- #include <Utils/SystemTime.h>
53
+ #include <StrIntTools/StrIntUtils.h>
54
+ #include <IOTools/MessageIO.h>
55
+ #include <SystemTools/SystemTime.h>
56
56
 
57
57
 
58
58
  namespace Passenger {
@@ -64,7 +64,7 @@
64
64
  #include <FileTools/PathManip.h>
65
65
  #include <SystemTools/UserDatabase.h>
66
66
  #include <Utils.h>
67
- #include <Utils/StrIntUtils.h>
67
+ #include <StrIntTools/StrIntUtils.h>
68
68
  #include <Core/SpawningKit/Handshake/WorkDir.h>
69
69
  #include <Core/SpawningKit/Exceptions.h>
70
70
 
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Phusion Passenger - https://www.phusionpassenger.com/
3
- * Copyright (c) 2014-2017 Phusion Holding B.V.
3
+ * Copyright (c) 2014-2018 Phusion Holding B.V.
4
4
  *
5
5
  * "Passenger", "Phusion Passenger" and "Union Station" are registered
6
6
  * trademarks of Phusion Holding B.V.
@@ -28,9 +28,10 @@
28
28
  #include <unistd.h>
29
29
  #include <cstdio>
30
30
  #include <cstring>
31
+
32
+ #include <SystemTools/SystemMetricsCollector.h>
31
33
  #include <Utils.h>
32
- #include <Utils/StrIntUtils.h>
33
- #include <Utils/SystemMetricsCollector.h>
34
+ #include <StrIntTools/StrIntUtils.h>
34
35
 
35
36
  using namespace std;
36
37
  using namespace Passenger;
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Phusion Passenger - https://www.phusionpassenger.com/
3
- * Copyright (c) 2014-2017 Phusion Holding B.V.
3
+ * Copyright (c) 2014-2018 Phusion Holding B.V.
4
4
  *
5
5
  * "Passenger", "Phusion Passenger" and "Union Station" are registered
6
6
  * trademarks of Phusion Holding B.V.
@@ -40,8 +40,8 @@
40
40
  #include <StaticString.h>
41
41
  #include <LoggingKit/LoggingKit.h>
42
42
  #include <Constants.h>
43
- #include <Utils/StrIntUtils.h>
44
- #include <Utils/MessageIO.h>
43
+ #include <StrIntTools/StrIntUtils.h>
44
+ #include <IOTools/MessageIO.h>
45
45
 
46
46
  namespace Passenger {
47
47
  namespace Watchdog {
@@ -33,7 +33,7 @@
33
33
  #include <Watchdog/ApiServer.h>
34
34
  #include <Shared/ApiAccountUtils.h>
35
35
  #include <Utils.h>
36
- #include <Utils/StrIntUtils.h>
36
+ #include <StrIntTools/StrIntUtils.h>
37
37
 
38
38
  namespace Passenger {
39
39
  namespace Watchdog {
@@ -146,7 +146,7 @@ using namespace std;
146
146
  * security_update_checker_interval unsigned integer - default(86400)
147
147
  * security_update_checker_proxy_url string - -
148
148
  * security_update_checker_url string - default("https://securitycheck.phusionpassenger.com/v1/check.json")
149
- * server_software string - default("Phusion_Passenger/5.3.5")
149
+ * server_software string - default("Phusion_Passenger/5.3.6")
150
150
  * setsid boolean - default(false)
151
151
  * show_version_in_header boolean - default(true)
152
152
  * single_app_mode_app_root string - default,read_only
@@ -296,6 +296,7 @@ public:
296
296
  core.translator.finalize();
297
297
  addSubSchema(core.schema, core.translator);
298
298
  erase("instance_dir");
299
+ erase("oom_score");
299
300
  erase("watchdog_fd_passing_password");
300
301
  /***********/
301
302
  /***********/
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Phusion Passenger - https://www.phusionpassenger.com/
3
- * Copyright (c) 2010-2017 Phusion Holding B.V.
3
+ * Copyright (c) 2010-2018 Phusion Holding B.V.
4
4
  *
5
5
  * "Passenger", "Phusion Passenger" and "Union Station" are registered
6
6
  * trademarks of Phusion Holding B.V.
@@ -25,7 +25,7 @@
25
25
  */
26
26
 
27
27
  #include <Shared/Fundamentals/Utils.h>
28
- #include <Utils/MessageIO.h>
28
+ #include <IOTools/MessageIO.h>
29
29
 
30
30
  class CoreWatcher: public AgentWatcher {
31
31
  protected:
@@ -73,18 +73,19 @@
73
73
  #include <FileDescriptor.h>
74
74
  #include <FileTools/PathSecurityCheck.h>
75
75
  #include <SystemTools/UserDatabase.h>
76
+ #include <SystemTools/ContainerHelpers.h>
76
77
  #include <RandomGenerator.h>
77
78
  #include <BackgroundEventLoop.h>
78
79
  #include <LoggingKit/LoggingKit.h>
79
80
  #include <Exceptions.h>
80
81
  #include <StaticString.h>
81
82
  #include <Hooks.h>
83
+ #include <IOTools/IOUtils.h>
84
+ #include <IOTools/MessageIO.h>
82
85
  #include <Utils.h>
83
86
  #include <Utils/Timer.h>
84
87
  #include <Utils/ScopeGuard.h>
85
- #include <Utils/StrIntUtils.h>
86
- #include <Utils/IOUtils.h>
87
- #include <Utils/MessageIO.h>
88
+ #include <StrIntTools/StrIntUtils.h>
88
89
  #include <Utils/OptionParsing.h>
89
90
  #include <Utils/VariantMap.h>
90
91
 
@@ -180,8 +181,22 @@ static void cleanup(const WorkingObjectsPtr &wo);
180
181
  /***** Functions *****/
181
182
 
182
183
  #if !BOOST_OS_MACOS
184
+
185
+ struct WatchdogOomAdjustResult {
186
+ struct Message {
187
+ LoggingKit::Level level;
188
+ string text;
189
+ };
190
+
191
+ string oldScore;
192
+ // LoggingKit has not been initialized yet when setOomScoreNeverKill()
193
+ // is called, so we store the messages here and print them after
194
+ // LoggingKit initialization.
195
+ vector<Message> messages;
196
+ };
197
+
183
198
  static FILE *
184
- openOomAdjFileGetType(const char *mode, OomFileType &type) {
199
+ openOomAdjFileGetType(const char *mode, OomFileType &type, string &path) {
185
200
  FILE *f = fopen("/proc/self/oom_score_adj", mode);
186
201
  if (f == NULL) {
187
202
  f = fopen("/proc/self/oom_adj", mode);
@@ -189,40 +204,46 @@ openOomAdjFileGetType(const char *mode, OomFileType &type) {
189
204
  return NULL;
190
205
  } else {
191
206
  type = OOM_ADJ;
207
+ path = "/proc/self/oom_adj";
192
208
  return f;
193
209
  }
194
210
  } else {
195
211
  type = OOM_SCORE_ADJ;
212
+ path = "/proc/self/oom_score_adj";
196
213
  return f;
197
214
  }
198
215
  }
199
216
 
200
- static FILE *
201
- openOomAdjFileForcedType(const char *mode, OomFileType &type) {
202
- if (type == OOM_SCORE_ADJ) {
203
- return fopen("/proc/self/oom_score_adj", mode);
204
- } else {
205
- assert(type == OOM_ADJ);
206
- return fopen("/proc/self/oom_adj", mode);
207
- }
208
- }
209
-
210
217
  /**
211
218
  * Set the current process's OOM score to "never kill".
212
219
  */
213
- static string
220
+ static WatchdogOomAdjustResult
214
221
  setOomScoreNeverKill() {
215
- string oldScore;
222
+ WatchdogOomAdjustResult result;
216
223
  FILE *f;
224
+ string path;
217
225
  OomFileType type;
226
+ int e;
227
+
228
+ if (geteuid() != 0) {
229
+ WatchdogOomAdjustResult::Message msg;
230
+ msg.level = LoggingKit::DEBUG;
231
+ msg.text = "Not adjusting Watchdog's OOM score because not running with root privileges";
232
+ result.messages.push_back(msg);
233
+ return result;
234
+ }
218
235
 
219
- f = openOomAdjFileGetType("r", type);
236
+ f = openOomAdjFileGetType("r", type, path);
220
237
  if (f == NULL) {
221
- return "";
238
+ e = errno;
239
+ P_ERROR("Error adjusting Watchdog's OOM score: error opening both"
240
+ " /proc/self/oom_score_adj and /proc/self/oom_adj for reading: " <<
241
+ strerror(e) << " (errno=" << e << ")");
242
+ return result;
222
243
  }
223
244
  // mark if this is a legacy score so we won't try to write it as OOM_SCORE_ADJ
224
245
  if (type == OOM_ADJ) {
225
- oldScore.append("l");
246
+ result.oldScore.append("l");
226
247
  }
227
248
  char buf[1024];
228
249
  size_t bytesRead;
@@ -231,17 +252,27 @@ setOomScoreNeverKill() {
231
252
  if (bytesRead == 0 && feof(f)) {
232
253
  break;
233
254
  } else if (bytesRead == 0 && ferror(f)) {
255
+ P_ERROR("Error adjusting Watchdog's OOM score: error reading " << path);
234
256
  fclose(f);
235
- return "";
257
+ result.oldScore.clear();
258
+ return result;
236
259
  } else {
237
- oldScore.append(buf, bytesRead);
260
+ result.oldScore.append(buf, bytesRead);
238
261
  }
239
262
  }
240
263
  fclose(f);
241
264
 
242
- f = openOomAdjFileForcedType("w", type);
265
+ f = fopen(path.c_str(), "w");
243
266
  if (f == NULL) {
244
- return "";
267
+ e = errno;
268
+ WatchdogOomAdjustResult::Message msg;
269
+ msg.level = LoggingKit::ERROR;
270
+ msg.text = "Error adjusting Watchdog's OOM score: error opening "
271
+ + path + " for writing: " + strerror(e) + " (errno="
272
+ + toString(e) + ")";
273
+ result.messages.push_back(msg);
274
+ result.oldScore.clear();
275
+ return result;
245
276
  }
246
277
  if (type == OOM_SCORE_ADJ) {
247
278
  fprintf(f, "-1000\n");
@@ -249,10 +280,44 @@ setOomScoreNeverKill() {
249
280
  assert(type == OOM_ADJ);
250
281
  fprintf(f, "-17\n");
251
282
  }
252
- fclose(f);
253
283
 
254
- return oldScore;
284
+ e = fflush(f);
285
+ if (e != 0) {
286
+ e = errno;
287
+ WatchdogOomAdjustResult::Message msg;
288
+ if (autoDetectInContainer()) {
289
+ msg.level = LoggingKit::INFO;
290
+ msg.text = "Running in container, so couldn't adjust Watchdog's"
291
+ " OOM score through " + path;
292
+ } else {
293
+ msg.level = LoggingKit::ERROR;
294
+ msg.text = "Error adjusting Watchdog's OOM score: error writing to "
295
+ + path + ": " + strerror(e) + " (errno=" + toString(e) + ")";
296
+ }
297
+ result.messages.push_back(msg);
298
+ }
299
+ e = fclose(f);
300
+ if (e == EOF) {
301
+ e = errno;
302
+ WatchdogOomAdjustResult::Message msg;
303
+ msg.level = LoggingKit::ERROR;
304
+ msg.text = "Error adjusting Watchdog's OOM score: error closing "
305
+ + path + ": " + strerror(e) + " (errno=" + toString(e) + ")";
306
+ result.messages.push_back(msg);
307
+ }
308
+
309
+ return result;
310
+ }
311
+
312
+ static void
313
+ printOomAdjustResultMessages(const WatchdogOomAdjustResult &result) {
314
+ vector<WatchdogOomAdjustResult::Message>::const_iterator it;
315
+
316
+ for (it = result.messages.begin(); it != result.messages.end(); it++) {
317
+ P_LOG(LoggingKit::context, it->level, __FILE__, __LINE__, it->text);
318
+ }
255
319
  }
320
+
256
321
  #endif
257
322
 
258
323
  static void
@@ -798,7 +863,7 @@ initializeBareEssentials(int argc, char *argv[], WorkingObjectsPtr &wo) {
798
863
  * so we need to restore it after each fork().
799
864
  */
800
865
  #if !BOOST_OS_MACOS
801
- string oldOomScore = setOomScoreNeverKill();
866
+ WatchdogOomAdjustResult oomAdjustResult = setOomScoreNeverKill();
802
867
  #endif
803
868
 
804
869
  watchdogWrapperRegistry = new WrapperRegistry::Registry();
@@ -815,7 +880,8 @@ initializeBareEssentials(int argc, char *argv[], WorkingObjectsPtr &wo) {
815
880
  wo = boost::make_shared<WorkingObjects>();
816
881
  workingObjects = wo.get();
817
882
  #if !BOOST_OS_MACOS
818
- wo->extraConfigToPassToSubAgents["oom_score"] = oldOomScore;
883
+ printOomAdjustResultMessages(oomAdjustResult);
884
+ wo->extraConfigToPassToSubAgents["oom_score"] = oomAdjustResult.oldScore;
819
885
  #endif
820
886
  }
821
887