passenger 5.0.21 → 5.0.22

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of passenger might be problematic. Click here for more details.

Files changed (203) hide show
  1. checksums.yaml +8 -8
  2. checksums.yaml.gz.asc +7 -7
  3. data.tar.gz.asc +7 -7
  4. data/CHANGELOG +38 -2
  5. data/CONTRIBUTORS +3 -0
  6. data/README.md +5 -1
  7. data/bin/passenger-status +2 -7
  8. data/build/agent.rb +2 -0
  9. data/build/cxx_dependency_map.rb +1464 -162
  10. data/build/node_tests.rb +1 -1
  11. data/build/packaging.rb +1 -1
  12. data/dev/ci/run_travis.sh +1 -1
  13. data/dev/vagrant/provision.sh +1 -1
  14. data/npm-shrinkwrap.json +635 -125
  15. data/package.json +1 -1
  16. data/resources/templates/standalone/config.erb +33 -161
  17. data/resources/templates/standalone/global.erb +15 -0
  18. data/resources/templates/standalone/http.erb +40 -0
  19. data/resources/templates/standalone/mass_deployment_default_server.erb +11 -0
  20. data/resources/templates/standalone/rails_asset_pipeline.erb +22 -0
  21. data/resources/templates/standalone/server.erb +58 -0
  22. data/src/agent/Core/ApiServer.h +37 -32
  23. data/src/agent/Core/ApplicationPool/BasicGroupInfo.h +1 -1
  24. data/src/agent/Core/ApplicationPool/BasicProcessInfo.h +6 -0
  25. data/src/agent/Core/ApplicationPool/Common.h +1 -1
  26. data/src/agent/Core/ApplicationPool/Group/OutOfBandWork.cpp +1 -1
  27. data/src/agent/Core/ApplicationPool/Group/ProcessListManagement.cpp +4 -0
  28. data/src/agent/Core/ApplicationPool/Implementation.cpp +2 -2
  29. data/src/agent/Core/ApplicationPool/Options.h +18 -1
  30. data/src/agent/Core/ApplicationPool/Pool.h +1 -1
  31. data/src/agent/Core/ApplicationPool/Pool/AnalyticsCollection.cpp +6 -6
  32. data/src/agent/Core/ApplicationPool/Pool/GeneralUtils.cpp +3 -3
  33. data/src/agent/Core/ApplicationPool/Pool/InitializationAndShutdown.cpp +1 -1
  34. data/src/agent/Core/ApplicationPool/Pool/Miscellaneous.cpp +6 -0
  35. data/src/agent/Core/ApplicationPool/Process.h +6 -1
  36. data/src/agent/Core/ApplicationPool/Socket.h +9 -12
  37. data/src/agent/Core/Controller.h +422 -0
  38. data/src/agent/Core/{RequestHandler → Controller}/AppResponse.h +2 -0
  39. data/src/agent/Core/{RequestHandler → Controller}/BufferBody.cpp +27 -5
  40. data/src/agent/Core/{RequestHandler → Controller}/CheckoutSession.cpp +61 -31
  41. data/src/agent/Core/{RequestHandler → Controller}/Client.h +5 -2
  42. data/src/agent/Core/{RequestHandler → Controller}/ForwardResponse.cpp +93 -42
  43. data/src/agent/Core/{RequestHandler → Controller}/Hooks.cpp +107 -60
  44. data/src/agent/Core/Controller/Implementation.cpp +38 -0
  45. data/src/agent/Core/{RequestHandler → Controller}/InitRequest.cpp +134 -80
  46. data/src/agent/Core/Controller/InitializationAndShutdown.cpp +165 -0
  47. data/src/agent/Core/{RequestHandler/Utils.cpp → Controller/InternalUtils.cpp} +49 -32
  48. data/src/agent/Core/Controller/Miscellaneous.cpp +116 -0
  49. data/src/agent/Core/{RequestHandler → Controller}/Request.h +6 -4
  50. data/src/agent/Core/{RequestHandler → Controller}/SendRequest.cpp +205 -130
  51. data/src/agent/Core/Controller/StateInspectionAndConfiguration.cpp +161 -0
  52. data/src/agent/Core/{RequestHandler → Controller}/TurboCaching.h +3 -0
  53. data/src/agent/Core/CoreMain.cpp +62 -51
  54. data/src/agent/Core/OptionParser.h +24 -0
  55. data/src/agent/Core/ResponseCache.h +5 -5
  56. data/src/agent/Core/SpawningKit/Config.h +2 -2
  57. data/src/agent/Core/SpawningKit/SmartSpawner.h +1 -1
  58. data/src/agent/Core/UnionStation/{Core.h → Context.h} +14 -18
  59. data/src/agent/Core/UnionStation/StopwatchLog.h +3 -2
  60. data/src/agent/Core/UnionStation/Transaction.h +7 -7
  61. data/src/agent/Shared/ApiServerUtils.h +9 -1
  62. data/src/agent/UstRouter/ApiServer.h +5 -2
  63. data/src/agent/UstRouter/Controller.h +27 -9
  64. data/src/agent/UstRouter/UstRouterMain.cpp +1 -0
  65. data/src/agent/Watchdog/ApiServer.h +5 -2
  66. data/src/apache2_module/ConfigurationCommands.cpp +7 -0
  67. data/src/apache2_module/ConfigurationFields.hpp +2 -0
  68. data/src/apache2_module/ConfigurationSetters.cpp +24 -0
  69. data/src/apache2_module/CreateDirConfig.cpp +1 -0
  70. data/src/apache2_module/Hooks.cpp +6 -5
  71. data/src/apache2_module/MergeDirConfig.cpp +7 -0
  72. data/src/apache2_module/SetHeaders.cpp +5 -0
  73. data/src/cxx_supportlib/Constants.h +5 -3
  74. data/src/cxx_supportlib/SafeLibev.h +2 -1
  75. data/src/cxx_supportlib/UnionStationFilterSupport.h +2 -1
  76. data/src/cxx_supportlib/Utils/ReleaseableScopedPointer.h +70 -0
  77. data/src/cxx_supportlib/vendor-modified/boost/libs/regex/src/regex_raw_buffer.cpp +6 -6
  78. data/src/helper-scripts/node-loader.js +59 -0
  79. data/src/nginx_module/CacheLocationConfig.c +48 -0
  80. data/src/nginx_module/ConfigurationCommands.c +20 -0
  81. data/src/nginx_module/ConfigurationFields.h +4 -0
  82. data/src/nginx_module/CreateLocationConfig.c +8 -0
  83. data/src/nginx_module/MergeLocationConfig.c +12 -0
  84. data/src/nodejs_supportlib/phusion_passenger/log_express.js +106 -0
  85. data/src/nodejs_supportlib/phusion_passenger/log_mongodb.js +203 -0
  86. data/src/nodejs_supportlib/phusion_passenger/ustreporter.js +227 -0
  87. data/src/nodejs_supportlib/phusion_passenger/ustrouter_connector.js +446 -0
  88. data/src/nodejs_supportlib/vendor-copy/codify/codify.js +44 -0
  89. data/src/nodejs_supportlib/vendor-copy/codify/package.json +29 -0
  90. data/src/nodejs_supportlib/vendor-copy/continuation-local-storage/context.js +200 -0
  91. data/src/nodejs_supportlib/vendor-copy/continuation-local-storage/node_modules/async-listener/glue.js +488 -0
  92. data/src/nodejs_supportlib/vendor-copy/continuation-local-storage/node_modules/async-listener/index.js +407 -0
  93. data/src/nodejs_supportlib/vendor-copy/continuation-local-storage/node_modules/async-listener/node_modules/shimmer/index.js +90 -0
  94. data/src/nodejs_supportlib/vendor-copy/continuation-local-storage/node_modules/async-listener/node_modules/shimmer/package.json +40 -0
  95. data/src/nodejs_supportlib/vendor-copy/continuation-local-storage/node_modules/async-listener/package.json +54 -0
  96. data/src/nodejs_supportlib/vendor-copy/continuation-local-storage/node_modules/emitter-listener/listener.js +160 -0
  97. data/src/nodejs_supportlib/vendor-copy/continuation-local-storage/node_modules/emitter-listener/node_modules/shimmer/index.js +90 -0
  98. data/src/nodejs_supportlib/vendor-copy/continuation-local-storage/node_modules/emitter-listener/node_modules/shimmer/package.json +40 -0
  99. data/src/nodejs_supportlib/vendor-copy/continuation-local-storage/node_modules/emitter-listener/package.json +46 -0
  100. data/src/nodejs_supportlib/vendor-copy/continuation-local-storage/package.json +56 -0
  101. data/src/nodejs_supportlib/vendor-copy/network-byte-order/lib/index.js +102 -0
  102. data/src/nodejs_supportlib/vendor-copy/network-byte-order/package.json +51 -0
  103. data/src/nodejs_supportlib/vendor-copy/winston/LICENSE +19 -0
  104. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston.js +165 -0
  105. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/common.js +483 -0
  106. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/config.js +62 -0
  107. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/config/cli-config.js +35 -0
  108. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/config/npm-config.js +27 -0
  109. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/config/syslog-config.js +31 -0
  110. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/container.js +127 -0
  111. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/exception.js +56 -0
  112. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/logger.js +701 -0
  113. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/transports.js +34 -0
  114. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/transports/console.js +128 -0
  115. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/transports/daily-rotate-file.js +601 -0
  116. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/transports/file.js +675 -0
  117. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/transports/http.js +232 -0
  118. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/transports/memory.js +89 -0
  119. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/transports/transport.js +135 -0
  120. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/transports/webhook.js +146 -0
  121. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/async/LICENSE +19 -0
  122. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/async/lib/async.js +1283 -0
  123. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/async/package.json +66 -0
  124. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/async/support/sync-package-managers.js +53 -0
  125. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/MIT-LICENSE.txt +23 -0
  126. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/lib/colors.js +176 -0
  127. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/lib/custom/trap.js +45 -0
  128. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/lib/custom/zalgo.js +104 -0
  129. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/lib/extendStringPrototype.js +118 -0
  130. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/lib/index.js +12 -0
  131. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/lib/maps/america.js +12 -0
  132. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/lib/maps/rainbow.js +13 -0
  133. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/lib/maps/random.js +8 -0
  134. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/lib/maps/zebra.js +5 -0
  135. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/lib/styles.js +77 -0
  136. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/lib/system/supports-colors.js +61 -0
  137. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/package.json +35 -0
  138. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/safe.js +9 -0
  139. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/themes/generic-logging.js +12 -0
  140. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/cycle/cycle.js +170 -0
  141. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/cycle/package.json +30 -0
  142. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/eyes/LICENSE +20 -0
  143. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/eyes/lib/eyes.js +236 -0
  144. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/eyes/package.json +42 -0
  145. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/isstream/LICENSE.md +11 -0
  146. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/isstream/isstream.js +27 -0
  147. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/isstream/package.json +42 -0
  148. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/pkginfo/LICENSE +19 -0
  149. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/pkginfo/lib/pkginfo.js +136 -0
  150. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/pkginfo/package.json +56 -0
  151. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/stack-trace/License +19 -0
  152. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/stack-trace/lib/stack-trace.js +111 -0
  153. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/stack-trace/package.json +33 -0
  154. data/src/nodejs_supportlib/vendor-copy/winston/package.json +87 -0
  155. data/src/ruby_supportlib/phusion_passenger.rb +3 -4
  156. data/src/ruby_supportlib/phusion_passenger/admin_tools/instance.rb +19 -2
  157. data/src/ruby_supportlib/phusion_passenger/apache2/config_options.rb +8 -0
  158. data/src/ruby_supportlib/phusion_passenger/config/list_instances_command.rb +2 -6
  159. data/src/ruby_supportlib/phusion_passenger/config/reopen_logs_command.rb +13 -0
  160. data/src/ruby_supportlib/phusion_passenger/config/restart_app_command.rb +3 -0
  161. data/src/ruby_supportlib/phusion_passenger/config/utils.rb +9 -7
  162. data/src/ruby_supportlib/phusion_passenger/config/validate_install_command.rb +8 -1
  163. data/src/ruby_supportlib/phusion_passenger/constants.rb +3 -1
  164. data/src/ruby_supportlib/phusion_passenger/native_support.rb +20 -4
  165. data/src/ruby_supportlib/phusion_passenger/nginx/config_options.rb +8 -0
  166. data/src/ruby_supportlib/phusion_passenger/packaging.rb +1 -0
  167. data/src/ruby_supportlib/phusion_passenger/platform_info/apache_detector.rb +1 -1
  168. data/src/ruby_supportlib/phusion_passenger/platform_info/operating_system.rb +11 -4
  169. data/src/ruby_supportlib/phusion_passenger/rack/thread_handler_extension.rb +1 -1
  170. data/src/ruby_supportlib/phusion_passenger/standalone/config_options_list.rb +647 -0
  171. data/src/ruby_supportlib/phusion_passenger/standalone/config_utils.rb +229 -15
  172. data/src/ruby_supportlib/phusion_passenger/standalone/start_command.rb +35 -323
  173. data/src/ruby_supportlib/phusion_passenger/standalone/start_command/builtin_engine.rb +36 -12
  174. data/src/ruby_supportlib/phusion_passenger/standalone/start_command/nginx_engine.rb +123 -14
  175. data/src/ruby_supportlib/phusion_passenger/standalone/status_command.rb +32 -17
  176. data/src/ruby_supportlib/phusion_passenger/standalone/stop_command.rb +32 -21
  177. data/src/ruby_supportlib/phusion_passenger/standalone/version_command.rb +5 -5
  178. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/README.md +2 -2
  179. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/Rakefile +5 -1
  180. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core.rb +68 -24
  181. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/api.rb +9 -1
  182. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/context.rb +9 -7
  183. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter.rb +3 -2
  184. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/basics.rb +8 -5
  185. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/simple_json.rb +395 -0
  186. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/transaction.rb +10 -7
  187. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/utils.rb +14 -0
  188. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/version_data.rb +2 -2
  189. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/ruby_versions.yml +4 -2
  190. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/ruby_versions.yml.example +2 -2
  191. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/ruby_versions.yml.travis +2 -2
  192. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/ruby_versions.yml.travis-with-sudo +16 -0
  193. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/Gemfile +1 -1
  194. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/Gemfile.lock +2 -2
  195. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/README.md +1 -1
  196. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails.rb +44 -17
  197. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/active_support_cache_subscriber.rb +16 -7
  198. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/version_data.rb +2 -2
  199. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/union_station_hooks_rails.gemspec +1 -1
  200. metadata +99 -16
  201. metadata.gz.asc +7 -7
  202. data/resources/oss-binaries.phusionpassenger.com.crt +0 -248
  203. data/src/agent/Core/RequestHandler.h +0 -471
