passenger 5.3.4 → 6.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (283) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +69 -0
  3. data/CONTRIBUTORS +1 -0
  4. data/README.md +2 -1
  5. data/Rakefile +0 -5
  6. data/build/agent.rb +6 -3
  7. data/build/cxx_tests.rb +28 -19
  8. data/build/integration_tests.rb +6 -2
  9. data/build/misc.rb +2 -1
  10. data/build/packaging.rb +2 -0
  11. data/build/support/cplusplus.rb +2 -2
  12. data/build/support/cxx_dependency_map.rb +2651 -2189
  13. data/dev/colorize-logs +272 -0
  14. data/dev/show-latest-crashlog-dir +27 -0
  15. data/resources/templates/standalone/http.erb +2 -0
  16. data/resources/templates/standalone/server.erb +1 -0
  17. data/src/agent/AgentMain.cpp +4 -0
  18. data/src/agent/Core/AdminPanelConnector.h +6 -6
  19. data/src/agent/Core/ApiServer.h +4 -4
  20. data/src/agent/Core/ApplicationPool/BasicProcessInfo.h +2 -2
  21. data/src/agent/Core/ApplicationPool/Context.h +5 -1
  22. data/src/agent/Core/ApplicationPool/Group/InternalUtils.cpp +2 -2
  23. data/src/agent/Core/ApplicationPool/Group/LifetimeAndBasics.cpp +5 -0
  24. data/src/agent/Core/ApplicationPool/Group/Miscellaneous.cpp +2 -1
  25. data/src/agent/Core/ApplicationPool/Group/OutOfBandWork.cpp +3 -3
  26. data/src/agent/Core/ApplicationPool/Group/ProcessListManagement.cpp +1 -1
  27. data/src/agent/Core/ApplicationPool/Group/StateInspection.cpp +13 -20
  28. data/src/agent/Core/ApplicationPool/Group.h +4 -2
  29. data/src/agent/Core/ApplicationPool/Implementation.cpp +5 -5
  30. data/src/agent/Core/ApplicationPool/Options.h +42 -38
  31. data/src/agent/Core/ApplicationPool/Pool/GroupUtils.cpp +2 -1
  32. data/src/agent/Core/ApplicationPool/Pool.h +4 -4
  33. data/src/agent/Core/ApplicationPool/Process.h +13 -15
  34. data/src/agent/Core/ApplicationPool/Socket.h +5 -5
  35. data/src/agent/Core/ApplicationPool/TestSession.h +3 -3
  36. data/src/agent/Core/Config.h +50 -10
  37. data/src/agent/Core/ConfigChange.cpp +13 -1
  38. data/src/agent/Core/Controller/Config.h +41 -17
  39. data/src/agent/Core/Controller/ForwardResponse.cpp +4 -0
  40. data/src/agent/Core/Controller/InitRequest.cpp +14 -8
  41. data/src/agent/Core/Controller/InitializationAndShutdown.cpp +5 -0
  42. data/src/agent/Core/Controller/SendRequest.cpp +9 -9
  43. data/src/agent/Core/Controller/TurboCaching.h +2 -2
  44. data/src/agent/Core/Controller.h +7 -5
  45. data/src/agent/Core/CoreMain.cpp +204 -60
  46. data/src/agent/Core/OptionParser.h +20 -3
  47. data/src/agent/Core/ResponseCache.h +3 -3
  48. data/src/agent/Core/SecurityUpdateChecker.h +4 -2
  49. data/src/agent/Core/SpawningKit/Config/AutoGeneratedCode.h +1 -1
  50. data/src/agent/Core/SpawningKit/Config.h +3 -2
  51. data/src/agent/Core/SpawningKit/Context.h +8 -2
  52. data/src/agent/Core/SpawningKit/DirectSpawner.h +4 -4
  53. data/src/agent/Core/SpawningKit/DummySpawner.h +3 -3
  54. data/src/agent/Core/SpawningKit/ErrorRenderer.h +1 -1
  55. data/src/agent/Core/SpawningKit/Exceptions.h +21 -14
  56. data/src/agent/Core/SpawningKit/Factory.h +1 -1
  57. data/src/agent/Core/SpawningKit/Handshake/BackgroundIOCapturer.h +1 -1
  58. data/src/agent/Core/SpawningKit/Handshake/Perform.h +14 -2
  59. data/src/agent/Core/SpawningKit/Handshake/Prepare.h +3 -3
  60. data/src/agent/Core/SpawningKit/Handshake/WorkDir.h +1 -1
  61. data/src/agent/Core/SpawningKit/Journey.h +4 -5
  62. data/src/agent/Core/SpawningKit/PipeWatcher.h +1 -1
  63. data/src/agent/Core/SpawningKit/README.md +34 -17
  64. data/src/agent/Core/SpawningKit/Result/AutoGeneratedCode.h +1 -1
  65. data/src/agent/Core/SpawningKit/Result.h +20 -8
  66. data/src/agent/Core/SpawningKit/SmartSpawner.h +7 -7
  67. data/src/agent/Core/SpawningKit/Spawner.h +25 -8
  68. data/src/agent/Core/SpawningKit/UserSwitchingRules.h +17 -7
  69. data/src/agent/Core/TelemetryCollector.h +681 -0
  70. data/src/agent/ExecHelper/ExecHelperMain.cpp +1 -1
  71. data/src/agent/FileReadHelper/FileReadHelperMain.cpp +198 -0
  72. data/src/agent/README.md +1 -1
  73. data/src/agent/Shared/ApiAccountUtils.h +1 -1
  74. data/src/agent/Shared/ApiServerUtils.h +3 -3
  75. data/src/agent/Shared/ApplicationPoolApiKey.h +2 -2
  76. data/src/agent/Shared/Fundamentals/AbortHandler.cpp +324 -98
  77. data/src/agent/Shared/Fundamentals/AbortHandler.h +31 -4
  78. data/src/agent/Shared/Fundamentals/Initialization.cpp +4 -5
  79. data/src/agent/Shared/Fundamentals/Initialization.h +9 -1
  80. data/src/agent/SpawnEnvSetupper/SpawnEnvSetupperMain.cpp +1 -1
  81. data/src/agent/SystemMetrics/SystemMetricsMain.cpp +4 -3
  82. data/src/agent/TempDirToucher/TempDirToucherMain.cpp +3 -3
  83. data/src/agent/Watchdog/ApiServer.h +3 -3
  84. data/src/agent/Watchdog/Config.h +24 -5
  85. data/src/agent/Watchdog/CoreWatcher.cpp +2 -2
  86. data/src/agent/Watchdog/WatchdogMain.cpp +97 -28
  87. data/src/apache2_module/Config.cpp +14 -14
  88. data/src/apache2_module/Config.h +8 -16
  89. data/src/apache2_module/ConfigGeneral/AutoGeneratedDefinitions.cpp +510 -481
  90. data/src/apache2_module/ConfigGeneral/AutoGeneratedDefinitions.cpp.cxxcodebuilder +39 -17
  91. data/src/apache2_module/ConfigGeneral/AutoGeneratedManifestDefaultsInitialization.cpp +5 -0
  92. data/src/apache2_module/ConfigGeneral/AutoGeneratedSetterFuncs.cpp +69 -1
  93. data/src/apache2_module/ConfigGeneral/AutoGeneratedSetterFuncs.cpp.cxxcodebuilder +31 -1
  94. data/src/apache2_module/ConfigGeneral/Common.h +45 -0
  95. data/src/apache2_module/DirConfig/AutoGeneratedCreateFunction.cpp +17 -1
  96. data/src/apache2_module/DirConfig/AutoGeneratedCreateFunction.cpp.cxxcodebuilder +16 -1
  97. data/src/apache2_module/DirConfig/AutoGeneratedHeaderSerialization.cpp +19 -5
  98. data/src/apache2_module/DirConfig/AutoGeneratedHeaderSerialization.cpp.cxxcodebuilder +26 -9
  99. data/src/apache2_module/DirConfig/AutoGeneratedManifestGeneration.cpp +19 -1
  100. data/src/apache2_module/DirConfig/AutoGeneratedManifestGeneration.cpp.cxxcodebuilder +10 -1
  101. data/src/apache2_module/DirConfig/AutoGeneratedMergeFunction.cpp +14 -1
  102. data/src/apache2_module/DirConfig/AutoGeneratedMergeFunction.cpp.cxxcodebuilder +11 -1
  103. data/src/apache2_module/DirConfig/AutoGeneratedStruct.h +36 -1
  104. data/src/apache2_module/DirConfig/AutoGeneratedStruct.h.cxxcodebuilder +34 -1
  105. data/src/apache2_module/DirectoryMapper.h +36 -37
  106. data/src/apache2_module/Hooks.cpp +27 -8
  107. data/src/apache2_module/ServerConfig/AutoGeneratedManifestGeneration.cpp +20 -0
  108. data/src/apache2_module/ServerConfig/AutoGeneratedStruct.h +48 -1
  109. data/src/apache2_module/ServerConfig/AutoGeneratedStruct.h.cxxcodebuilder +36 -1
  110. data/src/cxx_supportlib/{Utils → Algorithms}/Hasher.cpp +2 -2
  111. data/src/cxx_supportlib/{Utils → Algorithms}/Hasher.h +4 -4
  112. data/src/cxx_supportlib/AppLocalConfigFileUtils.h +148 -0
  113. data/src/cxx_supportlib/AppTypeDetector/CBindings.cpp +147 -0
  114. data/src/cxx_supportlib/AppTypeDetector/CBindings.h +75 -0
  115. data/src/cxx_supportlib/{AppTypes.h → AppTypeDetector/Detector.h} +92 -131
  116. data/src/cxx_supportlib/ConfigKit/README.md +90 -2
  117. data/src/cxx_supportlib/ConfigKit/Schema.h +60 -15
  118. data/src/cxx_supportlib/ConfigKit/Store.h +129 -5
  119. data/src/cxx_supportlib/Constants.h +1 -1
  120. data/src/cxx_supportlib/{Utils → DataStructures}/HashMap.h +4 -4
  121. data/src/cxx_supportlib/DataStructures/HashedStaticString.h +5 -5
  122. data/src/cxx_supportlib/DataStructures/LString.h +3 -3
  123. data/src/cxx_supportlib/{Utils → DataStructures}/StringMap.h +36 -36
  124. data/src/cxx_supportlib/FileTools/FileManip.cpp +1 -1
  125. data/src/cxx_supportlib/FileTools/PathManip.cpp +2 -2
  126. data/src/cxx_supportlib/FileTools/PathSecurityCheck.cpp +1 -1
  127. data/src/cxx_supportlib/Hooks.h +2 -2
  128. data/src/cxx_supportlib/{Utils → IOTools}/BufferedIO.h +5 -5
  129. data/src/cxx_supportlib/{Utils → IOTools}/IOUtils.cpp +4 -3
  130. data/src/cxx_supportlib/{Utils → IOTools}/IOUtils.h +3 -3
  131. data/src/cxx_supportlib/{Utils → IOTools}/MessageIO.h +7 -7
  132. data/src/cxx_supportlib/{MessageReadersWriters.h → IOTools/MessageSerialization.h} +5 -5
  133. data/src/cxx_supportlib/InstanceDirectory.h +4 -4
  134. data/src/cxx_supportlib/Integrations/LibevJsonUtils.h +3 -3
  135. data/src/cxx_supportlib/{Utils → JsonTools}/JsonUtils.h +5 -5
  136. data/src/cxx_supportlib/LoggingKit/Context.h +2 -2
  137. data/src/cxx_supportlib/LoggingKit/Implementation.cpp +3 -3
  138. data/src/cxx_supportlib/MemoryKit/mbuf.cpp +2 -2
  139. data/src/cxx_supportlib/ProcessManagement/Ruby.cpp +3 -3
  140. data/src/cxx_supportlib/ProcessManagement/Ruby.h +7 -2
  141. data/src/cxx_supportlib/ProcessManagement/Spawn.cpp +19 -12
  142. data/src/cxx_supportlib/ProcessManagement/Spawn.h +21 -2
  143. data/src/cxx_supportlib/ProcessManagement/Utils.h +10 -0
  144. data/src/cxx_supportlib/RandomGenerator.h +2 -2
  145. data/src/cxx_supportlib/ResourceLocator.h +1 -1
  146. data/src/cxx_supportlib/{Crypto.cpp → SecurityKit/Crypto.cpp} +4 -4
  147. data/src/cxx_supportlib/{Crypto.h → SecurityKit/Crypto.h} +4 -4
  148. data/src/cxx_supportlib/{Utils → SecurityKit}/MemZeroGuard.h +0 -0
  149. data/src/cxx_supportlib/ServerKit/AcceptLoadBalancer.h +2 -2
  150. data/src/cxx_supportlib/ServerKit/Channel.h +1 -1
  151. data/src/cxx_supportlib/ServerKit/ClientRef.h +17 -7
  152. data/src/cxx_supportlib/ServerKit/Context.h +2 -2
  153. data/src/cxx_supportlib/ServerKit/FileBufferedChannel.h +1 -1
  154. data/src/cxx_supportlib/ServerKit/HttpHeaderParser.h +3 -3
  155. data/src/cxx_supportlib/ServerKit/HttpHeaderParserState.h +2 -2
  156. data/src/cxx_supportlib/ServerKit/HttpRequestRef.h +17 -7
  157. data/src/cxx_supportlib/ServerKit/HttpServer.h +16 -10
  158. data/src/cxx_supportlib/ServerKit/Server.h +3 -4
  159. data/src/cxx_supportlib/{Utils → StrIntTools}/DateParsing.h +5 -5
  160. data/src/cxx_supportlib/{Utils → StrIntTools}/StrIntUtils.cpp +3 -3
  161. data/src/cxx_supportlib/{Utils → StrIntTools}/StrIntUtils.h +0 -0
  162. data/src/cxx_supportlib/{Utils → StrIntTools}/StrIntUtilsNoStrictAliasing.cpp +12 -12
  163. data/src/cxx_supportlib/{Utils → StrIntTools}/StringScanning.h +5 -5
  164. data/src/cxx_supportlib/{Utils → StrIntTools}/Template.h +30 -5
  165. data/src/cxx_supportlib/SystemTools/ContainerHelpers.h +88 -0
  166. data/src/cxx_supportlib/{Utils → SystemTools}/ProcessMetricsCollector.h +15 -12
  167. data/src/cxx_supportlib/{Utils → SystemTools}/SystemMetricsCollector.h +3 -3
  168. data/src/cxx_supportlib/{Utils → SystemTools}/SystemTime.cpp +1 -1
  169. data/src/cxx_supportlib/{Utils → SystemTools}/SystemTime.h +0 -0
  170. data/src/cxx_supportlib/SystemTools/UserDatabase.h +1 -1
  171. data/src/cxx_supportlib/Utils/CachedFileStat.hpp +3 -3
  172. data/src/cxx_supportlib/Utils/Curl.h +2 -2
  173. data/src/cxx_supportlib/Utils/FileChangeChecker.h +2 -2
  174. data/src/cxx_supportlib/Utils/MessagePassing.h +1 -1
  175. data/src/cxx_supportlib/Utils/SpeedMeter.h +2 -2
  176. data/src/cxx_supportlib/Utils/Timer.h +2 -2
  177. data/src/cxx_supportlib/Utils/VariantMap.h +3 -3
  178. data/src/cxx_supportlib/Utils.cpp +2 -2
  179. data/src/cxx_supportlib/WatchdogLauncher.h +3 -3
  180. data/src/cxx_supportlib/WebSocketCommandReverseServer.h +1 -1
  181. data/src/cxx_supportlib/WrapperRegistry/CBindings.cpp +85 -0
  182. data/src/cxx_supportlib/{Utils/MemoryBarrier.h → WrapperRegistry/CBindings.h} +30 -27
  183. data/src/cxx_supportlib/WrapperRegistry/Entry.h +112 -0
  184. data/src/cxx_supportlib/WrapperRegistry/README.md +37 -0
  185. data/src/cxx_supportlib/WrapperRegistry/Registry.h +309 -0
  186. data/src/cxx_supportlib/vendor-modified/psg_sysqueue.h +3 -0
  187. data/src/helper-scripts/download_binaries/extconf.rb +6 -2
  188. data/src/nginx_module/ConfigGeneral/AutoGeneratedDefinitions.c +32 -0
  189. data/src/nginx_module/ConfigGeneral/AutoGeneratedManifestDefaultsInitialization.c +12 -0
  190. data/src/nginx_module/ConfigGeneral/AutoGeneratedSetterFuncs.c +36 -0
  191. data/src/nginx_module/Configuration.c +23 -3
  192. data/src/nginx_module/ContentHandler.c +331 -32
  193. data/src/nginx_module/ContentHandler.h +8 -3
  194. data/src/nginx_module/LocationConfig/AutoGeneratedCreateFunction.c +10 -0
  195. data/src/nginx_module/LocationConfig/AutoGeneratedManifestGeneration.c +27 -0
  196. data/src/nginx_module/LocationConfig/AutoGeneratedMergeFunction.c +3 -0
  197. data/src/nginx_module/LocationConfig/AutoGeneratedStruct.h +7 -0
  198. data/src/nginx_module/MainConfig/AutoGeneratedCreateFunction.c +11 -0
  199. data/src/nginx_module/MainConfig/AutoGeneratedManifestGeneration.c +23 -0
  200. data/src/nginx_module/MainConfig/AutoGeneratedStruct.h +8 -0
  201. data/src/nginx_module/config +2 -1
  202. data/src/nginx_module/ngx_http_passenger_module.c +9 -3
  203. data/src/nginx_module/ngx_http_passenger_module.h +10 -3
  204. data/src/ruby_supportlib/phusion_passenger/apache2/config_options.rb +19 -0
  205. data/src/ruby_supportlib/phusion_passenger/common_library.rb +19 -16
  206. data/src/ruby_supportlib/phusion_passenger/config/agent_compiler.rb +4 -4
  207. data/src/ruby_supportlib/phusion_passenger/config/download_agent_command.rb +6 -2
  208. data/src/ruby_supportlib/phusion_passenger/config/download_nginx_engine_command.rb +6 -2
  209. data/src/ruby_supportlib/phusion_passenger/config/nginx_engine_compiler.rb +1 -1
  210. data/src/ruby_supportlib/phusion_passenger/message_channel.rb +2 -2
  211. data/src/ruby_supportlib/phusion_passenger/native_support.rb +7 -3
  212. data/src/ruby_supportlib/phusion_passenger/nginx/config_options.rb +29 -0
  213. data/src/ruby_supportlib/phusion_passenger/packaging.rb +20 -19
  214. data/src/ruby_supportlib/phusion_passenger/platform_info/apache.rb +22 -4
  215. data/src/ruby_supportlib/phusion_passenger/platform_info/ruby.rb +33 -13
  216. data/src/ruby_supportlib/phusion_passenger/standalone/app_finder.rb +1 -0
  217. data/src/ruby_supportlib/phusion_passenger/standalone/config_options_list.rb +22 -2
  218. data/src/ruby_supportlib/phusion_passenger/standalone/start_command/builtin_engine.rb +4 -1
  219. data/src/ruby_supportlib/phusion_passenger.rb +7 -5
  220. data/src/schema_printer/SchemaPrinterMain.cpp +2 -0
  221. metadata +40 -89
  222. data/.editorconfig +0 -134
  223. data/CODE_OF_CONDUCT.md +0 -52
  224. data/dev/boost-patches/0001-Patch-boost-thread-so-that-oxt-thread-can-use-it.patch +0 -48
  225. data/dev/boost-patches/0002-Make-boost-thread_interrupted-derive-from-oxt-tracab.patch +0 -33
  226. data/dev/boost-patches/0003-Disable-a-Clang-pragma-to-prevent-warnings-on-OS-X.patch +0 -25
  227. data/dev/ci/README.md +0 -134
  228. data/dev/ci/lib/functions.sh +0 -129
  229. data/dev/ci/lib/set-container-envvars.sh +0 -53
  230. data/dev/ci/lib/setup-container.sh +0 -46
  231. data/dev/ci/run-tests-natively +0 -24
  232. data/dev/ci/run-tests-with-docker +0 -42
  233. data/dev/ci/scripts/debug-console-wrapper.sh +0 -29
  234. data/dev/ci/scripts/docker-entrypoint-stage2.sh +0 -17
  235. data/dev/ci/scripts/docker-entrypoint.sh +0 -17
  236. data/dev/ci/scripts/inituidgid +0 -17
  237. data/dev/ci/scripts/run-tests-natively-stage2.sh +0 -17
  238. data/dev/ci/scripts/setup-host-natively.sh +0 -11
  239. data/dev/ci/setup-host +0 -56
  240. data/dev/ci/tests/apache2/run +0 -6
  241. data/dev/ci/tests/apache2/setup +0 -4
  242. data/dev/ci/tests/binaries/Jenkinsfile +0 -105
  243. data/dev/ci/tests/binaries/build-linux +0 -38
  244. data/dev/ci/tests/binaries/build-macos +0 -40
  245. data/dev/ci/tests/binaries/prepare-macos +0 -38
  246. data/dev/ci/tests/binaries/test-linux +0 -45
  247. data/dev/ci/tests/binaries/test-macos +0 -38
  248. data/dev/ci/tests/cxx/run +0 -9
  249. data/dev/ci/tests/cxx/setup +0 -4
  250. data/dev/ci/tests/debian/Jenkinsfile +0 -89
  251. data/dev/ci/tests/debian/run +0 -60
  252. data/dev/ci/tests/nginx/run +0 -5
  253. data/dev/ci/tests/nginx/setup +0 -4
  254. data/dev/ci/tests/nginx-dynamic/run +0 -20
  255. data/dev/ci/tests/nginx-dynamic/setup +0 -4
  256. data/dev/ci/tests/nodejs/run +0 -4
  257. data/dev/ci/tests/nodejs/setup +0 -4
  258. data/dev/ci/tests/rpm/Jenkinsfile +0 -68
  259. data/dev/ci/tests/rpm/run +0 -63
  260. data/dev/ci/tests/ruby/run +0 -4
  261. data/dev/ci/tests/ruby/setup +0 -4
  262. data/dev/ci/tests/source-packaging/run +0 -4
  263. data/dev/ci/tests/source-packaging/setup +0 -4
  264. data/dev/ci/tests/standalone/run +0 -4
  265. data/dev/ci/tests/standalone/setup +0 -4
  266. data/dev/configkit-schemas/index.json +0 -1748
  267. data/dev/configkit-schemas/update_schema_inline_comments.rb +0 -118
  268. data/dev/rack.test/config.ru +0 -5
  269. data/dev/rack.test/public/asset.txt +0 -1
  270. data/dev/vagrant/apache_default_site.conf +0 -35
  271. data/dev/vagrant/apache_passenger.conf +0 -5
  272. data/dev/vagrant/apache_passenger.load +0 -1
  273. data/dev/vagrant/apache_ports.conf +0 -24
  274. data/dev/vagrant/apache_rack_test.conf +0 -9
  275. data/dev/vagrant/bashrc +0 -23
  276. data/dev/vagrant/nginx.conf +0 -39
  277. data/dev/vagrant/nginx_rakefile +0 -33
  278. data/dev/vagrant/nginx_start +0 -32
  279. data/dev/vagrant/provision.sh +0 -117
  280. data/dev/vagrant/sudoers.conf +0 -5
  281. data/resources/templates/error_renderer/.editorconfig +0 -19
  282. data/src/cxx_supportlib/AppTypes.cpp +0 -109
  283. data/src/cxx_supportlib/vendor-modified/SmallVector.h +0 -653
