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
@@ -0,0 +1,161 @@
1
+ /*
2
+ * Phusion Passenger - https://www.phusionpassenger.com/
3
+ * Copyright (c) 2014-2015 Phusion Holding B.V.
4
+ *
5
+ * "Passenger", "Phusion Passenger" and "Union Station" are registered
6
+ * trademarks of Phusion Holding B.V.
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ * of this software and associated documentation files (the "Software"), to deal
10
+ * in the Software without restriction, including without limitation the rights
11
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ * copies of the Software, and to permit persons to whom the Software is
13
+ * furnished to do so, subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in
16
+ * all copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ * THE SOFTWARE.
25
+ */
26
+ #include <Core/Controller.h>
27
+
28
+ /*************************************************************************
29
+ *
30
+ * State inspection functions for Core::Controller
31
+ *
32
+ *************************************************************************/
33
+
34
+ namespace Passenger {
35
+ namespace Core {
36
+
37
+ using namespace std;
38
+ using namespace boost;
39
+
40
+
41
+ /****************************
42
+ *
43
+ * Public methods
44
+ *
45
+ ****************************/
46
+
47
+
48
+ Json::Value
49
+ Controller::getConfigAsJson() const {
50
+ Json::Value doc = ParentClass::getConfigAsJson();
51
+ doc["single_app_mode"] = singleAppMode;
52
+ doc["stat_throttle_rate"] = statThrottleRate;
53
+ doc["show_version_in_header"] = showVersionInHeader;
54
+ doc["data_buffer_dir"] = getContext()->defaultFileBufferedChannelConfig.bufferDir;
55
+ return doc;
56
+ }
57
+
58
+ void
59
+ Controller::configure(const Json::Value &doc) {
60
+ ParentClass::configure(doc);
61
+ if (doc.isMember("show_version_in_header")) {
62
+ showVersionInHeader = doc["show_version_in_header"].asBool();
63
+ }
64
+ if (doc.isMember("data_buffer_dir")) {
65
+ getContext()->defaultFileBufferedChannelConfig.bufferDir =
66
+ doc["data_buffer_dir"].asString();
67
+ }
68
+ }
69
+
70
+ Json::Value
71
+ Controller::inspectStateAsJson() const {
72
+ Json::Value doc = ParentClass::inspectStateAsJson();
73
+ if (turboCaching.isEnabled()) {
74
+ Json::Value subdoc;
75
+ subdoc["fetches"] = turboCaching.responseCache.getFetches();
76
+ subdoc["hits"] = turboCaching.responseCache.getHits();
77
+ subdoc["hit_ratio"] = turboCaching.responseCache.getHitRatio();
78
+ subdoc["stores"] = turboCaching.responseCache.getStores();
79
+ subdoc["store_successes"] = turboCaching.responseCache.getStoreSuccesses();
80
+ subdoc["store_success_ratio"] = turboCaching.responseCache.getStoreSuccessRatio();
81
+ doc["turbocaching"] = subdoc;
82
+ }
83
+ return doc;
84
+ }
85
+
86
+ Json::Value
87
+ Controller::inspectClientStateAsJson(const Client *client) const {
88
+ Json::Value doc = ParentClass::inspectClientStateAsJson(client);
89
+ doc["connected_at"] = timeToJson(client->connectedAt * 1000000.0);
90
+ return doc;
91
+ }
92
+
93
+ Json::Value
94
+ Controller::inspectRequestStateAsJson(const Request *req) const {
95
+ Json::Value doc = ParentClass::inspectRequestStateAsJson(req);
96
+ Json::Value flags;
97
+ const AppResponse *resp = &req->appResponse;
98
+
99
+ if (req->startedAt != 0) {
100
+ doc["started_at"] = timeToJson(req->startedAt * 1000000.0);
101
+ }
102
+ doc["state"] = req->getStateString();
103
+ if (req->stickySession) {
104
+ doc["sticky_session_id"] = req->options.stickySessionId;
105
+ }
106
+ doc["sticky_session"] = req->stickySession;
107
+ doc["session_checkout_try"] = req->sessionCheckoutTry;
108
+
109
+ flags["dechunk_response"] = req->dechunkResponse;
110
+ flags["request_body_buffering"] = req->requestBodyBuffering;
111
+ flags["https"] = req->https;
112
+ doc["flags"] = flags;
113
+
114
+ if (req->requestBodyBuffering) {
115
+ doc["body_bytes_buffered"] = byteSizeToJson(req->bodyBytesBuffered);
116
+ }
117
+
118
+ if (req->session != NULL) {
119
+ Json::Value &sessionDoc = doc["session"] = Json::Value(Json::objectValue);
120
+ const Session *session = req->session.get();
121
+
122
+ if (req->session->isClosed()) {
123
+ sessionDoc["closed"] = true;
124
+ } else {
125
+ sessionDoc["pid"] = (Json::Int64) session->getPid();
126
+ sessionDoc["gupid"] = session->getGupid().toString();
127
+ }
128
+ }
129
+
130
+ if (req->appResponseInitialized) {
131
+ doc["app_response_http_state"] = resp->getHttpStateString();
132
+ if (resp->begun()) {
133
+ doc["app_response_http_major"] = resp->httpMajor;
134
+ doc["app_response_http_minor"] = resp->httpMinor;
135
+ doc["app_response_want_keep_alive"] = resp->wantKeepAlive;
136
+ doc["app_response_body_type"] = resp->getBodyTypeString();
137
+ doc["app_response_body_fully_read"] = resp->bodyFullyRead();
138
+ doc["app_response_body_already_read"] = byteSizeToJson(
139
+ resp->bodyAlreadyRead);
140
+ if (resp->httpState != AppResponse::ERROR) {
141
+ if (resp->bodyType == AppResponse::RBT_CONTENT_LENGTH) {
142
+ doc["app_response_content_length"] = byteSizeToJson(
143
+ resp->aux.bodyInfo.contentLength);
144
+ } else if (resp->bodyType == AppResponse::RBT_CHUNKED) {
145
+ doc["app_response_end_chunk_reached"] = resp->aux.bodyInfo.endChunkReached;
146
+ }
147
+ } else {
148
+ doc["app_response_parse_error"] = ServerKit::getErrorDesc(resp->aux.parseError);
149
+ }
150
+ }
151
+ }
152
+
153
+ doc["app_source_state"] = req->appSource.inspectAsJson();
154
+ doc["app_sink_state"] = req->appSink.inspectAsJson();
155
+
156
+ return doc;
157
+ }
158
+
159
+
160
+ } // namespace Core
161
+ } // namespace Passenger
@@ -39,6 +39,8 @@
39
39
  #include <Core/ResponseCache.h>