@@ -258,6 +258,9 @@ module PhusionPassenger
258
258
  elsif response.code.to_i == 401
259
259
  if response["pool-empty"] == "true"
260
260
  REXML::Document.new('<?xml version="1.0" encoding="iso8859-1"?><info version="3"></info>')
261
+ elsif @options[:ignore_app_not_running]
262
+ print_instance_querying_permission_error
263
+ exit
261
264
  else
262
265
  print_instance_querying_permission_error
263
266
  abort
@@ -105,16 +105,18 @@ module PhusionPassenger
105
105
  abort
106
106
  end
107
107
 
108
- def list_all_passenger_instances(instances)
109
- puts "The following #{PROGRAM_NAME} instances are running:"
110
- puts
111
- printf "%-25s %s\n", "Name", "Description"
112
- puts "------------------------------------------------------------------"
108
+ def list_all_passenger_instances(instances, print_preamble = true)
109
+ if print_preamble
110
+ puts "The following #{PROGRAM_NAME} instances are running:"
111
+ puts
112
+ end
113
+ printf "%-25s %-7s %s\n", "Name", "PID", "Description"
114
+ puts "--------------------------------------------------------------------------"
113
115
  if instances.empty?
114
- printf "%-25s %s\n", "(list empty)", "-"
116
+ printf "%-25s %-7s %s\n", "(list empty)", "-", "-"
115
117
  else