@@ -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.
@@ -30,7 +30,7 @@
30
30
  #include <vector>
31
31
  #include <utility>
32
32
  #include <boost/shared_array.hpp>
33
- #include <AppTypes.h>
33
+ #include <WrapperRegistry/Registry.h>
34
34
  #include <DataStructures/HashedStaticString.h>
35
35
  #include <Constants.h>
36
36
  #include <ResourceLocator.h>
@@ -85,7 +85,7 @@ private:
85
85
  result.push_back(&options.appGroupName);
86
86
  result.push_back(&options.appLogFile);
87
87
  result.push_back(&options.appType);
88
- result.push_back(&options.startCommand);
88
+ result.push_back(&options.appStartCommand);
89
89
  result.push_back(&options.startupFile);
90
90
  result.push_back(&options.processTitle);
91
91
 
@@ -181,15 +181,15 @@ public:
181
181
  /** The application's type, used for determining the command to invoke to
182
182
  * spawn an application process as well as determining the startup file's
183
183
  * filename. It can be one of the app type names in AppType.cpp, or the
184
- * empty string (default). In case of the latter, 'startCommand' and
184
+ * empty string (default). In case of the latter, 'appStartCommand' and
185
185
  * 'startupFile' (which MUST be set) will dictate the startup command
186
186
  * and the startup file's filename. */
