passenger 5.0.10 → 5.0.11
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.
- checksums.yaml +8 -8
- checksums.yaml.gz.asc +7 -7
- data.tar.gz.asc +7 -7
- data/CHANGELOG +18 -0
- data/CONTRIBUTING.md +3 -3
- data/bin/passenger-status +12 -4
- data/build/agents.rb +45 -45
- data/build/apache2.rb +1 -1
- data/build/basics.rb +1 -1
- data/build/cxx_tests.rb +12 -12
- data/doc/CloudLicensingConfiguration.html +10 -10
- data/doc/CloudLicensingConfiguration.txt.md +10 -10
- data/doc/DebuggingAndStressTesting.md +3 -3
- data/doc/Design and Architecture.html +30 -30
- data/doc/Design and Architecture.txt +28 -28
- data/doc/ServerOptimizationGuide.html +3 -3
- data/doc/ServerOptimizationGuide.txt.md +3 -3
- data/doc/Users guide Apache.html +24 -12
- data/doc/Users guide Apache.txt +2 -2
- data/doc/Users guide Nginx.html +24 -12
- data/doc/Users guide Nginx.txt +2 -2
- data/doc/Users guide Standalone.html +18 -6
- data/doc/images/passenger_architecture.png +0 -0
- data/doc/images/passenger_architecture.svg +10 -9
- data/doc/images/{helper_agent_core_architecture.png → passenger_core_architecture.png} +0 -0
- data/doc/users_guide_snippets/environment_variables.txt +1 -1
- data/doc/users_guide_snippets/installation/verify_running_epilogue.txt +1 -1
- data/doc/users_guide_snippets/support_information.txt +1 -1
- data/doc/users_guide_snippets/tips.txt +2 -2
- data/doc/users_guide_snippets/under_the_hood/relationship_with_ruby.txt +1 -1
- data/ext/apache2/Bucket.h +5 -5
- data/ext/apache2/Configuration.cpp +1 -1
- data/ext/apache2/Configuration.hpp +2 -3
- data/ext/apache2/ConfigurationFields.hpp +3 -0
- data/ext/apache2/ConfigurationFields.hpp.erb +3 -0
- data/ext/apache2/Hooks.cpp +42 -34
- data/ext/common/Account.h +3 -3
- data/ext/common/AgentsStarter.cpp +7 -7
- data/ext/common/AgentsStarter.h +20 -20
- data/ext/common/ApplicationPool2/Options.h +12 -12
- data/ext/common/Constants.h +10 -8
- data/ext/common/Logging.cpp +22 -1
- data/ext/common/Logging.h +19 -2
- data/ext/common/ServerKit/AcceptLoadBalancer.h +3 -3
- data/ext/common/ServerKit/Server.h +24 -0
- data/ext/common/UnionStation/Connection.h +1 -1
- data/ext/common/UnionStation/Core.h +21 -21
- data/ext/common/UnionStation/Transaction.h +3 -3
- data/ext/common/Utils.cpp +2 -2
- data/ext/common/Utils/IOUtils.cpp +5 -1
- data/ext/common/{agents → agent}/ApiServerUtils.h +3 -3
- data/ext/common/{agents → agent}/Base.cpp +2 -2
- data/ext/common/{agents → agent}/Base.h +0 -0
- data/ext/common/{agents/HelperAgent → agent/Core}/ApiServer.h +33 -9
- data/ext/common/{agents/HelperAgent → agent/Core}/Main.cpp +60 -59
- data/ext/common/{agents/HelperAgent → agent/Core}/OptionParser.h +32 -25
- data/ext/common/{agents/HelperAgent → agent/Core}/RequestHandler.h +17 -17
- data/ext/common/{agents/HelperAgent → agent/Core}/RequestHandler/AppResponse.h +0 -0
- data/ext/common/{agents/HelperAgent → agent/Core}/RequestHandler/BufferBody.cpp +0 -0
- data/ext/common/{agents/HelperAgent → agent/Core}/RequestHandler/CheckoutSession.cpp +0 -0
- data/ext/common/{agents/HelperAgent → agent/Core}/RequestHandler/Client.h +2 -2
- data/ext/common/{agents/HelperAgent → agent/Core}/RequestHandler/ForwardResponse.cpp +0 -0
- data/ext/common/{agents/HelperAgent → agent/Core}/RequestHandler/Hooks.cpp +0 -0
- data/ext/common/{agents/HelperAgent → agent/Core}/RequestHandler/InitRequest.cpp +4 -3
- data/ext/common/{agents/HelperAgent → agent/Core}/RequestHandler/Request.h +1 -1
- data/ext/common/{agents/HelperAgent → agent/Core}/RequestHandler/SendRequest.cpp +0 -0
- data/ext/common/{agents/HelperAgent → agent/Core}/RequestHandler/TurboCaching.h +1 -1
- data/ext/common/{agents/HelperAgent → agent/Core}/RequestHandler/Utils.cpp +0 -0
- data/ext/common/{agents/HelperAgent → agent/Core}/ResponseCache.h +0 -0
- data/ext/common/{agents → agent}/Main.cpp +9 -9
- data/ext/common/{agents → agent}/SpawnPreparer/Main.cpp +0 -0
- data/ext/common/{agents/HelperAgent/SystemMetricsTool.cpp → agent/SystemMetrics/Main.cpp} +0 -0
- data/ext/common/{agents → agent}/TempDirToucher/Main.cpp +0 -0
- data/ext/common/{agents/LoggingAgent → agent/UstRouter}/ApiServer.h +7 -7
- data/ext/common/{agents/LoggingAgent → agent/UstRouter}/DataStoreId.h +0 -0
- data/ext/common/{agents/LoggingAgent → agent/UstRouter}/FilterSupport.cpp +0 -0
- data/ext/common/{agents/LoggingAgent → agent/UstRouter}/FilterSupport.h +0 -0
- data/ext/common/{agents/LoggingAgent → agent/UstRouter}/LoggingServer.h +4 -4
- data/ext/common/{agents/LoggingAgent → agent/UstRouter}/Main.cpp +45 -45
- data/ext/common/{agents/LoggingAgent → agent/UstRouter}/OptionParser.h +20 -20
- data/ext/common/{agents/LoggingAgent → agent/UstRouter}/RemoteSender.h +0 -0
- data/ext/common/{agents → agent}/Watchdog/AgentWatcher.cpp +0 -0
- data/ext/common/{agents → agent}/Watchdog/ApiServer.h +1 -1
- data/ext/common/{agents/Watchdog/HelperAgentWatcher.cpp → agent/Watchdog/CoreWatcher.cpp} +14 -10
- data/ext/common/{agents → agent}/Watchdog/InstanceDirToucher.cpp +0 -0
- data/ext/common/{agents → agent}/Watchdog/Main.cpp +131 -75
- data/ext/common/{agents/Watchdog/LoggingAgentWatcher.cpp → agent/Watchdog/UstRouterWatcher.cpp} +13 -9
- data/ext/nginx/CacheLocationConfig.c +11 -6
- data/ext/nginx/CacheLocationConfig.c.erb +11 -6
- data/ext/nginx/Configuration.c +22 -7
- data/ext/nginx/Configuration.h +1 -19
- data/ext/nginx/ConfigurationFields.h +19 -0
- data/ext/nginx/ConfigurationFields.h.erb +19 -0
- data/ext/nginx/ContentHandler.c +33 -33
- data/ext/nginx/CreateLocationConfig.c +3 -1
- data/ext/nginx/CreateLocationConfig.c.erb +3 -1
- data/ext/nginx/MergeLocationConfig.c +8 -4
- data/ext/nginx/MergeLocationConfig.c.erb +7 -3
- data/ext/nginx/ngx_http_passenger_module.c +33 -42
- data/helper-scripts/backtrace-sanitizer.rb +2 -2
- data/lib/phusion_passenger.rb +1 -1
- data/lib/phusion_passenger/admin_tools/instance.rb +2 -2
- data/lib/phusion_passenger/admin_tools/instance_registry.rb +7 -3
- data/lib/phusion_passenger/common_library.rb +8 -8
- data/lib/phusion_passenger/config/about_command.rb +1 -1
- data/lib/phusion_passenger/config/api_call_command.rb +3 -3
- data/lib/phusion_passenger/config/installation_utils.rb +34 -21
- data/lib/phusion_passenger/config/reopen_logs_command.rb +2 -2
- data/lib/phusion_passenger/config/restart_app_command.rb +18 -4
- data/lib/phusion_passenger/constants.rb +7 -5
- data/lib/phusion_passenger/loader_shared_helpers.rb +2 -6
- data/lib/phusion_passenger/message_client.rb +8 -8
- data/lib/phusion_passenger/platform_info/ruby.rb +1 -2
- data/lib/phusion_passenger/preloader_shared_helpers.rb +1 -1
- data/lib/phusion_passenger/request_handler.rb +3 -2
- data/lib/phusion_passenger/request_handler/thread_handler.rb +4 -4
- data/lib/phusion_passenger/standalone/start_command.rb +13 -3
- data/lib/phusion_passenger/standalone/start_command/builtin_engine.rb +2 -1
- data/lib/phusion_passenger/union_station/core.rb +18 -18
- data/lib/phusion_passenger/union_station/transaction.rb +5 -5
- data/resources/oss-binaries.phusionpassenger.com.crt +0 -84
- data/resources/templates/standalone/config.erb +1 -0
- metadata +40 -40
- metadata.gz.asc +7 -7
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
* Phusion Passenger - https://www.phusionpassenger.com/
|
3
|
-
* Copyright (c) 2010-
|
3
|
+
* Copyright (c) 2010-2015 Phusion
|
4
4
|
*
|
5
5
|
* "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
|
6
6
|
*
|
@@ -188,7 +188,7 @@ public:
|
|
188
188
|
guard.clear();
|
189
189
|
if (connection->disconnect(errorResponse)) {
|
190
190
|
handleException(IOException(
|
191
|
-
"
|
191
|
+
"UstRouter disconnected with error: " +
|
192
192
|
errorResponse));
|
193
193
|
} else {
|
194
194
|
handleException(e);
|
@@ -230,7 +230,7 @@ public:
|
|
230
230
|
guard.clear();
|
231
231
|
if (connection->disconnect(errorResponse)) {
|
232
232
|
handleException(IOException(
|
233
|
-
"
|
233
|
+
"UstRouter disconnected with error: " +
|
234
234
|
errorResponse));
|
235
235
|
} else {
|
236
236
|
handleException(e);
|
data/ext/common/Utils.cpp
CHANGED
@@ -775,9 +775,9 @@ prestartWebApps(const ResourceLocator &locator, const string &ruby,
|
|
775
775
|
const vector<string> &prestartURLs)
|
776
776
|
{
|
777
777
|
/* Apache calls the initialization routines twice during startup, and
|
778
|
-
* as a result it starts two
|
778
|
+
* as a result it starts two watchdogs, where the first one exits
|
779
779
|
* after a short idle period. We want any prespawning requests to reach
|
780
|
-
* the second
|
780
|
+
* the second watchdog, so we sleep for a short period before
|
781
781
|
* executing the prespawning scripts.
|
782
782
|
*/
|
783
783
|
syscalls::sleep(2);
|
@@ -1193,6 +1193,7 @@ readPeerCredentials(int sock, uid_t *uid, gid_t *gid) {
|
|
1193
1193
|
struct sockaddr_in inetAddress;
|
1194
1194
|
} addr;
|
1195
1195
|
socklen_t len = sizeof(addr);
|
1196
|
+
int ret;
|
1196
1197
|
|
1197
1198
|
/*
|
1198
1199
|
* The functions for receiving the peer credentials are not guaranteed to
|
@@ -1200,7 +1201,10 @@ readPeerCredentials(int sock, uid_t *uid, gid_t *gid) {
|
|
1200
1201
|
* just returns garbage when invoked on a TCP socket. So we check here
|
1201
1202
|
* whether 'sock' is a Unix domain socket.
|
1202
1203
|
*/
|
1203
|
-
|
1204
|
+
do {
|
1205
|
+
ret = getsockname(sock, &addr.genericAddress, &len);
|
1206
|
+
} while (ret == -1 && errno == EINTR);
|
1207
|
+
if (ret == -1) {
|
1204
1208
|
int e = errno;
|
1205
1209
|
throw SystemException("Unable to autodetect socket type (getsockname() failed)", e);
|
1206
1210
|
}
|
@@ -26,8 +26,8 @@
|
|
26
26
|
#define _PASSENGER_API_SERVER_UTILS_H_
|
27
27
|
|
28
28
|
/**
|
29
|
-
* Utility code shared by
|
30
|
-
* and Watchdog/ApiServer.h. This code handles authentication and authorization
|
29
|
+
* Utility code shared by agent/Core/ApiServer.h, agent/UstRouter/ApiServer.h
|
30
|
+
* and agent/Watchdog/ApiServer.h. This code handles authentication and authorization
|
31
31
|
* of connected ApiServer clients.
|
32
32
|
*
|
33
33
|
* This file consists of the following items.
|
@@ -202,7 +202,7 @@ struct Authorization {
|
|
202
202
|
bool canAdminister;
|
203
203
|
|
204
204
|
Authorization()
|
205
|
-
: uid(-1),
|
205
|
+
: uid((uid_t) -1),
|
206
206
|
canReadPool(false),
|
207
207
|
canModifyPool(false),
|
208
208
|
canInspectState(false),
|
@@ -57,7 +57,7 @@
|
|
57
57
|
#include <string>
|
58
58
|
#include <vector>
|
59
59
|
|
60
|
-
#include <
|
60
|
+
#include <agent/Base.h>
|
61
61
|
#include <Constants.h>
|
62
62
|
#include <Exceptions.h>
|
63
63
|
#include <Logging.h>
|
@@ -1399,7 +1399,7 @@ lookupErrno(const char *name) {
|
|
1399
1399
|
static void
|
1400
1400
|
initializeSyscallFailureSimulation(const char *processName) {
|
1401
1401
|
// Format:
|
1402
|
-
//
|
1402
|
+
// PassengerAgent watchdog=EMFILE:0.1,ECONNREFUSED:0.25;PassengerAgent core=ESPIPE=0.4
|
1403
1403
|
const char *spec = getenv("PASSENGER_SIMULATE_SYSCALL_FAILURES");
|
1404
1404
|
string prefix = string(processName) + "=";
|
1405
1405
|
vector<string> components;
|
File without changes
|
@@ -22,8 +22,8 @@
|
|
22
22
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
23
23
|
* THE SOFTWARE.
|
24
24
|
*/
|
25
|
-
#ifndef
|
26
|
-
#define
|
25
|
+
#ifndef _PASSENGER_CORE_API_SERVER_H_
|
26
|
+
#define _PASSENGER_CORE_API_SERVER_H_
|
27
27
|
|
28
28
|
#include <boost/regex.hpp>
|
29
29
|
#include <oxt/thread.hpp>
|
@@ -32,8 +32,8 @@
|
|
32
32
|
#include <cstring>
|
33
33
|
#include <sys/types.h>
|
34
34
|
|
35
|
-
#include <
|
36
|
-
#include <
|
35
|
+
#include <agent/Core/RequestHandler.h>
|
36
|
+
#include <agent/ApiServerUtils.h>
|
37
37
|
#include <ApplicationPool2/Pool.h>
|
38
38
|
#include <ServerKit/HttpServer.h>
|
39
39
|
#include <DataStructures/LString.h>
|
@@ -48,7 +48,7 @@
|
|
48
48
|
#include <Utils/MessageIO.h>
|
49
49
|
|
50
50
|
namespace Passenger {
|
51
|
-
namespace
|
51
|
+
namespace Core {
|
52
52
|
|
53
53
|
using namespace std;
|
54
54
|
|
@@ -212,7 +212,19 @@ private:
|
|
212
212
|
endRequest(&client, &req);
|
213
213
|
}
|
214
214
|
} else {
|
215
|
-
|
215
|
+
HeaderTable headers;
|
216
|
+
headers.insert(req->pool, "Cache-Control", "no-cache, no-store, must-revalidate");
|
217
|
+
headers.insert(req->pool, "WWW-Authenticate", "Basic realm=\"api\"");
|
218
|
+
if (clientOnUnixDomainSocket(client) && appPool->getGroupCount() == 0) {
|
219
|
+
// Allow admin tools that connected through the Unix domain socket
|
220
|
+
// to know that this authorization error is caused by the fact
|
221
|
+
// that the pool is empty.
|
222
|
+
headers.insert(req->pool, "Pool-Empty", "true");
|
223
|
+
}
|
224
|
+
writeSimpleResponse(client, 401, &headers, "Unauthorized");
|
225
|
+
if (!req->ended()) {
|
226
|
+
endRequest(&client, &req);
|
227
|
+
}
|
216
228
|
}
|
217
229
|
}
|
218
230
|
|
@@ -232,7 +244,19 @@ private:
|
|
232
244
|
endRequest(&client, &req);
|
233
245
|
}
|
234
246
|
} else {
|
235
|
-
|
247
|
+
HeaderTable headers;
|
248
|
+
headers.insert(req->pool, "Cache-Control", "no-cache, no-store, must-revalidate");
|
249
|
+
headers.insert(req->pool, "WWW-Authenticate", "Basic realm=\"api\"");
|
250
|
+
if (clientOnUnixDomainSocket(client) && appPool->getGroupCount() == 0) {
|
251
|
+
// Allow admin tools that connected through the Unix domain socket
|
252
|
+
// to know that this authorization error is caused by the fact
|
253
|
+
// that the pool is empty.
|
254
|
+
headers.insert(req->pool, "Pool-Empty", "true");
|
255
|
+
}
|
256
|
+
writeSimpleResponse(client, 401, &headers, "Unauthorized");
|
257
|
+
if (!req->ended()) {
|
258
|
+
endRequest(&client, &req);
|
259
|
+
}
|
236
260
|
}
|
237
261
|
}
|
238
262
|
|
@@ -593,7 +617,7 @@ public:
|
|
593
617
|
};
|
594
618
|
|
595
619
|
|
596
|
-
} // namespace
|
620
|
+
} // namespace Core
|
597
621
|
} // namespace Passenger
|
598
622
|
|
599
|
-
#endif /*
|
623
|
+
#endif /* _PASSENGER_CORE_API_SERVER_H_ */
|
@@ -66,11 +66,11 @@
|
|
66
66
|
|
67
67
|
#include <ev++.h>
|
68
68
|
|
69
|
-
#include <
|
70
|
-
#include <
|
71
|
-
#include <
|
72
|
-
#include <
|
73
|
-
#include <
|
69
|
+
#include <agent/Core/OptionParser.h>
|
70
|
+
#include <agent/Core/RequestHandler.h>
|
71
|
+
#include <agent/Core/ApiServer.h>
|
72
|
+
#include <agent/Base.h>
|
73
|
+
#include <agent/ApiServerUtils.h>
|
74
74
|
#include <Constants.h>
|
75
75
|
#include <ServerKit/Server.h>
|
76
76
|
#include <ServerKit/AcceptLoadBalancer.h>
|
@@ -98,7 +98,7 @@ using namespace Passenger::ApplicationPool2;
|
|
98
98
|
/***** Structures, constants, global variables and forward declarations *****/
|
99
99
|
|
100
100
|
namespace Passenger {
|
101
|
-
namespace
|
101
|
+
namespace Core {
|
102
102
|
struct ThreadWorkingObjects {
|
103
103
|
BackgroundEventLoop *bgloop;
|
104
104
|
ServerKit::Context *serverKitContext;
|
@@ -177,23 +177,23 @@ namespace ServerAgent {
|
|
177
177
|
delete apiWorkingObjects.bgloop;
|
178
178
|
}
|
179
179
|
};
|
180
|
-
} // namespace
|
180
|
+
} // namespace Core
|
181
181
|
} // namespace Passenger
|
182
182
|
|
183
|
-
using namespace Passenger::
|
183
|
+
using namespace Passenger::Core;
|
184
184
|
|
185
185
|
static VariantMap *agentsOptions;
|
186
186
|
static WorkingObjects *workingObjects;
|
187
187
|
|
188
188
|
|
189
|
-
/*****
|
189
|
+
/***** Core stuff *****/
|
190
190
|
|
191
191
|
static void waitForExitEvent();
|
192
192
|
static void cleanup();
|
193
193
|
static void deletePidFile();
|
194
194
|
static void abortLongRunningConnections(const ApplicationPool2::ProcessPtr &process);
|
195
195
|
static void requestHandlerShutdownFinished(RequestHandler *server);
|
196
|
-
static void apiServerShutdownFinished(
|
196
|
+
static void apiServerShutdownFinished(Core::ApiServer *server);
|
197
197
|
static void printInfoInThread();
|
198
198
|
|
199
199
|
static void
|
@@ -204,14 +204,14 @@ initializePrivilegedWorkingObjects() {
|
|
204
204
|
|
205
205
|
wo->prestarterThread = NULL;
|
206
206
|
|
207
|
-
wo->password = options.get("
|
207
|
+
wo->password = options.get("core_password", false);
|
208
208
|
if (wo->password == "-") {
|
209
209
|
wo->password.clear();
|
210
|
-
} else if (wo->password.empty() && options.has("
|
211
|
-
wo->password = strip(readAll(options.get("
|
210
|
+
} else if (wo->password.empty() && options.has("core_password_file")) {
|
211
|
+
wo->password = strip(readAll(options.get("core_password_file")));
|
212
212
|
}
|
213
213
|
|
214
|
-
vector<string> authorizations = options.getStrSet("
|
214
|
+
vector<string> authorizations = options.getStrSet("core_authorizations",
|
215
215
|
false);
|
216
216
|
string description;
|
217
217
|
|
@@ -231,7 +231,7 @@ initializeSingleAppMode() {
|
|
231
231
|
VariantMap &options = *agentsOptions;
|
232
232
|
|
233
233
|
if (options.getBool("multi_app")) {
|
234
|
-
P_NOTICE(
|
234
|
+
P_NOTICE(SHORT_PROGRAM_NAME " core running in multi-application mode.");
|
235
235
|
return;
|
236
236
|
}
|
237
237
|
|
@@ -244,7 +244,7 @@ initializeSingleAppMode() {
|
|
244
244
|
"lives in %s. Please specify information about the app using "
|
245
245
|
"--app-type and --startup-file, or specify a correct location to "
|
246
246
|
"the application you want to serve.\n"
|
247
|
-
"Type '"
|
247
|
+
"Type '" SHORT_PROGRAM_NAME " core --help' for more information.\n",
|
248
248
|
options.get("app_root").c_str());
|
249
249
|
exit(1);
|
250
250
|
}
|
@@ -253,7 +253,7 @@ initializeSingleAppMode() {
|
|
253
253
|
options.set("startup_file", getAppTypeStartupFile(appType));
|
254
254
|
}
|
255
255
|
|
256
|
-
P_NOTICE(
|
256
|
+
P_NOTICE(SHORT_PROGRAM_NAME " core running in single-application mode.");
|
257
257
|
P_NOTICE("Serving app : " << options.get("app_root"));
|
258
258
|
P_NOTICE("App type : " << options.get("app_type"));
|
259
259
|
P_NOTICE("App startup file: " << options.get("startup_file"));
|
@@ -313,8 +313,8 @@ static void
|
|
313
313
|
startListening() {
|
314
314
|
TRACE_POINT();
|
315
315
|
WorkingObjects *wo = workingObjects;
|
316
|
-
vector<string> addresses = agentsOptions->getStrSet("
|
317
|
-
vector<string> apiAddresses = agentsOptions->getStrSet("
|
316
|
+
vector<string> addresses = agentsOptions->getStrSet("core_addresses");
|
317
|
+
vector<string> apiAddresses = agentsOptions->getStrSet("core_api_addresses", false);
|
318
318
|
|
319
319
|
#ifdef USE_SELINUX
|
320
320
|
// Set SELinux context on the first socket that we create
|
@@ -348,7 +348,7 @@ startListening() {
|
|
348
348
|
static void
|
349
349
|
createPidFile() {
|
350
350
|
TRACE_POINT();
|
351
|
-
string pidFile = agentsOptions->get("
|
351
|
+
string pidFile = agentsOptions->get("core_pid_file", false);
|
352
352
|
if (!pidFile.empty()) {
|
353
353
|
char pidStr[32];
|
354
354
|
|
@@ -532,8 +532,8 @@ initializeNonPrivilegedWorkingObjects() {
|
|
532
532
|
setenv("SERVER_SOFTWARE", options.get("server_software").c_str(), 1);
|
533
533
|
options.set("data_buffer_dir", absolutizePath(options.get("data_buffer_dir")));
|
534
534
|
|
535
|
-
vector<string> addresses = options.getStrSet("
|
536
|
-
vector<string> apiAddresses = options.getStrSet("
|
535
|
+
vector<string> addresses = options.getStrSet("core_addresses");
|
536
|
+
vector<string> apiAddresses = options.getStrSet("core_api_addresses", false);
|
537
537
|
|
538
538
|
wo->resourceLocator = ResourceLocator(options.get("passenger_root"));
|
539
539
|
|
@@ -546,11 +546,11 @@ initializeNonPrivilegedWorkingObjects() {
|
|
546
546
|
}
|
547
547
|
|
548
548
|
UPDATE_TRACE_POINT();
|
549
|
-
if (options.has("
|
549
|
+
if (options.has("ust_router_address")) {
|
550
550
|
wo->unionStationCore = boost::make_shared<UnionStation::Core>(
|
551
|
-
options.get("
|
551
|
+
options.get("ust_router_address"),
|
552
552
|
"logging",
|
553
|
-
options.get("
|
553
|
+
options.get("ust_router_password"));
|
554
554
|
}
|
555
555
|
|
556
556
|
UPDATE_TRACE_POINT();
|
@@ -577,7 +577,7 @@ initializeNonPrivilegedWorkingObjects() {
|
|
577
577
|
wo->appPool->abortLongRunningConnectionsCallback = abortLongRunningConnections;
|
578
578
|
|
579
579
|
UPDATE_TRACE_POINT();
|
580
|
-
unsigned int nthreads = options.getInt("
|
580
|
+
unsigned int nthreads = options.getInt("core_threads");
|
581
581
|
BackgroundEventLoop *firstLoop = NULL; // Avoid compiler warning
|
582
582
|
wo->threadWorkingObjects.reserve(nthreads);
|
583
583
|
for (unsigned int i = 0; i < nthreads; i++) {
|
@@ -636,7 +636,7 @@ initializeNonPrivilegedWorkingObjects() {
|
|
636
636
|
options.getUint("file_buffer_threshold");
|
637
637
|
|
638
638
|
UPDATE_TRACE_POINT();
|
639
|
-
awo->apiServer = new
|
639
|
+
awo->apiServer = new Core::ApiServer(awo->serverKitContext);
|
640
640
|
awo->apiServer->requestHandlers.reserve(wo->threadWorkingObjects.size());
|
641
641
|
for (unsigned int i = 0; i < wo->threadWorkingObjects.size(); i++) {
|
642
642
|
awo->apiServer->requestHandlers.push_back(
|
@@ -704,16 +704,16 @@ static void
|
|
704
704
|
reportInitializationInfo() {
|
705
705
|
TRACE_POINT();
|
706
706
|
if (feedbackFdAvailable()) {
|
707
|
-
P_NOTICE(
|
707
|
+
P_NOTICE(SHORT_PROGRAM_NAME " core online, PID " << getpid());
|
708
708
|
writeArrayMessage(FEEDBACK_FD,
|
709
709
|
"initialized",
|
710
710
|
NULL);
|
711
711
|
} else {
|
712
|
-
vector<string> addresses = agentsOptions->getStrSet("
|
713
|
-
vector<string> apiAddresses = agentsOptions->getStrSet("
|
712
|
+
vector<string> addresses = agentsOptions->getStrSet("core_addresses");
|
713
|
+
vector<string> apiAddresses = agentsOptions->getStrSet("core_api_addresses", false);
|
714
714
|
string address;
|
715
715
|
|
716
|
-
P_NOTICE(
|
716
|
+
P_NOTICE(SHORT_PROGRAM_NAME " core online, PID " << getpid() <<
|
717
717
|
", listening on " << addresses.size() << " socket(s):");
|
718
718
|
foreach (address, addresses) {
|
719
719
|
if (startsWith(address, "tcp://")) {
|
@@ -744,7 +744,7 @@ mainLoop() {
|
|
744
744
|
WorkingObjects *wo = workingObjects;
|
745
745
|
#ifdef SUPPORTS_PER_THREAD_CPU_AFFINITY
|
746
746
|
unsigned int maxCpus = boost::thread::hardware_concurrency();
|
747
|
-
bool cpuAffine = agentsOptions->getBool("
|
747
|
+
bool cpuAffine = agentsOptions->getBool("core_cpu_affine")
|
748
748
|
&& maxCpus <= CPU_SETSIZE;
|
749
749
|
#endif
|
750
750
|
|
@@ -759,12 +759,12 @@ mainLoop() {
|
|
759
759
|
|
760
760
|
CPU_ZERO(&cpus);
|
761
761
|
CPU_SET(i % maxCpus, &cpus);
|
762
|
-
P_DEBUG("Setting CPU affinity of
|
762
|
+
P_DEBUG("Setting CPU affinity of core thread " << (i + 1)
|
763
763
|
<< " to CPU " << (i % maxCpus + 1));
|
764
764
|
result = pthread_setaffinity_np(two->bgloop->getNativeHandle(),
|
765
765
|
maxCpus, &cpus);
|
766
766
|
if (result != 0) {
|
767
|
-
P_WARN("Cannot set CPU affinity on
|
767
|
+
P_WARN("Cannot set CPU affinity on core thread " << (i + 1)
|
768
768
|
<< ": " << strerror(result) << " (errno=" << result << ")");
|
769
769
|
}
|
770
770
|
}
|
@@ -825,7 +825,7 @@ requestHandlerShutdownFinished(RequestHandler *server) {
|
|
825
825
|
}
|
826
826
|
|
827
827
|
static void
|
828
|
-
apiServerShutdownFinished(
|
828
|
+
apiServerShutdownFinished(Core::ApiServer *server) {
|
829
829
|
serverShutdownFinished();
|
830
830
|
}
|
831
831
|
|
@@ -907,7 +907,7 @@ cleanup() {
|
|
907
907
|
TRACE_POINT();
|
908
908
|
WorkingObjects *wo = workingObjects;
|
909
909
|
|
910
|
-
P_DEBUG("Shutting down "
|
910
|
+
P_DEBUG("Shutting down " SHORT_PROGRAM_NAME " core...");
|
911
911
|
wo->appPool->destroy();
|
912
912
|
installDiagnosticsDumper(NULL, NULL);
|
913
913
|
for (unsigned i = 0; i < wo->threadWorkingObjects.size(); i++) {
|
@@ -939,22 +939,22 @@ cleanup() {
|
|
939
939
|
deletePidFile();
|
940
940
|
delete workingObjects;
|
941
941
|
workingObjects = NULL;
|
942
|
-
P_NOTICE(
|
942
|
+
P_NOTICE(SHORT_PROGRAM_NAME " core shutdown finished");
|
943
943
|
}
|
944
944
|
|
945
945
|
static void
|
946
946
|
deletePidFile() {
|
947
947
|
TRACE_POINT();
|
948
|
-
string pidFile = agentsOptions->get("
|
948
|
+
string pidFile = agentsOptions->get("core_pid_file", false);
|
949
949
|
if (!pidFile.empty()) {
|
950
950
|
syscalls::unlink(pidFile.c_str());
|
951
951
|
}
|
952
952
|
}
|
953
953
|
|
954
954
|
static int
|
955
|
-
|
955
|
+
runCore() {
|
956
956
|
TRACE_POINT();
|
957
|
-
P_NOTICE("Starting "
|
957
|
+
P_NOTICE("Starting " SHORT_PROGRAM_NAME " core...");
|
958
958
|
|
959
959
|
try {
|
960
960
|
UPDATE_TRACE_POINT();
|
@@ -992,18 +992,18 @@ runServer() {
|
|
992
992
|
|
993
993
|
static void
|
994
994
|
parseOptions(int argc, const char *argv[], VariantMap &options) {
|
995
|
-
OptionParser p(
|
995
|
+
OptionParser p(coreUsage);
|
996
996
|
int i = 2;
|
997
997
|
|
998
998
|
while (i < argc) {
|
999
|
-
if (
|
999
|
+
if (parseCoreOption(argc, argv, i, options)) {
|
1000
1000
|
continue;
|
1001
1001
|
} else if (p.isFlag(argv[i], 'h', "--help")) {
|
1002
|
-
|
1002
|
+
coreUsage();
|
1003
1003
|
exit(0);
|
1004
1004
|
} else {
|
1005
1005
|
fprintf(stderr, "ERROR: unrecognized argument %s. Please type "
|
1006
|
-
"'%s
|
1006
|
+
"'%s core --help' for usage.\n", argv[i], argv[0]);
|
1007
1007
|
exit(1);
|
1008
1008
|
}
|
1009
1009
|
}
|
@@ -1013,14 +1013,14 @@ static void
|
|
1013
1013
|
preinitialize(VariantMap &options) {
|
1014
1014
|
// Set log_level here so that initializeAgent() calls setLogLevel()
|
1015
1015
|
// and setLogFile() with the right value.
|
1016
|
-
if (options.has("
|
1017
|
-
options.setInt("log_level", options.getInt("
|
1016
|
+
if (options.has("core_log_level")) {
|
1017
|
+
options.setInt("log_level", options.getInt("core_log_level"));
|
1018
1018
|
}
|
1019
|
-
if (options.has("
|
1020
|
-
options.set("log_file", options.get("
|
1019
|
+
if (options.has("core_log_file")) {
|
1020
|
+
options.set("log_file", options.get("core_log_file"));
|
1021
1021
|
}
|
1022
|
-
if (options.has("
|
1023
|
-
options.set("file_descriptor_log_file", options.get("
|
1022
|
+
if (options.has("core_file_descriptor_log_file")) {
|
1023
|
+
options.set("file_descriptor_log_file", options.get("core_file_descriptor_log_file"));
|
1024
1024
|
}
|
1025
1025
|
}
|
1026
1026
|
|
@@ -1047,7 +1047,7 @@ setAgentsOptionsDefaults() {
|
|
1047
1047
|
options.set("default_group",
|
1048
1048
|
inferDefaultGroup(options.get("default_user")));
|
1049
1049
|
}
|
1050
|
-
options.setDefaultStrSet("
|
1050
|
+
options.setDefaultStrSet("core_addresses", defaultAddress);
|
1051
1051
|
options.setDefaultBool("multi_app", false);
|
1052
1052
|
options.setDefault("environment", DEFAULT_APP_ENV);
|
1053
1053
|
options.setDefault("spawn_method", DEFAULT_SPAWN_METHOD);
|
@@ -1057,6 +1057,7 @@ setAgentsOptionsDefaults() {
|
|
1057
1057
|
options.setDefaultInt("max_pool_size", DEFAULT_MAX_POOL_SIZE);
|
1058
1058
|
options.setDefaultInt("pool_idle_time", DEFAULT_POOL_IDLE_TIME);
|
1059
1059
|
options.setDefaultInt("min_instances", 1);
|
1060
|
+
options.setDefaultInt("max_preloader_idle_time", DEFAULT_MAX_PRELOADER_IDLE_TIME);
|
1060
1061
|
options.setDefaultInt("stat_throttle_rate", DEFAULT_STAT_THROTTLE_RATE);
|
1061
1062
|
options.setDefault("server_software", SERVER_TOKEN_NAME "/" PASSENGER_VERSION);
|
1062
1063
|
options.setDefaultBool("show_version_in_header", true);
|
@@ -1067,14 +1068,14 @@ setAgentsOptionsDefaults() {
|
|
1067
1068
|
options.setDefaultUint("file_buffer_threshold", DEFAULT_FILE_BUFFERED_CHANNEL_THRESHOLD);
|
1068
1069
|
options.setDefaultInt("response_buffer_high_watermark", DEFAULT_RESPONSE_BUFFER_HIGH_WATERMARK);
|
1069
1070
|
options.setDefaultBool("selfchecks", false);
|
1070
|
-
options.setDefaultBool("
|
1071
|
-
options.setDefaultInt("
|
1072
|
-
options.setDefaultBool("
|
1071
|
+
options.setDefaultBool("core_graceful_exit", true);
|
1072
|
+
options.setDefaultInt("core_threads", boost::thread::hardware_concurrency());
|
1073
|
+
options.setDefaultBool("core_cpu_affine", false);
|
1073
1074
|
options.setDefault("friendly_error_pages", "auto");
|
1074
1075
|
options.setDefaultBool("rolling_restarts", false);
|
1075
1076
|
options.setDefaultBool("resist_deployment_errors", false);
|
1076
1077
|
|
1077
|
-
string firstAddress = options.getStrSet("
|
1078
|
+
string firstAddress = options.getStrSet("core_addresses")[0];
|
1078
1079
|
if (getSocketAddressType(firstAddress) == SAT_TCP) {
|
1079
1080
|
string host;
|
1080
1081
|
unsigned short port;
|
@@ -1173,7 +1174,7 @@ sanityCheckOptions() {
|
|
1173
1174
|
options.get("benchmark_mode", false).c_str());
|
1174
1175
|
ok = false;
|
1175
1176
|
}
|
1176
|
-
if (options.getInt("
|
1177
|
+
if (options.getInt("core_threads") < 1) {
|
1177
1178
|
fprintf(stderr, "ERROR: you may only specify for --threads a number greater than or equal to 1.\n");
|
1178
1179
|
ok = false;
|
1179
1180
|
}
|
@@ -1188,15 +1189,15 @@ sanityCheckOptions() {
|
|
1188
1189
|
}
|
1189
1190
|
|
1190
1191
|
int
|
1191
|
-
|
1192
|
+
coreMain(int argc, char *argv[]) {
|
1192
1193
|
int ret;
|
1193
1194
|
|
1194
1195
|
agentsOptions = new VariantMap();
|
1195
|
-
*agentsOptions = initializeAgent(argc, &argv,
|
1196
|
+
*agentsOptions = initializeAgent(argc, &argv, SHORT_PROGRAM_NAME " core", parseOptions,
|
1196
1197
|
preinitialize, 2);
|
1197
1198
|
setAgentsOptionsDefaults();
|
1198
1199
|
sanityCheckOptions();
|
1199
|
-
ret =
|
1200
|
+
ret = runCore();
|
1200
1201
|
shutdownAgent(agentsOptions);
|
1201
1202
|
return ret;
|
1202
1203
|
}
|