116
118
  instances.each do |instance|
117
- printf "%-25s %s\n", instance.name, instance.server_software
119
+ printf "%-25s %-7s %s\n", instance.name, instance.watchdog_pid, instance.server_software
118
120
  end
119
121
  end
120
122
  end
@@ -252,6 +252,7 @@ module PhusionPassenger
252
252
 
253
253
  paths.delete(try_realpath(gem_bindir))
254
254
  paths.delete(try_realpath(homebrew_bindir))
255
+ paths.delete(try_realpath(rbenv_shims_dir))
255
256
  paths.delete(try_realpath(PhusionPassenger.bin_dir))
256
257
  paths.uniq!
257
258
 
@@ -621,6 +622,12 @@ module PhusionPassenger
621
622
  end
622
623
  end
623
624
 
625
+ # Returns the ~/.rbenv/shims directory if it exists.
626
+ def rbenv_shims_dir
627
+ home = PhusionPassenger.home_dir
628
+ "#{home}/.rbenv/shims"
629
+ end
630
+
624
631
  def logn(message)
625
632
  STDOUT.write(@colors.ansi_colorize(message))
626
633
  STDOUT.flush
@@ -726,7 +733,7 @@ module PhusionPassenger
726
733
  if path
727
734
  begin
728
735
  Pathname.new(path).realpath.to_s
729
- rescue Errno::ENOENT, Errno::EACCES
736
+ rescue Errno::ENOENT, Errno::EACCES, Errno::ENOTDIR
730
737
  path
731
738
  end
732
739
  else
@@ -25,6 +25,7 @@
25
25
  module PhusionPassenger