187
187
  StaticString appType;
188
188
 
189
- /** The command for spawning the application process. This is a list of
190
- * arguments, separated by '\t', e.g. "ruby\tfoo.rb". Only used
191
- * during spawning and only if appType.empty(). */
192
- StaticString startCommand;
189
+ /** The shell command string for spawning the application process.
190
+ * Only used during spawning and only if appType.empty().
191
+ */
192
+ StaticString appStartCommand;
193
193
 
194
194
  /** Filename of the application's startup file. Only actually used for
195
195
  * determining user switching info. Only used during spawning. */
@@ -545,16 +545,16 @@ public:
545
545
  * the `elements` argument.
546
546
  */
547
547
  void toVector(vector<string> &vec, const ResourceLocator &resourceLocator,
548
- int fields = ALL_OPTIONS) const
548
+ const WrapperRegistry::Registry &wrapperRegistry, int fields = ALL_OPTIONS) const
549
549
  {
550
550
  if (fields & SPAWN_OPTIONS) {
551
551
  appendKeyValue (vec, "app_root", appRoot);
552
552
  appendKeyValue (vec, "app_group_name", getAppGroupName());
553
553
  appendKeyValue (vec, "app_type", appType);
554
554
  appendKeyValue (vec, "app_log_file", appLogFile);
555
- appendKeyValue (vec, "start_command", getStartCommand(resourceLocator));
556
- appendKeyValue (vec, "startup_file", absolutizePath(getStartupFile(), absolutizePath(appRoot)));
557
- appendKeyValue (vec, "process_title", getProcessTitle());
555
+ appendKeyValue (vec, "start_command", getStartCommand(resourceLocator, wrapperRegistry));
556
+ appendKeyValue (vec, "startup_file", absolutizePath(getStartupFile(wrapperRegistry), absolutizePath(appRoot)));
557
+ appendKeyValue (vec, "process_title", getProcessTitle(wrapperRegistry));
558
558
  appendKeyValue2(vec, "log_level", logLevel);
559
559
  appendKeyValue3(vec, "start_timeout", startTimeout);
560
560
  appendKeyValue (vec, "environment", environment);
@@ -589,12 +589,12 @@ public:
589
589
 
590
590
  template<typename Stream>
591
591
  void toXml(Stream &stream, const ResourceLocator &resourceLocator,
592
- int fields = ALL_OPTIONS) const
592
+ const WrapperRegistry::Registry &wrapperRegistry, int fields = ALL_OPTIONS) const
593
593
  {
594
594
  vector<string> args;
595
595
  unsigned int i;
596
596
 
597
- toVector(args, resourceLocator, fields);
597
+ toVector(args, resourceLocator, wrapperRegistry, fields);
598
598
  for (i = 0; i < args.size(); i += 2) {
599
599
  stream << "<" << args[i] << ">";
600
600
  stream << escapeForXml(args[i + 1]);
@@ -614,43 +614,47 @@ public:
614
614
  }
615
615
  }
616
616
 
617
- string getStartCommand(const ResourceLocator &resourceLocator) const {
618
- if (appType == P_STATIC_STRING("rack")) {
619
- return escapeShell(ruby) + " "
620
- + escapeShell(resourceLocator.getHelperScriptsDir() + "/rack-loader.rb");
621
- } else if (appType == P_STATIC_STRING("wsgi")) {
622
- return escapeShell(python) + " "
623
- + escapeShell(resourceLocator.getHelperScriptsDir() + "/wsgi-loader.py");
624
- } else if (appType == P_STATIC_STRING("node")) {
625
- return escapeShell(nodejs) + " "
626
- + escapeShell(resourceLocator.getHelperScriptsDir() + "/node-loader.js");
627
- } else if (appType == P_STATIC_STRING("meteor")) {
628
- return escapeShell(ruby) + " "
629
- + escapeShell(resourceLocator.getHelperScriptsDir() + "/meteor-loader.rb");
617
+ string getStartCommand(const ResourceLocator &resourceLocator,
618
+ const WrapperRegistry::Registry &wrapperRegistry) const
619
+ {
620
+ const WrapperRegistry::Entry &entry = wrapperRegistry.lookup(appType);
621
+
622
+ string interpreter;
623
+ if (entry.language == P_STATIC_STRING("ruby")) {
624
+ interpreter = escapeShell(ruby);
625
+ } else if (entry.language == P_STATIC_STRING("python")) {
626
+ interpreter = escapeShell(python);
627
+ } else if (entry.language == P_STATIC_STRING("nodejs")) {
628
+ interpreter = escapeShell(nodejs);
629
+ } else if (entry.language == P_STATIC_STRING("meteor")) {
630
+ interpreter = escapeShell(ruby);
630
631
  } else {
631
- return startCommand;
632
+ return appStartCommand;
632
633
  }
634
+
635
+ return interpreter + " " + escapeShell(resourceLocator.getHelperScriptsDir()
636
+ + "/" + entry.path);
633
637
  }
634
638
 
635
- StaticString getStartupFile() const {
639
+ StaticString getStartupFile(const WrapperRegistry::Registry &wrapperRegistry) const {
636
640
  if (startupFile.empty()) {
637
- const char *result = getAppTypeStartupFile(getAppType(appType));
638
- if (result == NULL) {
639
- return P_STATIC_STRING("");
641
+ const WrapperRegistry::Entry &entry = wrapperRegistry.lookup(appType);
642
+ if (entry.isNull() || entry.defaultStartupFiles.empty()) {
643
+ return StaticString();
640
644
  } else {
641
- return result;
645
+ return entry.defaultStartupFiles[0];
642
646
  }
643
647
  } else {
644
648
  return startupFile;
645
649
  }
646
650
  }
647
651
 
648
- StaticString getProcessTitle() const {
649
- const char *result = getAppTypeProcessTitle(getAppType(appType));
650
- if (result == NULL) {
651
- return processTitle;
652
+ StaticString getProcessTitle(const WrapperRegistry::Registry &registry) const {
653
+ const WrapperRegistry::Entry &entry = registry.lookup(appType);
654
+ if (entry.isNull()) {
655
+ return entry.processTitle;
652
656
  } else {
653
- return result;
657
+ return StaticString();
654
658
  }
655
659
  }
656
660
 
@@ -52,7 +52,8 @@ Pool::getGroupRunUidAndGids(const StaticString &appGroupName) {
52
52
  if (!groups.lookup(appGroupName.c_str(), &group)) {
53
53
  throw RuntimeException("Could not find group: " + appGroupName);
54
54
  } else {
55
- SpawningKit::UserSwitchingInfo info = SpawningKit::prepareUserSwitching((*group)->options);
55
+ SpawningKit::UserSwitchingInfo info = SpawningKit::prepareUserSwitching((*group)->options,
56
+ *context->getWrapperRegistry());
56
57
  return pair<uid_t, gid_t>(info.uid,info.gid);
57
58
  }
58
59
  }
@@ -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.
@@ -52,13 +52,13 @@
52
52
  #include <ConfigKit/ConfigKit.h>
53
53
  #include <Exceptions.h>
54
54
  #include <Hooks.h>
55
+ #include <SystemTools/SystemMetricsCollector.h>
56
+ #include <SystemTools/ProcessMetricsCollector.h>
57
+ #include <SystemTools/SystemTime.h>
55
58
  #include <Utils/Lock.h>
56
59
  #include <Utils/AnsiColorConstants.h>
57
- #include <Utils/SystemTime.h>
58
60
  #include <Utils/MessagePassing.h>
59
61
  #include <Utils/VariantMap.h>
60
- #include <Utils/ProcessMetricsCollector.h>
61
- #include <Utils/SystemMetricsCollector.h>
62
62
  #include <Core/ApplicationPool/Common.h>
63
63
  #include <Core/ApplicationPool/Context.h>
64
64
  #include <Core/ApplicationPool/Process.h>
@@ -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.
@@ -43,10 +43,10 @@
43
43
  #include <Constants.h>
44
44
  #include <FileDescriptor.h>
45
45
  #include <LoggingKit/LoggingKit.h>
46
- #include <Utils/SystemTime.h>
47
- #include <Utils/StrIntUtils.h>
46
+ #include <SystemTools/ProcessMetricsCollector.h>
47
+ #include <SystemTools/SystemTime.h>
48
+ #include <StrIntTools/StrIntUtils.h>
48
49
  #include <Utils/Lock.h>
49
- #include <Utils/ProcessMetricsCollector.h>
50
50
  #include <Core/ApplicationPool/Common.h>
51
51
  #include <Core/ApplicationPool/Socket.h>
52
52
  #include <Core/ApplicationPool/Session.h>
@@ -156,12 +156,7 @@ private:
156
156
  */
157
157
  unsigned long long spawnEndTime;
158
158
 
159
- /**
160
- * If true, then indicates that this Process does not refer to a real OS
161
- * process. The sockets in the socket list are fake and need not be deleted,
162
- * the admin socket need not be closed, etc.
163
- */
164
- bool dummy;
159
+ SpawningKit::Result::Type type;
165
160
 
166
161
  /**
167
162
  * Whether it is required that triggerShutdown() and cleanup() must be called
@@ -458,7 +453,7 @@ public:
458
453
  spawnerCreationTime(getJsonUint64Field(args, "spawner_creation_time")),
459
454
  spawnStartTime(getJsonUint64Field(args, "spawn_start_time")),
460
455
  spawnEndTime(SystemTime::getUsec()),
461
- dummy(args["type"] == "dummy"),
456
+ type(args["type"] == "dummy" ? SpawningKit::Result::DUMMY : SpawningKit::Result::UNKNOWN),
462
457
  requiresShutdown(false),
463
458
  refcount(1),
464
459
  index(-1),
@@ -483,7 +478,7 @@ public:
483
478
  spawnerCreationTime(getJsonUint64Field(args, "spawner_creation_time")),
484
479
  spawnStartTime(skResult.spawnStartTime),
485
480
  spawnEndTime(skResult.spawnEndTime),
486
- dummy(skResult.dummy),
481
+ type(skResult.type),
487
482
  requiresShutdown(false),
488
483
  refcount(1),
489
484
  index(-1),
@@ -606,6 +601,9 @@ public:
606
601
  if (inputPipe != -1) {
607
602
  inputPipe.close();
608
603
  }
604
+ if (type == SpawningKit::Result::GENERIC) {
605
+ syscalls::kill(getPid(), SIGTERM);
606
+ }
609
607
  }
610
608
 
611
609
  bool shutdownTimeoutExpired() const {
@@ -620,7 +618,7 @@ public:
620
618
  assert(canCleanup());
621
619
 
622
620
  P_TRACE(2, "Cleaning up process " << inspect());
623
- if (!dummy) {
621
+ if (type != SpawningKit::Result::DUMMY) {
624
622
  SocketList::iterator it, end = sockets.end();
625
623
  for (it = sockets.begin(); it != end; it++) {
626
624
  if (getSocketAddressType(it->address) == SAT_UNIX) {
@@ -676,7 +674,7 @@ public:
676
674
  }
677
675
 
678
676
  bool isDummy() const {
679
- return dummy;
677
+ return type == SpawningKit::Result::DUMMY;
680
678
  }
681
679
 
682
680
 
@@ -720,7 +718,7 @@ public:
720
718
  * same PID.
721
719
  */
722
720
  bool osProcessExists() const {
723
- if (!dummy && m_osProcessExists) {
721
+ if (type != SpawningKit::Result::DUMMY && m_osProcessExists) {
724
722
  if (syscalls::kill(getPid(), 0) == 0) {
725
723
  /* On some environments, e.g. Heroku, the init process does
726
724
  * not properly reap adopted zombie processes, which can interfere
@@ -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.
@@ -31,13 +31,13 @@
31
31
  #include <boost/thread.hpp>
32
32
  #include <boost/shared_ptr.hpp>
33
33
  #include <boost/weak_ptr.hpp>
34
+ #include <boost/container/small_vector.hpp>
34
35
  #include <climits>
35
36
  #include <cassert>
36
- #include <SmallVector.h>
37
37
  #include <LoggingKit/LoggingKit.h>
38
38
  #include <StaticString.h>
39
39
  #include <MemoryKit/palloc.h>
40
- #include <Utils/IOUtils.h>
40
+ #include <IOTools/IOUtils.h>
41
41
  #include <Core/ApplicationPool/Common.h>
42
42
 
43
43
  namespace Passenger {
@@ -253,7 +253,7 @@ public:
253
253
  }
254
254
 
255
255
  bool isTotallyBusy() const {
256
- return concurrency != 0 && sessions >= concurrency;
256
+ return concurrency > 0 && sessions >= concurrency;
257
257
  }
258
258
 
259
259
  void recreateStrings(psg_pool_t *newPool) {
@@ -263,7 +263,7 @@ public:
263
263
  }
264
264
  };
265
265
 
266
- class SocketList: public SmallVector<Socket, 1> {
266
+ class SocketList: public boost::container::small_vector<Socket, 1> {
267
267
  public:
268
268
  void add(pid_t pid, const StaticString &address, const StaticString &protocol,
269
269
  const StaticString &description, int concurrency, bool acceptHttpRequests)
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Phusion Passenger - https://www.phusionpassenger.com/
3
- * Copyright (c) 2016-2017 Phusion Holding B.V.
3
+ * Copyright (c) 2016-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.
@@ -29,8 +29,8 @@
29
29
  #include <boost/thread.hpp>
30
30
  #include <string>
31
31
  #include <cassert>
32
- #include <Utils/IOUtils.h>
33
- #include <Utils/BufferedIO.h>
32
+ #include <IOTools/IOUtils.h>
33
+ #include <IOTools/BufferedIO.h>
34
34
  #include <Core/ApplicationPool/AbstractSession.h>
35
35
 
36
36
  namespace Passenger {
@@ -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.
@@ -41,14 +41,16 @@
41
41
  #include <ConfigKit/PrefixTranslator.h>
42
42
  #include <ServerKit/Context.h>
43
43
  #include <ServerKit/HttpServer.h>
44
+ #include <WrapperRegistry/Registry.h>
44
45
  #include <Core/Controller/Config.h>
45
46
  #include <Core/SecurityUpdateChecker.h>
47
+ #include <Core/TelemetryCollector.h>
46
48
  #include <Core/ApiServer.h>
47
49
  #include <Core/AdminPanelConnector.h>
48
50
  #include <Shared/ApiAccountUtils.h>
49
51
  #include <Constants.h>
50
52
  #include <Utils.h>
51
- #include <Utils/IOUtils.h>
53
+ #include <IOTools/IOUtils.h>
52
54
 
53
55
  namespace Passenger {
54
56
  namespace Core {
@@ -143,6 +145,7 @@ using namespace std;
143
145
  * max_instances_per_app unsigned integer - read_only
144
146
  * max_pool_size unsigned integer - default(6)
145
147
  * multi_app boolean - default(false),read_only
148
+ * oom_score string - read_only
146
149
  * passenger_root string required read_only
147
150
  * pid_file string - read_only
148
151
  * pool_idle_time unsigned integer - default(300)
@@ -154,13 +157,25 @@ using namespace std;
154
157
  * security_update_checker_interval unsigned integer - default(86400)
155
158
  * security_update_checker_proxy_url string - -
156
159
  * security_update_checker_url string - default("https://securitycheck.phusionpassenger.com/v1/check.json")
157
- * server_software string - default("Phusion_Passenger/5.3.4")
160
+ * server_software string - default("Phusion_Passenger/6.0.1")
158
161
  * show_version_in_header boolean - default(true)
159
162
  * single_app_mode_app_root string - default,read_only
163
+ * single_app_mode_app_start_command string - read_only
160
164
  * single_app_mode_app_type string - read_only
161
165
  * single_app_mode_startup_file string - read_only
162
166
  * standalone_engine string - default
163
167
  * stat_throttle_rate unsigned integer - default(10)
168
+ * telemetry_collector_ca_certificate_path string - -
169
+ * telemetry_collector_debug_curl boolean - default(false)
170
+ * telemetry_collector_disabled boolean - default(false)
171
+ * telemetry_collector_final_run_timeout unsigned integer - default(5)
172
+ * telemetry_collector_first_interval unsigned integer - default(7200)
173
+ * telemetry_collector_interval unsigned integer - default(21600)
174
+ * telemetry_collector_interval_jitter unsigned integer - default(7200)
175
+ * telemetry_collector_proxy_url string - -
176
+ * telemetry_collector_timeout unsigned integer - default(180)
177
+ * telemetry_collector_url string - default("https://anontelemetry.phusionpassenger.com/v1/collect.json")
178
+ * telemetry_collector_verify_server boolean - default(true)
164
179
  * turbocaching boolean - default(true),read_only
165
180
  * user_switching boolean - default(true)
166
181
  * vary_turbocache_by_cookie string - -
@@ -239,19 +254,27 @@ private:
239
254
  errors.push_back(Error("If '{{multi_app_mode}}' is set,"
240
255
  " then '{{single_app_mode_startup_file}}' may not be set"));
241
256
  }
257
+ if (!config["single_app_mode_app_start_command"].isNull()) {
258
+ errors.push_back(Error("If '{{multi_app_mode}}' is set,"
259
+ " then '{{single_app_mode_app_start_command}}' may not be set"));
260
+ }
242
261
  }
243
262
 
244
- static void validateSingleAppMode(const ConfigKit::Store &config, vector<ConfigKit::Error> &errors) {
263
+ static void validateSingleAppMode(const ConfigKit::Store &config,
264
+ const WrapperRegistry::Registry *wrapperRegistry, vector<ConfigKit::Error> &errors)
265
+ {
245
266
  typedef ConfigKit::Error Error;
246
267
 
247
268
  if (config["multi_app"].asBool()) {
248
269
  return;
249
270
  }
250
271
 
251
- // single_app_mode_app_type and single_app_mode_startup_file are
252
- // autodetected in initializeSingleAppMode()
272
+ // single_app_mode_app_type, single_app_mode_startup_file and
273
+ // single_app_mode_app_start_command are autodetected in
274
+ // initializeSingleAppMode() so no need to validate them.
253
275
 
254
- ControllerSingleAppModeSchema::validateAppType("single_app_mode_app_type", config, errors);
276
+ ControllerSingleAppModeSchema::validateAppType("single_app_mode_app_type",
277
+ wrapperRegistry, config, errors);
255
278
  }
256
279
 
257
280
  static void validateControllerSecureHeadersPassword(const ConfigKit::Store &config, vector<ConfigKit::Error> &errors) {
@@ -348,9 +371,13 @@ public:
348
371
  ControllerSchema schema;
349
372
  ConfigKit::TableTranslator translator;
350
373
  } controller;
351
- struct {
374
+ struct ControllerSingleAppModeSubschemaContainer {
352
375
  ControllerSingleAppModeSchema schema;
353
376
  ConfigKit::PrefixTranslator translator;
377
+
378
+ ControllerSingleAppModeSubschemaContainer(const WrapperRegistry::Registry *registry)
379
+ : schema(registry)
380
+ { }
354
381
  } controllerSingleAppMode;
355
382
  struct {
356
383
  ServerKit::Schema schema;
@@ -360,6 +387,10 @@ public:
360
387
  SecurityUpdateChecker::Schema schema;
361
388
  ConfigKit::PrefixTranslator translator;
362
389
  } securityUpdateChecker;
390
+ struct {
391
+ TelemetryCollector::Schema schema;
392
+ ConfigKit::PrefixTranslator translator;
393
+ } telemetryCollector;
363
394
  struct {
364
395
  ApiServer::Schema schema;
365
396
  ConfigKit::TableTranslator translator;
@@ -373,7 +404,9 @@ public:
373
404
  ConfigKit::TableTranslator translator;
374
405
  } adminPanelConnector;
375
406
 
376
- Schema() {
407
+ Schema(const WrapperRegistry::Registry *wrapperRegistry = NULL)
408
+ : controllerSingleAppMode(wrapperRegistry)
409
+ {
377
410
  using namespace ConfigKit;
378
411
 
379
412
  // Add subschema: loggingKit
@@ -398,6 +431,7 @@ public:
398
431
  ControllerSingleAppModeSchema::getDefaultAppRoot);
399
432
  add("single_app_mode_app_type", STRING_TYPE, OPTIONAL | READ_ONLY);
400
433
  add("single_app_mode_startup_file", STRING_TYPE, OPTIONAL | READ_ONLY);
434
+ add("single_app_mode_app_start_command", STRING_TYPE, OPTIONAL | READ_ONLY);
401
435
 
402
436
  // Add subschema: controllerServerKit
403
437
  controllerServerKit.translator.setPrefixAndFinalize("controller_");
@@ -410,6 +444,10 @@ public:
410
444
  erase("security_update_checker_server_identifier");
411
445
  erase("security_update_checker_web_server_version");
412
446
 
447
+ // Add subschema: telemetryCollector
448
+ telemetryCollector.translator.setPrefixAndFinalize("telemetry_collector_");
449
+ addSubSchema(telemetryCollector.schema, telemetryCollector.translator);
450
+
413
451
  // Add subschema: apiServer
414
452
  apiServer.translator.add("api_server_authorizations", "authorizations");
415
453
  addSubSchemaPrefixTranslations<ServerKit::HttpServerSchema>(
@@ -440,6 +478,7 @@ public:
440
478
  add("config_manifest", OBJECT_TYPE, OPTIONAL | READ_ONLY);
441
479
  add("pid_file", STRING_TYPE, OPTIONAL | READ_ONLY);
442
480
  add("web_server_version", STRING_TYPE, OPTIONAL | READ_ONLY);
481
+ add("oom_score", STRING_TYPE, OPTIONAL | READ_ONLY);
443
482
  addWithDynamicDefault("controller_threads", UINT_TYPE, OPTIONAL | READ_ONLY, getDefaultThreads);
444
483
  add("max_pool_size", UINT_TYPE, OPTIONAL, DEFAULT_MAX_POOL_SIZE);
445
484
  add("pool_idle_time", UINT_TYPE, OPTIONAL, Json::UInt(DEFAULT_POOL_IDLE_TIME));
@@ -453,7 +492,8 @@ public:
453
492
  add("file_descriptor_ulimit", UINT_TYPE, OPTIONAL | READ_ONLY, 0);
454
493
 
455
494
  addValidator(validateMultiAppMode);
456
- addValidator(validateSingleAppMode);
495
+ addValidator(boost::bind(validateSingleAppMode, boost::placeholders::_1,
496
+ wrapperRegistry, boost::placeholders::_2));
457
497
  addValidator(validateControllerSecureHeadersPassword);
458
498
  addValidator(validateApplicationPool);
459
499
  addValidator(validateController);
@@ -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.
@@ -49,6 +49,7 @@ struct ConfigChangeRequest {
49
49
  boost::scoped_ptr<ConfigKit::Store> config;
50
50
  LoggingKit::ConfigChangeRequest forLoggingKit;
51
51
  SecurityUpdateChecker::ConfigChangeRequest forSecurityUpdateChecker;
52
+ TelemetryCollector::ConfigChangeRequest forTelemetryCollector;
52
53
  vector<ServerKit::ConfigChangeRequest *> forControllerServerKit;
53
54
  vector<Controller::ConfigChangeRequest *> forController;
54
55
  ServerKit::ConfigChangeRequest forApiServerKit;
@@ -188,6 +189,13 @@ asyncPrepareConfigChange(const Json::Value &updates, ConfigChangeRequest *req,
188
189
  coreSchema->securityUpdateChecker.translator,
189
190
  req->config->inspectEffectiveValues(),
190
191
  req->errors, req->forSecurityUpdateChecker);
192
+ if (workingObjects->telemetryCollector != NULL) {
193
+ ConfigKit::prepareConfigChangeForSubComponent(
194
+ *workingObjects->telemetryCollector,
195
+ coreSchema->telemetryCollector.translator,
196
+ req->config->inspectEffectiveValues(),
197
+ req->errors, req->forTelemetryCollector);
198
+ }
191
199
 
192
200
  req->forControllerServerKit.resize(wo->threadWorkingObjects.size(), NULL);
193
201
  req->forController.resize(wo->threadWorkingObjects.size(), NULL);
@@ -287,6 +295,10 @@ asyncCommitConfigChange(ConfigChangeRequest *req, const CommitConfigChangeCallba
287
295
  LoggingKit::context->commitConfigChange(req->forLoggingKit);
288
296
  workingObjects->securityUpdateChecker->commitConfigChange(
289
297
  req->forSecurityUpdateChecker);
298
+ if (workingObjects->telemetryCollector != NULL) {
299
+ workingObjects->telemetryCollector->commitConfigChange(
300
+ req->forTelemetryCollector);
301
+ }
290
302
 
291
303
  wo->appPool->setMax(coreConfig->get("max_pool_size").asInt());
292
304
  wo->appPool->setMaxIdleTime(coreConfig->get("pool_idle_time").asInt() * 1000000ULL);
@@ -39,7 +39,7 @@
39
39
  #include <MemoryKit/palloc.h>
40
40
  #include <ServerKit/HttpServer.h>
41
41
  #include <SystemTools/UserDatabase.h>
42
- #include <AppTypes.h>
42
+ #include <WrapperRegistry/Registry.h>
43
43
  #include <Constants.h>
44
44
  #include <Exceptions.h>
45
45
  #include <StaticString.h>
@@ -113,7 +113,7 @@ parseControllerBenchmarkMode(const StaticString &mode) {
113
113
  * multi_app boolean - default(true),read_only
114
114
  * request_freelist_limit unsigned integer - default(1024)
115
115
  * response_buffer_high_watermark unsigned integer - default(134217728)
116
- * server_software string - default("Phusion_Passenger/5.3.4")
116
+ * server_software string - default("Phusion_Passenger/6.0.1")
117
117
  * show_version_in_header boolean - default(true)
118
118
  * start_reading_after_accept boolean - default(true)
119
119
  * stat_throttle_rate unsigned integer - default(10)
@@ -223,22 +223,25 @@ public:
223
223
  * (do not edit: following text is automatically generated
224
224
  * by 'rake configkit_schemas_inline_comments')
225
225
  *
226
- * app_root string - default,read_only
227
- * app_type string required read_only
228
- * startup_file string required read_only
226
+ * app_root string - default,read_only
227
+ * app_start_command string - read_only
228
+ * app_type string - read_only
229
+ * startup_file string - read_only
229
230
  *
230
231
  * END
231
232
  */
232
233
  struct ControllerSingleAppModeSchema: public ConfigKit::Schema {
233
- ControllerSingleAppModeSchema() {
234
+ ControllerSingleAppModeSchema(const WrapperRegistry::Registry *wrapperRegistry = NULL) {
234
235
  using namespace ConfigKit;
235
236
 
236
237
  addWithDynamicDefault("app_root", STRING_TYPE, OPTIONAL | READ_ONLY | CACHE_DEFAULT_VALUE,
237
238
  getDefaultAppRoot);
238
- add("app_type", STRING_TYPE, REQUIRED | READ_ONLY);
239
- add("startup_file", STRING_TYPE, REQUIRED | READ_ONLY);
239
+ add("app_type", STRING_TYPE, OPTIONAL | READ_ONLY);
240
+ add("startup_file", STRING_TYPE, OPTIONAL | READ_ONLY);
241
+ add("app_start_command", STRING_TYPE, OPTIONAL | READ_ONLY);
240
242
 
241
- addValidator(boost::bind(validateAppType, "app_type",
243
+ addValidator(validateAppTypeOrAppStartCommandSet);
244
+ addValidator(boost::bind(validateAppType, "app_type", wrapperRegistry,
242
245
  boost::placeholders::_1, boost::placeholders::_2));
243
246
  addNormalizer(normalizeAppRoot);
244
247
  addNormalizer(normalizeStartupFile);
@@ -257,22 +260,40 @@ struct ControllerSingleAppModeSchema: public ConfigKit::Schema {
257
260
  return result;
258
261
  }
259
262
 
263
+ static void validateAppTypeOrAppStartCommandSet(const ConfigKit::Store &config,
264
+ vector<ConfigKit::Error> &errors)
265
+ {
266
+ typedef ConfigKit::Error Error;
267
+
268
+ if (config["app_type"].isNull() && config["app_start_command"].isNull()) {
269
+ errors.push_back(Error(
270
+ "Either '{{app_type}}' or '{{app_start_command}}' must be set"));
271
+ }
272
+ if (!config["app_type"].isNull() && config["startup_file"].isNull()) {
273
+ errors.push_back(Error(
274
+ "If '{{app_type}}' is set, then '{{startup_file}}' must also be set"));
275
+ }
276
+ }
277
+
260
278
  static void validateAppType(const string &appTypeKey,
279
+ const WrapperRegistry::Registry *wrapperRegistry,
261
280
  const ConfigKit::Store &config, vector<ConfigKit::Error> &errors)
262
281
  {
263
282
  typedef ConfigKit::Error Error;
264
283
 
265
- if (!config[appTypeKey].isNull()) {
266
- PassengerAppType appType = getAppType(config[appTypeKey].asString());
267
- if (appType == PAT_NONE || appType == PAT_ERROR) {
284
+ if (!config[appTypeKey].isNull() && wrapperRegistry != NULL) {
285
+ const WrapperRegistry::Entry &entry =
286
+ wrapperRegistry->lookup(config[appTypeKey].asString());
287
+ if (entry.isNull()) {
268
288
  string message = "'{{" + appTypeKey + "}}' is set to '"
269
289
  + config[appTypeKey].asString() + "', which is not a"
270
290
  " valid application type. Supported app types are:";
271
- const AppTypeDefinition *definition = &appTypeDefinitions[0];
272
- while (definition->type != PAT_NONE) {
291
+ WrapperRegistry::Registry::ConstIterator it(
292
+ wrapperRegistry->getIterator());
293
+ while (*it != NULL) {
273
294
  message.append(1, ' ');
274
- message.append(definition->name);
275
- definition++;
295
+ message.append(it.getValue().language);
296
+ it.next();
276
297
  }
277
298
  errors.push_back(Error(message));
278
299
  }
@@ -287,7 +308,10 @@ struct ControllerSingleAppModeSchema: public ConfigKit::Schema {
287
308
 
288
309
  static Json::Value normalizeStartupFile(const Json::Value &effectiveValues) {
289
310
  Json::Value updates;
290
- updates["startup_file"] = absolutizePath(effectiveValues["startup_file"].asString());
311
+ if (effectiveValues.isMember("startup_file")) {
312
+ updates["startup_file"] = absolutizePath(
313
+ effectiveValues["startup_file"].asString());
314
+ }
291
315
  return updates;
292
316
  }
293
317
  };