40
40
 
41
41
  namespace Passenger {
42
+ namespace Core {
43
+
42
44
 
43
45
  using namespace std;
44
46
 
@@ -290,6 +292,7 @@ public:
290
292
  };
291
293
 
292
294
 
295
+ } // namespace Core
293
296
  } // namespace Passenger
294
297
 
295
298
  #endif /* _PASSENGER_TURBO_CACHING_H_ */
@@ -84,10 +84,10 @@
84
84
  #include <Utils/MessageIO.h>
85
85
  #include <Utils/VariantMap.h>
86
86
  #include <Core/OptionParser.h>
87
- #include <Core/RequestHandler.h>
87
+ #include <Core/Controller.h>
88
88
  #include <Core/ApiServer.h>
89
89
  #include <Core/ApplicationPool/Pool.h>
90
- #include <Core/UnionStation/Core.h>
90
+ #include <Core/UnionStation/Context.h>
91
91
 
92
92
  using namespace boost;
93
93
  using namespace oxt;
@@ -102,19 +102,19 @@ namespace Core {
102
102
  struct ThreadWorkingObjects {
103
103
  BackgroundEventLoop *bgloop;
104
104
  ServerKit::Context *serverKitContext;
105
- RequestHandler *requestHandler;
105
+ Controller *controller;
106
106
 
107
107
  ThreadWorkingObjects()
108
108
  : bgloop(NULL),
109
109
  serverKitContext(NULL),
110
- requestHandler(NULL)
110
+ controller(NULL)
111
111
  { }
112
112
  };
113
113
 
114
114
  struct ApiWorkingObjects {
115
115
  BackgroundEventLoop *bgloop;
116
116
  ServerKit::Context *serverKitContext;
117
- ApiServer *apiServer;
117
+ ApiServer::ApiServer *apiServer;
118
118
 
119
119
  ApiWorkingObjects()
120
120
  : bgloop(NULL),
@@ -131,12 +131,12 @@ namespace Core {
131
131
 
132
132
  ResourceLocator resourceLocator;
133
133
  RandomGeneratorPtr randomGenerator;
134
- UnionStation::CorePtr unionStationCore;
134
+ UnionStation::ContextPtr unionStationContext;
135
135
  SpawningKit::ConfigPtr spawningKitConfig;
136
136
  SpawningKit::FactoryPtr spawningKitFactory;
137
137
  PoolPtr appPool;
138
138
 
139
- ServerKit::AcceptLoadBalancer<RequestHandler> loadBalancer;
139
+ ServerKit::AcceptLoadBalancer<Controller> loadBalancer;
140
140
  vector<ThreadWorkingObjects> threadWorkingObjects;
141
141
  struct ev_signal sigintWatcher;
142
142
  struct ev_signal sigtermWatcher;
@@ -167,7 +167,7 @@ namespace Core {
167
167
 
168
168
  vector<ThreadWorkingObjects>::iterator it, end = threadWorkingObjects.end();
169
169
  for (it = threadWorkingObjects.begin(); it != end; it++) {
170
- delete it->requestHandler;
170
+ delete it->controller;
171
171
  delete it->serverKitContext;
172
172
  delete it->bgloop;
173
173
  }
@@ -192,8 +192,8 @@ static void waitForExitEvent();
192
192
  static void cleanup();
193
193
  static void deletePidFile();
194
194
  static void abortLongRunningConnections(const ApplicationPool2::ProcessPtr &process);
195
- static void requestHandlerShutdownFinished(RequestHandler *server);
196
- static void apiServerShutdownFinished(Core::ApiServer *server);
195
+ static void controllerShutdownFinished(Controller *controller);
196
+ static void apiServerShutdownFinished(Core::ApiServer::ApiServer *server);
197
197
  static void printInfoInThread();
198
198
 
199
199
  static void
@@ -377,13 +377,13 @@ printInfo(EV_P_ struct ev_signal *watcher, int revents) {
377
377
  }
378
378
 
379
379
  static void
380
- inspectRequestHandlerStateAsJson(RequestHandler *rh, string *result) {
381
- *result = rh->inspectStateAsJson().toStyledString();
380
+ inspectControllerStateAsJson(Controller *controller, string *result) {
381
+ *result = controller->inspectStateAsJson().toStyledString();
382
382
  }
383
383
 
384
384
  static void
385
- inspectRequestHandlerConfigAsJson(RequestHandler *rh, string *result) {
386
- *result = rh->getConfigAsJson().toStyledString();
385
+ inspectControllerConfigAsJson(Controller *controller, string *result) {
386
+ *result = controller->getConfigAsJson().toStyledString();
387
387
  }
388
388
 
389
389
  static void
@@ -407,8 +407,8 @@ printInfoInThread() {
407
407
  string json;
408
408
 
409
409
  cerr << "### Request handler state (thread " << (i + 1) << ")\n";
410
- two->bgloop->safe->runSync(boost::bind(inspectRequestHandlerStateAsJson,
411
- two->requestHandler, &json));
410
+ two->bgloop->safe->runSync(boost::bind(inspectControllerStateAsJson,
411
+ two->controller, &json));
412
412
  cerr << json;
413
413
  cerr << "\n";
414
414
  cerr.flush();
@@ -419,8 +419,8 @@ printInfoInThread() {
419
419
  string json;
420
420
 
421
421
  cerr << "### Request handler config (thread " << (i + 1) << ")\n";
422
- two->bgloop->safe->runSync(boost::bind(inspectRequestHandlerConfigAsJson,
423
- two->requestHandler, &json));
422
+ two->bgloop->safe->runSync(boost::bind(inspectControllerConfigAsJson,
423
+ two->controller, &json));
424
424
  cerr << json;
425
425
  cerr << "\n";
426
426
  cerr.flush();
@@ -455,7 +455,7 @@ dumpDiagnosticsOnCrash(void *userData) {
455
455
  for (i = 0; i < wo->threadWorkingObjects.size(); i++) {
456
456
  ThreadWorkingObjects *two = &wo->threadWorkingObjects[i];
457
457
  cerr << "### Request handler state (thread " << (i + 1) << ")\n";
458
- cerr << two->requestHandler->inspectStateAsJson();
458
+ cerr << two->controller->inspectStateAsJson();
459
459
  cerr << "\n";
460
460
  cerr.flush();
461
461
  }
@@ -463,7 +463,7 @@ dumpDiagnosticsOnCrash(void *userData) {
463
463
  for (i = 0; i < wo->threadWorkingObjects.size(); i++) {
464
464
  ThreadWorkingObjects *two = &wo->threadWorkingObjects[i];
465
465
  cerr << "### Request handler config (thread " << (i + 1) << ")\n";
466
- cerr << two->requestHandler->getConfigAsJson();
466
+ cerr << two->controller->getConfigAsJson();
467
467
  cerr << "\n";
468
468
  cerr.flush();
469
469
  }
@@ -547,7 +547,7 @@ initializeNonPrivilegedWorkingObjects() {
547
547
 
548
548
  UPDATE_TRACE_POINT();
549
549
  if (options.has("ust_router_address")) {
550
- wo->unionStationCore = boost::make_shared<UnionStation::Core>(
550
+ wo->unionStationContext = boost::make_shared<UnionStation::Context>(
551
551
  options.get("ust_router_address"),
552
552
  "logging",
553
553
  options.get("ust_router_password"));
@@ -558,7 +558,7 @@ initializeNonPrivilegedWorkingObjects() {
558
558
  wo->spawningKitConfig->resourceLocator = &wo->resourceLocator;
559
559
  wo->spawningKitConfig->agentsOptions = agentsOptions;
560
560
  wo->spawningKitConfig->errorHandler = spawningKitErrorHandler;
561
- wo->spawningKitConfig->unionStationCore = wo->unionStationCore;
561
+ wo->spawningKitConfig->unionStationContext = wo->unionStationContext;
562
562
  wo->spawningKitConfig->randomGenerator = wo->randomGenerator;
563
563
  wo->spawningKitConfig->instanceDir = options.get("instance_dir", false);
564
564
  if (!wo->spawningKitConfig->instanceDir.empty()) {
@@ -600,14 +600,14 @@ initializeNonPrivilegedWorkingObjects() {
600
600
  options.getUint("file_buffer_threshold");
601
601
 
602
602
  UPDATE_TRACE_POINT();
603
- two.requestHandler = new RequestHandler(two.serverKitContext, agentsOptions, i + 1);
604
- two.requestHandler->minSpareClients = 128;
605
- two.requestHandler->clientFreelistLimit = 1024;
606
- two.requestHandler->resourceLocator = &wo->resourceLocator;
607
- two.requestHandler->appPool = wo->appPool;
608
- two.requestHandler->unionStationCore = wo->unionStationCore;
609
- two.requestHandler->shutdownFinishCallback = requestHandlerShutdownFinished;
610
- two.requestHandler->initialize();
603
+ two.controller = new Core::Controller(two.serverKitContext, agentsOptions, i + 1);
604
+ two.controller->minSpareClients = 128;
605
+ two.controller->clientFreelistLimit = 1024;
606
+ two.controller->resourceLocator = &wo->resourceLocator;
607
+ two.controller->appPool = wo->appPool;
608
+ two.controller->unionStationContext = wo->unionStationContext;
609
+ two.controller->shutdownFinishCallback = controllerShutdownFinished;
610
+ two.controller->initialize();
611
611
  wo->shutdownCounter.fetch_add(1, boost::memory_order_relaxed);
612
612
 
613
613
  wo->threadWorkingObjects.push_back(two);
@@ -636,11 +636,11 @@ initializeNonPrivilegedWorkingObjects() {
636
636
  options.getUint("file_buffer_threshold");
637
637
 
638
638
  UPDATE_TRACE_POINT();
639
- awo->apiServer = new Core::ApiServer(awo->serverKitContext);
640
- awo->apiServer->requestHandlers.reserve(wo->threadWorkingObjects.size());
639
+ awo->apiServer = new Core::ApiServer::ApiServer(awo->serverKitContext);
640
+ awo->apiServer->controllers.reserve(wo->threadWorkingObjects.size());
641
641
  for (unsigned int i = 0; i < wo->threadWorkingObjects.size(); i++) {
642
- awo->apiServer->requestHandlers.push_back(
643
- wo->threadWorkingObjects[i].requestHandler);
642
+ awo->apiServer->controllers.push_back(
643
+ wo->threadWorkingObjects[i].controller);
644
644
  }
645
645
  awo->apiServer->apiAccountDatabase = &wo->apiAccountDatabase;
646
646
  awo->apiServer->appPool = wo->appPool;
@@ -663,20 +663,20 @@ initializeNonPrivilegedWorkingObjects() {
663
663
  for (unsigned int i = 0; i < addresses.size(); i++) {
664
664
  if (nthreads == 1) {
665
665
  ThreadWorkingObjects *two = &wo->threadWorkingObjects[0];
666
- two->requestHandler->listen(wo->serverFds[i]);
666
+ two->controller->listen(wo->serverFds[i]);
667
667
  } else {
668
668
  wo->loadBalancer.listen(wo->serverFds[i]);
669
669
  }
670
670
  }
671
671
  for (unsigned int i = 0; i < nthreads; i++) {
672
672
  ThreadWorkingObjects *two = &wo->threadWorkingObjects[i];
673
- two->requestHandler->createSpareClients();
673
+ two->controller->createSpareClients();
674
674
  }
675
675
  if (nthreads > 1) {
676
676
  wo->loadBalancer.servers.reserve(nthreads);
677
677
  for (unsigned int i = 0; i < nthreads; i++) {
678
678
  ThreadWorkingObjects *two = &wo->threadWorkingObjects[i];
679
- wo->loadBalancer.servers.push_back(two->requestHandler);
679
+ wo->loadBalancer.servers.push_back(two->controller);
680
680
  }
681
681
  }
682
682
  for (unsigned int i = 0; i < apiAddresses.size(); i++) {
@@ -780,10 +780,10 @@ mainLoop() {
780
780
  }
781
781
 
782
782
  static void
783
- abortLongRunningConnectionsOnRequestHandler(RequestHandler *requestHandler,
783
+ abortLongRunningConnectionsOnController(Core::Controller *controller,
784
784
  string gupid)
785
785
  {
786
- requestHandler->disconnectLongRunningConnections(gupid);
786
+ controller->disconnectLongRunningConnections(gupid);
787
787
  }
788
788
 
789
789
  static void
@@ -794,15 +794,15 @@ abortLongRunningConnections(const ApplicationPool2::ProcessPtr &process) {
794
794
  process->getPid() << ", application " << process->getGroup()->getName());
795
795
  for (unsigned int i = 0; i < wo->threadWorkingObjects.size(); i++) {
796
796
  wo->threadWorkingObjects[i].bgloop->safe->runLater(
797
- boost::bind(abortLongRunningConnectionsOnRequestHandler,
798
- wo->threadWorkingObjects[i].requestHandler,
797
+ boost::bind(abortLongRunningConnectionsOnController,
798
+ wo->threadWorkingObjects[i].controller,
799
799
  process->getGupid().toString()));
800
800
  }
801
801
  }
802
802
 
803
803
  static void
804
- shutdownRequestHandler(ThreadWorkingObjects *two) {
805
- two->requestHandler->shutdown();
804
+ shutdownController(ThreadWorkingObjects *two) {
805
+ two->controller->shutdown();
806
806
  }
807
807
 
808
808
  static void
@@ -820,12 +820,12 @@ serverShutdownFinished() {
820
820
  }
821
821
 
822
822
  static void
823
- requestHandlerShutdownFinished(RequestHandler *server) {
823
+ controllerShutdownFinished(Core::Controller *controller) {
824
824
  serverShutdownFinished();
825
825
  }
826
826
 
827
827
  static void
828
- apiServerShutdownFinished(Core::ApiServer *server) {
828
+ apiServerShutdownFinished(Core::ApiServer::ApiServer *server) {
829
829
  serverShutdownFinished();
830
830
  }
831
831
 
@@ -878,7 +878,7 @@ waitForExitEvent() {
878
878
 
879
879
  for (unsigned i = 0; i < wo->threadWorkingObjects.size(); i++) {
880
880
  ThreadWorkingObjects *two = &wo->threadWorkingObjects[i];
881
- two->bgloop->safe->runLater(boost::bind(shutdownRequestHandler, two));
881
+ two->bgloop->safe->runLater(boost::bind(shutdownController, two));
882
882
  }
883
883
  if (wo->threadWorkingObjects.size() > 1) {
884
884
  wo->loadBalancer.shutdown();
@@ -920,8 +920,8 @@ cleanup() {
920
920
  wo->appPool.reset();
921
921
  for (unsigned i = 0; i < wo->threadWorkingObjects.size(); i++) {
922
922
  ThreadWorkingObjects *two = &wo->threadWorkingObjects[i];
923
- delete two->requestHandler;
924
- two->requestHandler = NULL;
923
+ delete two->controller;
924
+ two->controller = NULL;
925
925
  }
926
926
  if (wo->prestarterThread != NULL) {
927
927
  wo->prestarterThread->interrupt_and_join();
@@ -1052,13 +1052,16 @@ setAgentsOptionsDefaults() {
1052
1052
  options.setDefault("environment", DEFAULT_APP_ENV);
1053
1053
  options.setDefault("spawn_method", DEFAULT_SPAWN_METHOD);
1054
1054
  options.setDefaultBool("load_shell_envvars", false);
1055
+ options.setDefaultBool("abort_websockets_on_process_shutdown", true);
1056
+ options.setDefaultInt("force_max_concurrent_requests_per_process", -1);
1055
1057
  options.setDefault("concurrency_model", DEFAULT_CONCURRENCY_MODEL);
1056
1058
  options.setDefaultInt("app_thread_count", DEFAULT_APP_THREAD_COUNT);
1057
1059
  options.setDefaultInt("max_pool_size", DEFAULT_MAX_POOL_SIZE);
1058
1060
  options.setDefaultInt("pool_idle_time", DEFAULT_POOL_IDLE_TIME);
1059
1061
  options.setDefaultInt("min_instances", 1);
1060
1062
  options.setDefaultInt("max_preloader_idle_time", DEFAULT_MAX_PRELOADER_IDLE_TIME);
1061
- options.setDefaultInt("stat_throttle_rate", DEFAULT_STAT_THROTTLE_RATE);
1063
+ options.setDefaultUint("max_request_queue_size", DEFAULT_MAX_REQUEST_QUEUE_SIZE);
1064
+ options.setDefaultUint("stat_throttle_rate", DEFAULT_STAT_THROTTLE_RATE);
1062
1065
  options.setDefault("server_software", SERVER_TOKEN_NAME "/" PASSENGER_VERSION);
1063
1066
  options.setDefaultBool("show_version_in_header", true);
1064
1067
  options.setDefaultBool("sticky_sessions", false);
@@ -1155,6 +1158,14 @@ sanityCheckOptions() {
1155
1158
  ok = false;
1156
1159
  #endif
1157
1160
  }
1161
+ if (options.has("memory_limit")) {
1162
+ #ifndef PASSENGER_IS_ENTERPRISE
1163
+ fprintf(stderr, "ERROR: the --memory-limit option is only supported in "
1164
+ PROGRAM_NAME " Enterprise.\nYou are currently using the open source "
1165
+ PROGRAM_NAME ". Buy " PROGRAM_NAME " Enterprise here: https://www.phusionpassenger.com/enterprise\n");
1166
+ ok = false;
1167
+ #endif
1168
+ }
1158
1169
  if (options.has("max_request_time")) {
1159
1170
  if (options.getInt("max_request_time", false, 0) < 1) {
1160
1171
  fprintf(stderr, "ERROR: the value passed to --max-request-time must be at least 1.\n");
@@ -1167,8 +1178,8 @@ sanityCheckOptions() {
1167
1178
  ok = false;
1168
1179
  #endif
1169
1180
  }
1170
- if (RequestHandler::parseBenchmarkMode(options.get("benchmark_mode", false))
1171
- == RequestHandler::BM_UNKNOWN)
1181
+ if (Core::Controller::parseBenchmarkMode(options.get("benchmark_mode", false))
1182
+ == Core::Controller::BM_UNKNOWN)
1172
1183
  {
1173
1184
  fprintf(stderr, "ERROR: '%s' is not a valid mode for --benchmark.\n",
1174
1185
  options.get("benchmark_mode", false).c_str());