26
26
  PASSENGER_TXN_ID = "PASSENGER_TXN_ID".freeze
27
27
  PASSENGER_APP_GROUP_NAME = "PASSENGER_APP_GROUP_NAME".freeze
28
+ PASSENGER_DELTA_MONOTONIC = "PASSENGER_DELTA_MONOTONIC".freeze
28
29
  RACK_HIJACK_IO = "rack.hijack_io".freeze
29
30
 
30
31
  LVL_CRIT = 0
@@ -59,6 +60,7 @@ module PhusionPassenger
59
60
  DEFAULT_STICKY_SESSIONS_COOKIE_NAME = "_passenger_route"
60
61
  DEFAULT_APP_THREAD_COUNT = 1
61
62
  DEFAULT_RESPONSE_BUFFER_HIGH_WATERMARK = 1024 * 1024 * 128
63
+ DEFAULT_MAX_REQUEST_QUEUE_SIZE = 100
62
64
  DEFAULT_STAT_THROTTLE_RATE = 10
63
65
  DEFAULT_ANALYTICS_LOG_USER = DEFAULT_WEB_APP_USER
64
66
  DEFAULT_ANALYTICS_LOG_GROUP = ""
@@ -83,7 +85,7 @@ module PhusionPassenger
83
85
  # Versions
84
86
  PASSENGER_VERSION = PhusionPassenger::VERSION_STRING
85
87
  PASSENGER_API_VERSION_MAJOR = 0
86
- PASSENGER_API_VERSION_MINOR = 2
88
+ PASSENGER_API_VERSION_MINOR = 3
87
89
  PASSENGER_API_VERSION = "#{PASSENGER_API_VERSION_MAJOR}.#{PASSENGER_API_VERSION_MINOR}"
88
90
  SERVER_INSTANCE_DIR_STRUCTURE_MAJOR_VERSION = 3
89
91
  SERVER_INSTANCE_DIR_STRUCTURE_MINOR_VERSION = 0
@@ -309,10 +309,26 @@ module PhusionPassenger
309
309
  options = { :logger => logger }
310
310
  begin
311
311
  try_directories(target_dirs, options) do |target_dir|
312
- result =
313
- sh_nonfatal("#{PlatformInfo.ruby_command} #{Shellwords.escape extconf_rb}",
314
- options) &&
315
- sh_nonfatal("make clean && make", options)
312
+ result = nil
313
+ # Perform the actual compilation in a temporary directory to avoid
314
+ # problems with multiple processes trying to concurrently compile.
315
+ # https://github.com/phusion/passenger/issues/1570
316
+ PhusionPassenger::Utils.mktmpdir("passenger-native-support-") do |tmpdir|
317
+ Dir.chdir(tmpdir) do
318
+ result =
319
+ sh_nonfatal("#{PlatformInfo.ruby_command} #{Shellwords.escape extconf_rb}",
320
+ options) &&
321
+ sh_nonfatal("make", options)
322
+ if result
323
+ begin
324
+ FileUtils.cp_r(".", target_dir)
325
+ rescue SystemCallError => e
326
+ log("Error: #{e}")
327
+ result = false
328
+ end
329
+ end
330
+ end
331
+ end
316
332
  if result
317
333
  log "Compilation succesful. The logs are here:"
318
334
  log logger.path
@@ -306,6 +306,14 @@ LOCATION_CONFIGURATION_OPTIONS = [
306
306
  :name => 'passenger_vary_turbocache_by_cookie',
307
307
  :type => :string
308
308
  },
309
+ {
310
+ :name => 'passenger_abort_websockets_on_process_shutdown',
311
+ :type => :flag
312
+ },
313
+ {
314
+ :name => 'passenger_force_max_concurrent_requests_per_process',
315
+ :type => :integer
316
+ },
309
317
 
310
318
  ###### Enterprise features ######
311
319
  {
@@ -95,6 +95,7 @@ module PhusionPassenger
95
95
  EXCLUDE_GLOB = [
96
96
  '**/.DS_Store',
97
97
  '.gitignore',
98
+ '.gitattributes',
98
99
  '.gitmodules',
99
100
  '.travis.yml',
100
101
  '.settings/*',
@@ -288,7 +288,7 @@ module PhusionPassenger
288
288
  if path
289
289
  begin
290
290
  Pathname.new(path).realpath.to_s
291
- rescue Errno::ENOENT, Errno::EACCES
291
+ rescue Errno::ENOENT, Errno::EACCES, Errno::ENOTDIR
292
292
  path
293
293
  end
294
294
  else
@@ -1,5 +1,5 @@
1
1
  # Phusion Passenger - https://www.phusionpassenger.com/
2
- # Copyright (c) 2010-2013 Phusion Holding B.V.
2
+ # Copyright (c) 2010-2015 Phusion Holding B.V.
3
3
  #
4
4
  # "Passenger", "Phusion Passenger" and "Union Station" are registered
5
5
  # trademarks of Phusion Holding B.V.
@@ -34,11 +34,13 @@ module PhusionPassenger
34
34
  # Identifiers for other operating systems may contain a version number, e.g. "freebsd10".
35
35
  def self.os_name
36
36
  if rb_config['target_os'] =~ /darwin/ && (sw_vers = find_command('sw_vers'))
37
- return "macosx"
37
+ 'macosx'
38
38
  elsif rb_config['target_os'] =~ /^linux-/
39
- return "linux"
39
+ 'linux'
40
+ elsif rb_config['target_os'] =~ /solaris/
41
+ 'solaris'
40
42
  else
41
- return rb_config['target_os']
43
+ rb_config['target_os']
42
44
  end
43
45
  end
44
46
  memoize :os_name
@@ -148,6 +150,11 @@ module PhusionPassenger
148
150
  end
149
151
  memoize :cpu_architectures, true
150
152
 
153
+ # Returns whether the flock() function is supported on this OS.
154
+ def self.supports_flock?
155
+ defined?(File::LOCK_EX) && os_name != 'solaris'
156
+ end
157
+
151
158
  # Returns whether the OS's main CPU architecture supports the
152
159
  # x86/x86_64 sfence instruction.
153
160
  def self.supports_sfence_instruction?
@@ -241,7 +241,7 @@ module PhusionPassenger
241
241
  # Disallowed by the HTTP spec
242
242
  raise "Response object may not contain both Content-Length and Transfer-Encoding"
243
243
  end
244
- else
244
+ elsif output_body
245
245
  # The app has set neither the Content-Length nor the Transfer-Encoding
246
246
  # header. This means we'll have to add one of those headers. We know exactly how
247
247
  # big our body will be, so we can keep-alive the connection.
@@ -0,0 +1,647 @@
1
+ # Phusion Passenger - https://www.phusionpassenger.com/
2
+ # Copyright (c) 2015 Phusion Holding B.V.
3
+ #
4
+ # "Passenger", "Phusion Passenger" and "Union Station" are registered
5
+ # trademarks of Phusion Holding B.V.
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in
15
+ # all copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ # THE SOFTWARE.
24
+
25
+ PhusionPassenger.require_passenger_lib 'constants'
26
+ PhusionPassenger.require_passenger_lib 'platform_info/ruby'
27
+
28
+ # This file contains a specification of all supported Passenger Standalone
29
+ # configuration options. The specifications are spread over multiple constants,
30
+ # one for each category. The command line parser for `passenger start` is
31
+ # automatically generated from these specifications. The configuration file
32
+ # parser and the environment variable parser also use these specifications.
33
+ #
34
+ # A specification is an array of hashes. The following keys are supported:
35
+ #
36
+ # - :name
37
+ # The name of the configuration option. If you omit this option, while
38
+ # simultaneously setting the `:cli` option, then it means this configuration
39
+ # option is available as a command line option only.
40
+ #
41
+ # - :type
42
+ # (default: :string)
43
+ # The value type. Supported types are: :string, :integer, :boolean, :path,
44
+ # :array, :map.
45
+ # This is used for determining a default parser and for checking the value.
46
+ #
47
+ # - :type_desc
48
+ # (default: automatically inferred)
49
+ # A description of the value type, to be used in command line option help
50
+ # messages. For example, the `:address` option should have the type desc
51
+ # `HOST` so that the help message `--address HOST` is generated. Boolean
52
+ # options have a `type_desc` of nil.
53
+ #
54
+ # - :cli
55
+ # (default: automatically inferred)
56
+ # The name of the corresponding command line option. If not specified, then
57
+ # a default one will be automatically generated form the configuration option
58
+ # name. For example, `:ssl_certificate_path` becomes `--ssl-certificate-path`.
59
+ # If set to nil, then it means there is no corresponding command line option.
60
+ #
61
+ # - :cli_parser
62
+ # (default: automatically inferred)
63
+ # Command line options are parsed based on the configuration option type.
64
+ # If you want to parse it differently, then you can set this option to a
65
+ # lambda to specify a custom parser.
66
+ #
67
+ # - :short_cli
68
+ # The name of the corresponding short command line option, if any. For
69
+ # example, the `:address` option should have `short_cli` set to `-a`.
70
+ #
71
+ # - :desc
72
+ # A description to be displayed in command line options help message.
73
+ #
74
+ # - :default
75
+ # The default value.
76
+ #
77
+ # - :min
78
+ # If :type is :integer, then this specifies the minimum accepted value.
79
+ # Has no meaing if :type is not :integer.
80
+ # This value is used by the default CLI parser to check whether the
81
+ # passed argument is acceptable.
82
+
83
+ module PhusionPassenger
84
+ module Standalone
85
+ # Server configuration options
86
+ SERVER_CONFIG_SPEC = [
87
+ {
88
+ :name => :address,
89
+ :type_desc => 'HOST',
90
+ :short_cli => '-a',
91
+ :default => '0.0.0.0',
92
+ :desc => "Bind to the given address.\n" \
93
+ "Default: %DEFAULT%"
94
+ },
95
+ {
96
+ :name => :port,
97
+ :type => :integer,
98
+ :short_cli => '-p',
99
+ :default => 3000,
100
+ :desc => 'Use the given port number. Default: %DEFAULT%'
101
+ },
102
+ {
103
+ :name => :socket_file,
104
+ :type => :path,
105
+ :type_desc => 'FILE',
106
+ :cli => '--socket',
107
+ :short_cli => '-S',
108
+ :desc => "Bind to Unix domain socket instead of TCP\n" \
109
+ 'socket'
110
+ },
111
+ {
112
+ :name => :ssl,
113
+ :type => :boolean,
114
+ :desc => "Enable SSL support (Nginx\n" \
115
+ 'engine only)'
116
+ },
117
+ {
118
+ :name => :ssl_certificate,
119
+ :type => :path,
120
+ :desc => "Specify the SSL certificate path\n" \
121
+ '(Nginx engine only)'
122
+ },
123
+ {
124
+ :name => :ssl_certificate_key,
125
+ :type => :path,
126
+ :desc => "Specify the SSL key path (Nginx\n" \
127
+ 'engine only)'
128
+ },
129
+ {
130
+ :name => :ssl_port,
131
+ :type => :integer,
132
+ :type_desc => 'PORT',
133
+ :desc => "Listen for SSL on this port, while\n" \
134
+ "listening for HTTP on the normal port\n" \
135
+ '(Nginx engine only)'
136
+ },
137
+ {
138
+ :name => :daemonize,
139
+ :type => :boolean,
140
+ :short_cli => '-d',
141
+ :desc => 'Daemonize into the background'
142
+ },
143
+ {
144
+ :name => :user,
145
+ :type_desc => 'USERNAME',
146
+ :desc => "User to run as. Ignored unless\n" \
147
+ 'running as root'
148
+ },
149
+ {
150
+ :name => :log_file,
151
+ :type => :path,
152
+ :desc => "Where to write log messages. Default:\n" \
153
+ 'console, or /dev/null when daemonized'
154
+ },
155
+ {
156
+ :name => :pid_file,
157
+ :type => :path,
158
+ :desc => 'Where to store the PID file'
159
+ },
160
+ {
161
+ :name => :instance_registry_dir,
162
+ :type => :path,
163
+ :desc => 'Use the given instance registry directory'
164
+ },
165
+ {
166
+ :name => :data_buffer_dir,
167
+ :type => :path,
168
+ :desc => 'Use the given data buffer directory'
169
+ }
170
+ ]
171
+
172
+ # Application loading configuration options
173
+ APPLICATION_LOADING_CONFIG_SPECS = [
174
+ {
175
+ :name => :environment,
176
+ :type_desc => 'NAME',
177
+ :short_cli => '-e',
178
+ :default => ENV['RAILS_ENV'] || ENV['RACK_ENV'] || ENV['NODE_ENV'] ||
179
+ ENV['PASSENGER_APP_ENV'] || 'development',
180
+ :desc => "Web framework environment. Default:\n" \
181
+ "%DEFAULT%"
182
+ },
183
+ {
184
+ :name => :ruby,
185
+ :type_desc => 'FILENAME',
186
+ :desc => "Executable to use for Ruby apps.\n" \
187
+ "Default: #{PlatformInfo.ruby_command}\n" \
188
+ "(current context)"
189
+ },
190
+ {
191
+ :name => :python,
192
+ :type_desc => 'FILENAME',
193
+ :desc => 'Executable to use for Python apps'
194
+ },
195
+ {
196
+ :name => :nodejs,
197
+ :type_desc => 'FILENAME',
198
+ :desc => 'Executable to use for Node.js apps'
199
+ },
200
+ {
201
+ :name => :meteor_app_settings,
202
+ :type => :path,
203
+ :type_desc => 'FILENAME',
204
+ :desc => "Settings file to use for (development mode)\n" \
205
+ 'Meteor apps'
206
+ },
207
+ {
208
+ :type => :path,
209
+ :type_desc => 'FILENAME',
210
+ :cli => '--rackup',
211
+ :short_cli => '-R',
212
+ :cli_parser => lambda do |options, value|
213
+ options[:app_type] = 'rack'
214
+ options[:startup_file] = File.absolute_logical_path(value,
215
+ Dir.logical_pwd)
216
+ end,
217
+ :desc => "Consider application a Ruby app, and use\n" \
218
+ 'the given rackup file'
219
+ },
220
+ {
221
+ :name => :app_type,
222
+ :type_desc => 'NAME',
223
+ :desc => 'Force app to be detected as the given type'
224
+ },
225
+ {
226
+ :name => :startup_file,
227
+ :type => :path,
228
+ :type_desc => 'FILENAME',
229
+ :desc => 'Force given startup file to be used'
230
+ },
231
+ {
232
+ :name => :spawn_method,
233
+ :type_desc => 'NAME',
234
+ :default => PlatformInfo.ruby_supports_fork? ? DEFAULT_SPAWN_METHOD : 'direct',
235
+ :desc => 'The spawn method to use. Default: %DEFAULT%'
236
+ },
237
+ {
238
+ :name => :static_files_dir,
239
+ :type => :path,
240
+ :desc => "Specify the static files dir (Nginx engine\n" \
241
+ 'only)'
242
+ },
243
+ {
244
+ :name => :restart_dir,
245
+ :type => :path,
246
+ :desc => 'Specify the restart dir'
247
+ },
248
+ {
249
+ :name => :friendly_error_pages,
250
+ :type => :boolean,
251
+ :desc => 'Turn on friendly error pages'
252
+ },
253
+ {
254
+ :type => :boolean,
255
+ :cli => '--no-friendly-error-pages',
256
+ :cli_parser => lambda do |options, value|
257
+ options[:friendly_error_pages] = false
258
+ end,
259
+ :desc => 'Turn off friendly error pages'
260
+ },
261
+ {
262
+ :name => :load_shell_envvars,
263
+ :type => :boolean,
264
+ :desc => "Load shell startup files before loading\n" \
265
+ 'application'
266
+ },
267
+ {
268
+ :name => :debugger,
269
+ :type => :boolean,
270
+ :desc => 'Enable debugger support'
271
+ },
272
+ {
273
+ :name => :envvars,
274
+ :type => :map,
275
+ :type_desc => 'NAME=VALUE',
276
+ :default => {},
277
+ :cli => '--envvar',
278
+ :cli_parser => lambda do |options, value|
279
+ if value !~ /=.+/
280
+ abort "*** ERROR: invalid --envvar format: #{value}"
281
+ end
282
+ key, real_value = value.split('=', 2)
283
+ options[:envvars] ||= {}
284
+ options[:envvars][key] = real_value
285
+ end,
286
+ :desc => 'Pass environment variable to application'
287
+ }
288
+ ]
289
+
290
+ # Process management configuration options
291
+ PROCESS_MANAGEMENT_CONFIG_SPECS = [
292
+ {
293
+ :name => :max_pool_size,
294
+ :type => :integer,
295
+ :min => 1,
296
+ :desc => "Maximum number of application processes.\n" \
297
+ "Default: #{DEFAULT_MAX_POOL_SIZE}"
298
+ },
299
+ {
300
+ :name => :min_instances,
301
+ :type => :integer,
302
+ :min => 0,
303
+ :desc => "Minimum number of processes per\n" \
304
+ 'application. Default: 1'
305
+ },
306
+ {
307
+ :name => :pool_idle_time,
308
+ :type => :integer,
309
+ :type_desc => 'SECONDS',
310
+ :desc => "Maximum time that processes may be idle.\n" \
311
+ "Default: #{DEFAULT_POOL_IDLE_TIME}"
312
+ },
313
+ {
314
+ :name => :max_preloader_idle_time,
315
+ :type => :integer,
316
+ :type_desc => 'SECONDS',
317
+ :desc => "Maximum time that preloader processes may\n" \
318
+ "be idle. A value of 0 means that preloader\n" \
319
+ "processes never timeout. Default: #{DEFAULT_MAX_PRELOADER_IDLE_TIME}"
320
+ },
321
+ {
322
+ :name => :force_max_concurrent_requests_per_process,
323
+ :type => :integer,
324
+ :desc => "Force #{SHORT_PROGRAM_NAME} to believe that an\n" \
325
+ "application process can handle the given\n" \
326
+ "number of concurrent requests per process"
327
+ },
328
+ {
329
+ :name => :concurrency_model,
330
+ :type_desc => 'NAME',
331
+ :desc => "The concurrency model to use, either\n" \
332
+ "'process' or 'thread' (Enterprise only).\n" \
333
+ "Default: #{DEFAULT_CONCURRENCY_MODEL}"
334
+ },
335
+ {
336
+ :name => :thread_count,
337
+ :type => :integer,
338
+ :desc => "The number of threads to use when using\n" \
339
+ "the 'thread' concurrency model (Enterprise\n" \
340
+ "only). Default: #{DEFAULT_APP_THREAD_COUNT}"
341
+ },
342
+ {
343
+ :name => :memory_limit,
344
+ :type => :integer,
345
+ :type_desc => 'MB',
346
+ :desc => "Restart application processes that go over\n" \
347
+ "the given memory limit (Enterprise only)"
348
+ },
349
+ {
350
+ :name => :rolling_restarts,
351
+ :type => :boolean,
352
+ :desc => "Enable rolling restarts (Enterprise only)"
353
+ },
354
+ {
355
+ :name => :resist_deployment_errors,
356
+ :type => :boolean,
357
+ :desc => "Enable deployment error resistance\n" \
358
+ '(Enterprise only)'
359
+ }
360
+ ]
361
+
362
+ # Request handling configuration options
363
+ REQUEST_HANDLING_CONFIG_SPECS = [
364
+ {
365
+ :name => :max_request_time,
366
+ :type => :integer,
367
+ :type_desc => 'SECONDS',
368
+ :min => 0,
369
+ :desc => "Abort requests that take too much time\n" \
370
+ '(Enterprise only)'
371
+ },
372
+ {
373
+ :name => :max_request_queue_size,
374
+ :type => :integer,
375
+ :min => 1,
376
+ :desc => "Specify request queue size. Default: #{DEFAULT_MAX_REQUEST_QUEUE_SIZE}"
377
+ },
378
+ {
379
+ :name => :sticky_sessions,
380
+ :type => :boolean,
381
+ :desc => 'Enable sticky sessions'
382
+ },
383
+ {
384
+ :name => :sticky_sessions_cookie_name,
385
+ :type_desc => 'NAME',
386
+ :desc => "Cookie name to use for sticky sessions.\n" \
387
+ "Default: #{DEFAULT_STICKY_SESSIONS_COOKIE_NAME}"
388
+ },
389
+ {
390
+ :name => :vary_turbocache_by_cookie,
391
+ :type_desc => 'NAME',
392
+ :desc => "Vary the turbocache by the cookie of the\n" \
393
+ 'given name'
394
+ },
395
+ {
396
+ :name => :turbocaching,
397
+ :type => :boolean,
398
+ :cli => nil
399
+ },
400
+ {
401
+ :type => :boolean,
402
+ :cli => '--disable-turbocaching',
403
+ :desc => 'Disable turbocaching',
404
+ :cli_parser => lambda do |options, value|
405
+ options[:turbocaching] = false
406
+ end
407
+ },
408
+ {
409
+ :name => :abort_websockets_on_process_shutdown,
410
+ :type => :boolean,
411
+ :cli => nil
412
+ },
413
+ {
414
+ :type => :boolean,
415
+ :cli => '--no-abort-websockets-on-process-shutdown',
416
+ :desc => "Do not abort WebSocket connections on\n" \
417
+ 'process restart',
418
+ :cli_parser => lambda do |options, value|
419
+ options[:abort_websockets_on_process_shutdown] = false
420
+ end
421
+ }
422
+ ]
423
+
424
+ # Union Station configuration options
425
+ UNION_STATION_CONFIG_SPECS = [
426
+ {
427
+ :name => :union_station_gateway_address,
428
+ :cli => nil
429
+ },
430
+ {
431
+ :name => :union_station_gateway_port,
432
+ :type => :integer,
433
+ :cli => nil
434
+ },
435
+ {
436
+ :type_desc => 'HOST:PORT',
437
+ :cli => '--union-station-gateway',
438
+ :cli_parser => lambda do |options, value|
439
+ host, port = value.split(":", 2)
440
+ port = port.to_i
441
+ port = 443 if port == 0
442
+ options[:union_station_gateway_address] = host
443
+ options[:union_station_gateway_port] = port.to_i
444
+ end,
445
+ :desc => 'Specify Union Station Gateway host and port'
446
+ },
447
+ {
448
+ :name => :union_station_key,
449
+ :type_desc => 'KEY',
450
+ :desc => 'Specify Union Station key'
451
+ },
452
+ {
453
+ :name => :union_station_gateway_cert,
454
+ :type => :path,
455
+ :desc => "The certificate to use for contacting the\n" \
456
+ "Union Station gateway, or '-' to disable\n" \
457
+ "certificate checking",
458
+ :config_value_parser => lambda do |value, base_dir|
459
+ if value == '-'
460
+ '-'
461
+ else
462
+ File.absolute_logical_path(value.to_s, base_dir)
463
+ end
464
+ end,
465
+ :cli_parser => lambda do |options, value|
466
+ if value == '-'
467
+ options[:union_station_gateway_cert] = '-'
468
+ else
469
+ options[:union_station_gateway_cert] =
470
+ File.absolute_logical_path(value,
471
+ Dir.logical_pwd)
472
+ end
473
+ end
474
+ }
475
+ ]
476
+
477
+ # Nginx engine configuration options
478
+ NGINX_ENGINE_CONFIG_SPECS = [
479
+ {
480
+ :name => :nginx_bin,
481
+ :type => :path,
482
+ :type_desc => 'FILENAME',
483
+ :desc => 'Nginx binary to use as core'
484
+ },
485
+ {
486
+ :name => :nginx_version,
487
+ :type_desc => 'VERSION',
488
+ :default => PREFERRED_NGINX_VERSION,
489
+ :desc => "Nginx version to use as core.\n" \
490
+ "Default: #{PREFERRED_NGINX_VERSION}"
491
+ },
492
+ {
493
+ :name => :nginx_tarball,
494
+ :type => :path,
495
+ :type_desc => 'FILENAME',
496
+ :desc => "If Nginx needs to be installed, then the\n" \
497
+ "given tarball will be used instead of\n" \
498
+ "downloading from the Internet"
499
+ },
500
+ {
501
+ :name => :nginx_config_template,
502
+ :type => :path,
503
+ :type_desc => 'FILENAME',
504
+ :desc => "The template to use for generating the\n" \
505
+ 'Nginx config file'
506
+ },
507
+ {
508
+ :name => :debug_nginx_config,
509
+ :type => :boolean,
510
+ :desc => 'Print Nginx config template and exit'
511
+ }
512
+ ]
513
+
514
+ # Advanced configuration options
515
+ ADVANCED_CONFIG_SPECS = [
516
+ {
517
+ :name => :engine,
518
+ :type_desc => 'NAME',
519
+ :default => 'nginx',
520
+ :desc => "Underlying HTTP engine to use. Available\n" \
521
+ "options: nginx (default), builtin"
522
+ },
523
+ {
524
+ :name => :log_level,
525
+ :type => :integer,
526
+ :default => DEFAULT_LOG_LEVEL,
527
+ :desc => "Log level to use. Default: #{DEFAULT_LOG_LEVEL}"
528
+ },
529
+ {
530
+ :name => :auto,
531
+ :type => :boolean,
532
+ :default => !STDIN.tty? || !STDOUT.tty?,
533
+ :desc => "Run in non-interactive mode. Default when\n" \
534
+ 'stdin or stdout is not a TTY'
535
+ },
536
+ {
537
+ :name => :ctls,
538
+ :type => :array,
539
+ :type_desc => 'NAME=VALUE',
540
+ :default => [],
541
+ :cli_parser => lambda do |options, value|
542
+ if value !~ /=.+/
543
+ abort "*** ERROR: invalid --ctl format: #{value}"
544
+ end
545
+ options[:ctls] ||= []
546
+ options[:ctls] << value
547
+ end
548
+ },
549
+ {
550
+ :name => :binaries_url_root,
551
+ :type_desc => 'URL',
552
+ :desc => "If Nginx needs to be installed, then the\n" \
553
+ "specified URL will be checked for binaries\n" \
554
+ 'prior to a local build'
555
+ },
556
+ {
557
+ :name => :runtime_check_only,
558
+ :type => :boolean,
559
+ :desc => "Quit after checking whether the\n" \
560
+ "#{PROGRAM_NAME} Standalone runtime files\n" \
561
+ 'are installed'
562
+ },
563
+ {
564
+ :name => :dont_install_runtime,
565
+ :type => :boolean,
566
+ :cli => '--no-install-runtime',
567
+ :desc => 'Abort if runtime must be installed'
568
+ },
569
+ {
570
+ :name => :dont_compile_runtime,
571
+ :type => :boolean,
572
+ :cli => '--no-compile-runtime',
573
+ :desc => 'Abort if runtime must be compiled'
574
+ }
575
+ ]
576
+
577
+ CONFIG_SPECS = [
578
+ SERVER_CONFIG_SPEC,
579
+ APPLICATION_LOADING_CONFIG_SPECS,
580
+ PROCESS_MANAGEMENT_CONFIG_SPECS,
581
+ REQUEST_HANDLING_CONFIG_SPECS,
582
+ UNION_STATION_CONFIG_SPECS,
583
+ NGINX_ENGINE_CONFIG_SPECS,
584
+ ADVANCED_CONFIG_SPECS
585
+ ]
586
+
587
+ # Maps configuration options to their default value. Automatically
588
+ # set by code later in this file.
589
+ #
590
+ # To inspect the value of this array, run:
591
+ #
592
+ # ./dev/runner -r standalone/config_options_list -r pp \
593
+ # 'pp Standalone::CONFIG_DEFAULTS; nil'
594
+ CONFIG_DEFAULTS = {}
595
+
596
+ # Indexes all configuration specification items by name.
597
+ #
598
+ # To inspect the value of this array, run:
599
+ #
600
+ # ./dev/runner -r standalone/config_options_list -r pp \
601
+ # 'pp Standalone::CONFIG_NAME_INDEX; nil'
602
+ CONFIG_NAME_INDEX = {}
603
+
604
+
605
+ ############
606
+
607
+
608
+ # Apply transformations on the specification constants, e.g. set default values.
609
+
610
+ make_default_type_desc_value = lambda do |spec_item|
611
+ case spec_item[:type]
612
+ when :string
613
+ 'STRING'
614
+ when :integer
615
+ 'NUMBER'
616
+ when :path
617
+ 'PATH'
618
+ when :array
619
+ 'ARRAY'
620
+ when :map
621
+ 'MAP'
622
+ else
623
+ nil
624
+ end
625
+ end
626
+
627
+ make_default_cli_value = lambda do |spec_item|
628
+ '--' + spec_item[:name].to_s.gsub('_', '-')
629
+ end
630
+
631
+ CONFIG_SPECS.each do |spec|
632
+ spec.each do |spec_item|
633
+ spec_item[:type] ||= :string
634
+ spec_item[:type_desc] ||= make_default_type_desc_value.call(spec_item)
635
+ if spec_item[:name]
636
+ if !spec_item.key?(:cli)
637
+ spec_item[:cli] = make_default_cli_value.call(spec_item)
638
+ end
639
+ if spec_item[:default]
640
+ CONFIG_DEFAULTS[spec_item[:name]] = spec_item[:default]
641
+ end
642
+ CONFIG_NAME_INDEX[spec_item[:name]] = spec_item
643
+ end
644
+ end
645
+ end
646
+ end
647
+ end