passenger 5.0.9 → 5.0.10
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 +15 -0
- data/CONTRIBUTORS +6 -0
- data/README.md +1 -1
- data/bin/passenger-install-apache2-module +24 -11
- data/bin/passenger-status +29 -14
- data/build/agents.rb +12 -10
- data/build/cxx_tests.rb +30 -30
- data/doc/Design and Architecture.html +1 -10
- data/doc/Design and Architecture.txt +1 -6
- data/doc/Users guide Apache.html +1 -19
- data/doc/Users guide Apache.txt +1 -1
- data/doc/Users guide Nginx.html +2 -20
- data/doc/Users guide Nginx.txt +2 -2
- data/doc/users_guide_snippets/tips.txt +0 -9
- data/ext/common/ApplicationPool2/ApiKey.h +158 -0
- data/ext/common/ApplicationPool2/BasicGroupInfo.h +81 -0
- data/ext/common/ApplicationPool2/BasicProcessInfo.h +106 -0
- data/ext/common/ApplicationPool2/Common.h +5 -44
- data/ext/common/ApplicationPool2/Context.h +94 -0
- data/ext/common/ApplicationPool2/Group.h +130 -1205
- data/ext/common/ApplicationPool2/Group/InitializationAndShutdown.cpp +190 -0
- data/ext/common/ApplicationPool2/Group/InternalUtils.cpp +329 -0
- data/ext/common/ApplicationPool2/Group/LifetimeAndBasics.cpp +103 -0
- data/ext/common/ApplicationPool2/{Pool/Debug.h → Group/Miscellaneous.cpp} +40 -38
- data/ext/common/ApplicationPool2/Group/OutOfBandWork.cpp +323 -0
- data/ext/common/ApplicationPool2/Group/ProcessListManagement.cpp +606 -0
- data/ext/common/ApplicationPool2/Group/SessionManagement.cpp +337 -0
- data/ext/common/ApplicationPool2/Group/SpawningAndRestarting.cpp +478 -0
- data/ext/common/ApplicationPool2/Group/StateInspection.cpp +197 -0
- data/ext/common/ApplicationPool2/Group/Verification.cpp +159 -0
- data/ext/common/ApplicationPool2/Implementation.cpp +19 -1401
- data/ext/common/ApplicationPool2/Options.h +5 -5
- data/ext/common/ApplicationPool2/Pool.h +260 -815
- data/ext/common/ApplicationPool2/Pool/{AnalyticsCollection.h → AnalyticsCollection.cpp} +55 -56
- data/ext/common/ApplicationPool2/Pool/{GarbageCollection.h → GarbageCollection.cpp} +49 -49
- data/ext/common/ApplicationPool2/Pool/GeneralUtils.cpp +241 -0
- data/ext/common/ApplicationPool2/Pool/GroupUtils.cpp +276 -0
- data/ext/common/ApplicationPool2/Pool/InitializationAndShutdown.cpp +145 -0
- data/ext/common/ApplicationPool2/Pool/Miscellaneous.cpp +244 -0
- data/ext/common/ApplicationPool2/Pool/ProcessUtils.cpp +330 -0
- data/ext/common/ApplicationPool2/Pool/StateInspection.cpp +299 -0
- data/ext/common/ApplicationPool2/Process.h +399 -205
- data/ext/common/ApplicationPool2/Session.h +70 -28
- data/ext/common/ApplicationPool2/Socket.h +1 -0
- data/ext/common/Constants.h +11 -3
- data/ext/common/Exceptions.h +1 -1
- data/ext/common/Logging.cpp +9 -4
- data/ext/common/Logging.h +6 -0
- data/ext/common/ServerKit/HttpServer.h +225 -215
- data/ext/common/ServerKit/Server.h +57 -57
- data/ext/common/SpawningKit/BackgroundIOCapturer.h +160 -0
- data/ext/common/SpawningKit/Config.h +107 -0
- data/ext/common/{ApplicationPool2 → SpawningKit}/DirectSpawner.h +17 -16
- data/ext/common/{ApplicationPool2 → SpawningKit}/DummySpawner.h +33 -33
- data/ext/common/{ApplicationPool2/SpawnerFactory.h → SpawningKit/Factory.h} +17 -17
- data/ext/common/{ApplicationPool2/ComponentInfo.h → SpawningKit/Options.h} +8 -21
- data/ext/common/SpawningKit/PipeWatcher.h +148 -0
- data/ext/common/{ApplicationPool2/PipeWatcher.h → SpawningKit/Result.h} +15 -33
- data/ext/common/{ApplicationPool2 → SpawningKit}/SmartSpawner.h +52 -57
- data/ext/common/{ApplicationPool2 → SpawningKit}/Spawner.h +83 -371
- data/ext/common/SpawningKit/UserSwitchingRules.h +265 -0
- data/ext/common/Utils/BufferedIO.h +24 -0
- data/ext/common/{ApplicationPool2/SpawnObject.h → Utils/ClassUtils.h} +24 -51
- data/ext/common/Utils/IOUtils.cpp +70 -0
- data/ext/common/Utils/IOUtils.h +19 -0
- data/ext/common/Utils/JsonUtils.h +113 -0
- data/ext/common/Utils/StrIntUtils.h +29 -0
- data/ext/common/Utils/json.h +1 -1
- data/ext/common/agents/ApiServerUtils.h +941 -0
- data/ext/common/agents/HelperAgent/{AdminServer.h → ApiServer.h} +163 -365
- data/ext/common/agents/HelperAgent/Main.cpp +86 -88
- data/ext/common/agents/HelperAgent/OptionParser.h +9 -10
- data/ext/common/agents/HelperAgent/RequestHandler/BufferBody.cpp +3 -0
- data/ext/common/agents/HelperAgent/RequestHandler/ForwardResponse.cpp +2 -0
- data/ext/common/agents/HelperAgent/RequestHandler/Hooks.cpp +1 -1
- data/ext/common/agents/HelperAgent/RequestHandler/SendRequest.cpp +2 -2
- data/ext/common/agents/LoggingAgent/ApiServer.h +279 -0
- data/ext/common/agents/LoggingAgent/Main.cpp +41 -51
- data/ext/common/agents/LoggingAgent/OptionParser.h +11 -11
- data/ext/common/agents/Watchdog/ApiServer.h +311 -0
- data/ext/common/agents/Watchdog/Main.cpp +91 -65
- data/helper-scripts/prespawn +2 -0
- data/lib/phusion_passenger.rb +1 -1
- data/lib/phusion_passenger/admin_tools/instance.rb +1 -1
- data/lib/phusion_passenger/common_library.rb +27 -14
- data/lib/phusion_passenger/config/{admin_command_command.rb → api_call_command.rb} +19 -16
- data/lib/phusion_passenger/config/detach_process_command.rb +6 -3
- data/lib/phusion_passenger/config/main.rb +3 -5
- data/lib/phusion_passenger/config/reopen_logs_command.rb +29 -7
- data/lib/phusion_passenger/config/restart_app_command.rb +13 -4
- data/lib/phusion_passenger/config/utils.rb +15 -8
- data/lib/phusion_passenger/constants.rb +6 -2
- data/lib/phusion_passenger/platform_info/apache.rb +4 -0
- data/lib/phusion_passenger/platform_info/apache_detector.rb +18 -3
- data/resources/templates/apache2/mpm_unknown.txt.erb +20 -0
- metadata +42 -21
- metadata.gz.asc +7 -7
- data/ext/common/ApplicationPool2/Pool/GeneralUtils.h +0 -127
- data/ext/common/ApplicationPool2/Pool/Inspection.h +0 -219
- data/ext/common/ApplicationPool2/Pool/ProcessUtils.h +0 -85
- data/ext/common/ApplicationPool2/SuperGroup.h +0 -706
- data/ext/common/agents/LoggingAgent/AdminServer.h +0 -435
- data/ext/common/agents/Watchdog/AdminServer.h +0 -432
@@ -55,6 +55,7 @@
|
|
55
55
|
#include <algorithm>
|
56
56
|
#include <iostream>
|
57
57
|
#include <sstream>
|
58
|
+
#include <stdexcept>
|
58
59
|
|
59
60
|
#include <boost/thread.hpp>
|
60
61
|
#include <boost/shared_ptr.hpp>
|
@@ -67,8 +68,9 @@
|
|
67
68
|
|
68
69
|
#include <agents/HelperAgent/OptionParser.h>
|
69
70
|
#include <agents/HelperAgent/RequestHandler.h>
|
70
|
-
#include <agents/HelperAgent/
|
71
|
+
#include <agents/HelperAgent/ApiServer.h>
|
71
72
|
#include <agents/Base.h>
|
73
|
+
#include <agents/ApiServerUtils.h>
|
72
74
|
#include <Constants.h>
|
73
75
|
#include <ServerKit/Server.h>
|
74
76
|
#include <ServerKit/AcceptLoadBalancer.h>
|
@@ -109,29 +111,29 @@ namespace ServerAgent {
|
|
109
111
|
{ }
|
110
112
|
};
|
111
113
|
|
112
|
-
struct
|
114
|
+
struct ApiWorkingObjects {
|
113
115
|
BackgroundEventLoop *bgloop;
|
114
116
|
ServerKit::Context *serverKitContext;
|
115
|
-
|
117
|
+
ApiServer *apiServer;
|
116
118
|
|
117
|
-
|
119
|
+
ApiWorkingObjects()
|
118
120
|
: bgloop(NULL),
|
119
121
|
serverKitContext(NULL),
|
120
|
-
|
122
|
+
apiServer(NULL)
|
121
123
|
{ }
|
122
124
|
};
|
123
125
|
|
124
126
|
struct WorkingObjects {
|
125
127
|
int serverFds[SERVER_KIT_MAX_SERVER_ENDPOINTS];
|
126
|
-
int
|
128
|
+
int apiServerFds[SERVER_KIT_MAX_SERVER_ENDPOINTS];
|
127
129
|
string password;
|
128
|
-
|
130
|
+
ApiAccountDatabase apiAccountDatabase;
|
129
131
|
|
130
132
|
ResourceLocator resourceLocator;
|
131
133
|
RandomGeneratorPtr randomGenerator;
|
132
134
|
UnionStation::CorePtr unionStationCore;
|
133
|
-
|
134
|
-
|
135
|
+
SpawningKit::ConfigPtr spawningKitConfig;
|
136
|
+
SpawningKit::FactoryPtr spawningKitFactory;
|
135
137
|
PoolPtr appPool;
|
136
138
|
|
137
139
|
ServerKit::AcceptLoadBalancer<RequestHandler> loadBalancer;
|
@@ -140,7 +142,7 @@ namespace ServerAgent {
|
|
140
142
|
struct ev_signal sigtermWatcher;
|
141
143
|
struct ev_signal sigquitWatcher;
|
142
144
|
|
143
|
-
|
145
|
+
ApiWorkingObjects apiWorkingObjects;
|
144
146
|
|
145
147
|
EventFd exitEvent;
|
146
148
|
EventFd allClientsDisconnectedEvent;
|
@@ -156,7 +158,7 @@ namespace ServerAgent {
|
|
156
158
|
{
|
157
159
|
for (unsigned int i = 0; i < SERVER_KIT_MAX_SERVER_ENDPOINTS; i++) {
|
158
160
|
serverFds[i] = -1;
|
159
|
-
|
161
|
+
apiServerFds[i] = -1;
|
160
162
|
}
|
161
163
|
}
|
162
164
|
|
@@ -170,9 +172,9 @@ namespace ServerAgent {
|
|
170
172
|
delete it->bgloop;
|
171
173
|
}
|
172
174
|
|
173
|
-
delete
|
174
|
-
delete
|
175
|
-
delete
|
175
|
+
delete apiWorkingObjects.apiServer;
|
176
|
+
delete apiWorkingObjects.serverKitContext;
|
177
|
+
delete apiWorkingObjects.bgloop;
|
176
178
|
}
|
177
179
|
};
|
178
180
|
} // namespace ServerAgent
|
@@ -191,33 +193,9 @@ static void cleanup();
|
|
191
193
|
static void deletePidFile();
|
192
194
|
static void abortLongRunningConnections(const ApplicationPool2::ProcessPtr &process);
|
193
195
|
static void requestHandlerShutdownFinished(RequestHandler *server);
|
194
|
-
static void
|
196
|
+
static void apiServerShutdownFinished(ServerAgent::ApiServer *server);
|
195
197
|
static void printInfoInThread();
|
196
198
|
|
197
|
-
static void
|
198
|
-
parseAndAddAdminAuthorization(const string &description) {
|
199
|
-
TRACE_POINT();
|
200
|
-
WorkingObjects *wo = workingObjects;
|
201
|
-
ServerAgent::AdminServer::Authorization auth;
|
202
|
-
vector<string> args;
|
203
|
-
|
204
|
-
split(description, ':', args);
|
205
|
-
|
206
|
-
if (args.size() == 2) {
|
207
|
-
auth.level = ServerAgent::AdminServer::FULL;
|
208
|
-
auth.username = args[0];
|
209
|
-
auth.password = strip(readAll(args[1]));
|
210
|
-
} else if (args.size() == 3) {
|
211
|
-
auth.level = ServerAgent::AdminServer::parseLevel(args[0]);
|
212
|
-
auth.username = args[1];
|
213
|
-
auth.password = strip(readAll(args[2]));
|
214
|
-
} else {
|
215
|
-
P_BUG("Too many elements in authorization description");
|
216
|
-
}
|
217
|
-
|
218
|
-
wo->adminAuthorizations.push_back(auth);
|
219
|
-
}
|
220
|
-
|
221
199
|
static void
|
222
200
|
initializePrivilegedWorkingObjects() {
|
223
201
|
TRACE_POINT();
|
@@ -239,7 +217,11 @@ initializePrivilegedWorkingObjects() {
|
|
239
217
|
|
240
218
|
UPDATE_TRACE_POINT();
|
241
219
|
foreach (description, authorizations) {
|
242
|
-
|
220
|
+
try {
|
221
|
+
wo->apiAccountDatabase.add(description);
|
222
|
+
} catch (const ArgumentException &e) {
|
223
|
+
throw std::runtime_error(e.what());
|
224
|
+
}
|
243
225
|
}
|
244
226
|
}
|
245
227
|
|
@@ -332,7 +314,7 @@ startListening() {
|
|
332
314
|
TRACE_POINT();
|
333
315
|
WorkingObjects *wo = workingObjects;
|
334
316
|
vector<string> addresses = agentsOptions->getStrSet("server_addresses");
|
335
|
-
vector<string>
|
317
|
+
vector<string> apiAddresses = agentsOptions->getStrSet("server_api_addresses", false);
|
336
318
|
|
337
319
|
#ifdef USE_SELINUX
|
338
320
|
// Set SELinux context on the first socket that we create
|
@@ -352,13 +334,13 @@ startListening() {
|
|
352
334
|
makeFileWorldReadableAndWritable(parseUnixSocketAddress(addresses[i]));
|
353
335
|
}
|
354
336
|
}
|
355
|
-
for (unsigned int i = 0; i <
|
356
|
-
wo->
|
337
|
+
for (unsigned int i = 0; i < apiAddresses.size(); i++) {
|
338
|
+
wo->apiServerFds[i] = createServer(apiAddresses[i], 0, true,
|
357
339
|
__FILE__, __LINE__);
|
358
|
-
P_LOG_FILE_DESCRIPTOR_PURPOSE(wo->
|
359
|
-
"
|
360
|
-
if (getSocketAddressType(
|
361
|
-
makeFileWorldReadableAndWritable(parseUnixSocketAddress(
|
340
|
+
P_LOG_FILE_DESCRIPTOR_PURPOSE(wo->apiServerFds[i],
|
341
|
+
"ApiServer address: " << apiAddresses[i]);
|
342
|
+
if (getSocketAddressType(apiAddresses[i]) == SAT_UNIX) {
|
343
|
+
makeFileWorldReadableAndWritable(parseUnixSocketAddress(apiAddresses[i]));
|
362
344
|
}
|
363
345
|
}
|
364
346
|
}
|
@@ -488,7 +470,7 @@ dumpDiagnosticsOnCrash(void *userData) {
|
|
488
470
|
|
489
471
|
cerr << "### Pool state (simple)\n";
|
490
472
|
// Do not lock, the crash may occur within the pool.
|
491
|
-
Pool::InspectOptions options;
|
473
|
+
Pool::InspectOptions options(Pool::InspectOptions::makeAuthorized());
|
492
474
|
options.verbose = true;
|
493
475
|
cerr << wo->appPool->inspect(options, false);
|
494
476
|
cerr << "\n";
|
@@ -505,7 +487,9 @@ dumpDiagnosticsOnCrash(void *userData) {
|
|
505
487
|
cerr.flush();
|
506
488
|
|
507
489
|
cerr << "### Pool state (XML)\n";
|
508
|
-
|
490
|
+
Pool::ToXmlOptions options2(Pool::ToXmlOptions::makeAuthorized());
|
491
|
+
options2.secrets = true;
|
492
|
+
cerr << wo->appPool->toXml(options2, false);
|
509
493
|
cerr << "\n\n";
|
510
494
|
cerr.flush();
|
511
495
|
}
|
@@ -528,6 +512,11 @@ onTerminationSignal(EV_P_ struct ev_signal *watcher, int revents) {
|
|
528
512
|
}
|
529
513
|
}
|
530
514
|
|
515
|
+
static void
|
516
|
+
spawningKitErrorHandler(const SpawningKit::ConfigPtr &config, SpawnException &e, const Options &options) {
|
517
|
+
ApplicationPool2::processAndLogNewSpawnException(e, options, config);
|
518
|
+
}
|
519
|
+
|
531
520
|
static void
|
532
521
|
initializeNonPrivilegedWorkingObjects() {
|
533
522
|
TRACE_POINT();
|
@@ -544,7 +533,7 @@ initializeNonPrivilegedWorkingObjects() {
|
|
544
533
|
options.set("data_buffer_dir", absolutizePath(options.get("data_buffer_dir")));
|
545
534
|
|
546
535
|
vector<string> addresses = options.getStrSet("server_addresses");
|
547
|
-
vector<string>
|
536
|
+
vector<string> apiAddresses = options.getStrSet("server_api_addresses", false);
|
548
537
|
|
549
538
|
wo->resourceLocator = ResourceLocator(options.get("passenger_root"));
|
550
539
|
|
@@ -565,19 +554,22 @@ initializeNonPrivilegedWorkingObjects() {
|
|
565
554
|
}
|
566
555
|
|
567
556
|
UPDATE_TRACE_POINT();
|
568
|
-
wo->
|
569
|
-
wo->
|
570
|
-
wo->
|
571
|
-
wo->
|
572
|
-
wo->
|
573
|
-
|
574
|
-
|
557
|
+
wo->spawningKitConfig = boost::make_shared<SpawningKit::Config>();
|
558
|
+
wo->spawningKitConfig->resourceLocator = &wo->resourceLocator;
|
559
|
+
wo->spawningKitConfig->agentsOptions = agentsOptions;
|
560
|
+
wo->spawningKitConfig->errorHandler = spawningKitErrorHandler;
|
561
|
+
wo->spawningKitConfig->unionStationCore = wo->unionStationCore;
|
562
|
+
wo->spawningKitConfig->randomGenerator = wo->randomGenerator;
|
563
|
+
wo->spawningKitConfig->instanceDir = options.get("instance_dir", false);
|
564
|
+
if (!wo->spawningKitConfig->instanceDir.empty()) {
|
565
|
+
wo->spawningKitConfig->instanceDir = absolutizePath(
|
566
|
+
wo->spawningKitConfig->instanceDir);
|
575
567
|
}
|
576
|
-
wo->
|
568
|
+
wo->spawningKitConfig->finalize();
|
577
569
|
|
578
570
|
UPDATE_TRACE_POINT();
|
579
|
-
wo->
|
580
|
-
wo->appPool = boost::make_shared<Pool>(wo->
|
571
|
+
wo->spawningKitFactory = boost::make_shared<SpawningKit::Factory>(wo->spawningKitConfig);
|
572
|
+
wo->appPool = boost::make_shared<Pool>(wo->spawningKitFactory, agentsOptions);
|
581
573
|
wo->appPool->initialize();
|
582
574
|
wo->appPool->setMax(options.getInt("max_pool_size"));
|
583
575
|
wo->appPool->setMaxIdleTime(options.getInt("pool_idle_time") * 1000000ULL);
|
@@ -630,9 +622,9 @@ initializeNonPrivilegedWorkingObjects() {
|
|
630
622
|
ev_signal_start(firstLoop->libev_loop, &wo->sigtermWatcher);
|
631
623
|
|
632
624
|
UPDATE_TRACE_POINT();
|
633
|
-
if (!
|
625
|
+
if (!apiAddresses.empty()) {
|
634
626
|
UPDATE_TRACE_POINT();
|
635
|
-
|
627
|
+
ApiWorkingObjects *awo = &wo->apiWorkingObjects;
|
636
628
|
|
637
629
|
awo->bgloop = new BackgroundEventLoop(true, true);
|
638
630
|
awo->serverKitContext = new ServerKit::Context(awo->bgloop->safe,
|
@@ -644,16 +636,18 @@ initializeNonPrivilegedWorkingObjects() {
|
|
644
636
|
options.getUint("file_buffer_threshold");
|
645
637
|
|
646
638
|
UPDATE_TRACE_POINT();
|
647
|
-
awo->
|
648
|
-
awo->
|
639
|
+
awo->apiServer = new ServerAgent::ApiServer(awo->serverKitContext);
|
640
|
+
awo->apiServer->requestHandlers.reserve(wo->threadWorkingObjects.size());
|
649
641
|
for (unsigned int i = 0; i < wo->threadWorkingObjects.size(); i++) {
|
650
|
-
awo->
|
642
|
+
awo->apiServer->requestHandlers.push_back(
|
651
643
|
wo->threadWorkingObjects[i].requestHandler);
|
652
644
|
}
|
653
|
-
awo->
|
654
|
-
awo->
|
655
|
-
awo->
|
656
|
-
awo->
|
645
|
+
awo->apiServer->apiAccountDatabase = &wo->apiAccountDatabase;
|
646
|
+
awo->apiServer->appPool = wo->appPool;
|
647
|
+
awo->apiServer->instanceDir = options.get("instance_dir", false);
|
648
|
+
awo->apiServer->fdPassingPassword = options.get("watchdog_fd_passing_password", false);
|
649
|
+
awo->apiServer->exitEvent = &wo->exitEvent;
|
650
|
+
awo->apiServer->shutdownFinishCallback = apiServerShutdownFinished;
|
657
651
|
|
658
652
|
wo->shutdownCounter.fetch_add(1, boost::memory_order_relaxed);
|
659
653
|
}
|
@@ -685,8 +679,8 @@ initializeNonPrivilegedWorkingObjects() {
|
|
685
679
|
wo->loadBalancer.servers.push_back(two->requestHandler);
|
686
680
|
}
|
687
681
|
}
|
688
|
-
for (unsigned int i = 0; i <
|
689
|
-
wo->
|
682
|
+
for (unsigned int i = 0; i < apiAddresses.size(); i++) {
|
683
|
+
wo->apiWorkingObjects.apiServer->listen(wo->apiServerFds[i]);
|
690
684
|
}
|
691
685
|
}
|
692
686
|
|
@@ -716,7 +710,7 @@ reportInitializationInfo() {
|
|
716
710
|
NULL);
|
717
711
|
} else {
|
718
712
|
vector<string> addresses = agentsOptions->getStrSet("server_addresses");
|
719
|
-
vector<string>
|
713
|
+
vector<string> apiAddresses = agentsOptions->getStrSet("server_api_addresses", false);
|
720
714
|
string address;
|
721
715
|
|
722
716
|
P_NOTICE(AGENT_EXE " server online, PID " << getpid() <<
|
@@ -730,9 +724,9 @@ reportInitializationInfo() {
|
|
730
724
|
P_NOTICE(" * " << address);
|
731
725
|
}
|
732
726
|
|
733
|
-
if (!
|
734
|
-
P_NOTICE("
|
735
|
-
foreach (address,
|
727
|
+
if (!apiAddresses.empty()) {
|
728
|
+
P_NOTICE("API server listening on " << apiAddresses.size() << " socket(s):");
|
729
|
+
foreach (address, apiAddresses) {
|
736
730
|
if (startsWith(address, "tcp://")) {
|
737
731
|
address.erase(0, sizeof("tcp://") - 1);
|
738
732
|
address.insert(0, "http://");
|
@@ -776,8 +770,8 @@ mainLoop() {
|
|
776
770
|
}
|
777
771
|
#endif
|
778
772
|
}
|
779
|
-
if (wo->
|
780
|
-
wo->
|
773
|
+
if (wo->apiWorkingObjects.apiServer != NULL) {
|
774
|
+
wo->apiWorkingObjects.bgloop->start("API event loop", 0);
|
781
775
|
}
|
782
776
|
if (wo->threadWorkingObjects.size() > 1) {
|
783
777
|
wo->loadBalancer.start();
|
@@ -797,12 +791,12 @@ abortLongRunningConnections(const ApplicationPool2::ProcessPtr &process) {
|
|
797
791
|
// We are inside the ApplicationPool lock. Be very careful here.
|
798
792
|
WorkingObjects *wo = workingObjects;
|
799
793
|
P_NOTICE("Disconnecting long-running connections for process " <<
|
800
|
-
process->
|
794
|
+
process->getPid() << ", application " << process->getGroup()->getName());
|
801
795
|
for (unsigned int i = 0; i < wo->threadWorkingObjects.size(); i++) {
|
802
796
|
wo->threadWorkingObjects[i].bgloop->safe->runLater(
|
803
797
|
boost::bind(abortLongRunningConnectionsOnRequestHandler,
|
804
798
|
wo->threadWorkingObjects[i].requestHandler,
|
805
|
-
|
799
|
+
process->getGupid().toString()));
|
806
800
|
}
|
807
801
|
}
|
808
802
|
|
@@ -812,8 +806,8 @@ shutdownRequestHandler(ThreadWorkingObjects *two) {
|
|
812
806
|
}
|
813
807
|
|
814
808
|
static void
|
815
|
-
|
816
|
-
workingObjects->
|
809
|
+
shutdownApiServer() {
|
810
|
+
workingObjects->apiWorkingObjects.apiServer->shutdown();
|
817
811
|
}
|
818
812
|
|
819
813
|
static void
|
@@ -831,7 +825,7 @@ requestHandlerShutdownFinished(RequestHandler *server) {
|
|
831
825
|
}
|
832
826
|
|
833
827
|
static void
|
834
|
-
|
828
|
+
apiServerShutdownFinished(ServerAgent::ApiServer *server) {
|
835
829
|
serverShutdownFinished();
|
836
830
|
}
|
837
831
|
|
@@ -889,8 +883,8 @@ waitForExitEvent() {
|
|
889
883
|
if (wo->threadWorkingObjects.size() > 1) {
|
890
884
|
wo->loadBalancer.shutdown();
|
891
885
|
}
|
892
|
-
if (wo->
|
893
|
-
wo->
|
886
|
+
if (wo->apiWorkingObjects.apiServer != NULL) {
|
887
|
+
wo->apiWorkingObjects.bgloop->safe->runLater(shutdownApiServer);
|
894
888
|
}
|
895
889
|
|
896
890
|
UPDATE_TRACE_POINT();
|
@@ -920,8 +914,8 @@ cleanup() {
|
|
920
914
|
ThreadWorkingObjects *two = &wo->threadWorkingObjects[i];
|
921
915
|
two->bgloop->stop();
|
922
916
|
}
|
923
|
-
if (wo->
|
924
|
-
wo->
|
917
|
+
if (wo->apiWorkingObjects.apiServer != NULL) {
|
918
|
+
wo->apiWorkingObjects.bgloop->stop();
|
925
919
|
}
|
926
920
|
wo->appPool.reset();
|
927
921
|
for (unsigned i = 0; i < wo->threadWorkingObjects.size(); i++) {
|
@@ -938,8 +932,8 @@ cleanup() {
|
|
938
932
|
if (wo->serverFds[i] != -1) {
|
939
933
|
close(wo->serverFds[i]);
|
940
934
|
}
|
941
|
-
if (wo->
|
942
|
-
close(wo->
|
935
|
+
if (wo->apiServerFds[i] != -1) {
|
936
|
+
close(wo->apiServerFds[i]);
|
943
937
|
}
|
944
938
|
}
|
945
939
|
deletePidFile();
|
@@ -984,6 +978,10 @@ runServer() {
|
|
984
978
|
P_CRITICAL("ERROR: " << e.what() << "\n" << e.backtrace());
|
985
979
|
deletePidFile();
|
986
980
|
return 1;
|
981
|
+
} catch (const std::runtime_error &e) {
|
982
|
+
P_CRITICAL("ERROR: " << e.what());
|
983
|
+
deletePidFile();
|
984
|
+
return 1;
|
987
985
|
}
|
988
986
|
|
989
987
|
return 0;
|
@@ -61,8 +61,7 @@ serverUsage() {
|
|
61
61
|
SERVER_KIT_MAX_SERVER_ENDPOINTS);
|
62
62
|
printf(" listen on multiple addresses. Default:\n");
|
63
63
|
printf(" " DEFAULT_HTTP_SERVER_LISTEN_ADDRESS "\n");
|
64
|
-
printf(" --
|
65
|
-
printf(" Listen on the given address for admin commands.\n");
|
64
|
+
printf(" --api-listen ADDRESS Listen on the given address for API commands.\n");
|
66
65
|
printf(" The same syntax and limitations as with --listen\n");
|
67
66
|
printf(" are applicable\n");
|
68
67
|
printf("\n");
|
@@ -75,8 +74,8 @@ serverUsage() {
|
|
75
74
|
printf(" Password-protect access to the HTTP server\n");
|
76
75
|
printf(" (multi-app mode only)\n");
|
77
76
|
printf(" --authorize [LEVEL]:USERNAME:PASSWORDFILE\n");
|
78
|
-
printf(" Enables authentication on the
|
79
|
-
printf(" the given
|
77
|
+
printf(" Enables authentication on the API server, through\n");
|
78
|
+
printf(" the given API account. LEVEL indicates the\n");
|
80
79
|
printf(" privilege level (see below). PASSWORDFILE must\n");
|
81
80
|
printf(" point to a file containing the password\n");
|
82
81
|
printf(" --no-user-switching Disables user switching support\n");
|
@@ -169,7 +168,7 @@ serverUsage() {
|
|
169
168
|
printf(" --cpu-affine Enable per-thread CPU affinity (Linux only)\n");
|
170
169
|
printf(" -h, --help Show this help\n");
|
171
170
|
printf("\n");
|
172
|
-
printf("
|
171
|
+
printf("API account privilege levels (ordered from most to least privileges):\n");
|
173
172
|
printf(" readonly Read-only access\n");
|
174
173
|
printf(" full Full access (default)\n");
|
175
174
|
}
|
@@ -198,20 +197,20 @@ parseServerOption(int argc, const char *argv[], int &i, VariantMap &options) {
|
|
198
197
|
"for Unix domain sockets.\n");
|
199
198
|
exit(1);
|
200
199
|
}
|
201
|
-
} else if (p.isValueFlag(argc, i, argv[i], '\0', "--
|
200
|
+
} else if (p.isValueFlag(argc, i, argv[i], '\0', "--api-listen")) {
|
202
201
|
if (getSocketAddressType(argv[i + 1]) != SAT_UNKNOWN) {
|
203
|
-
vector<string> addresses = options.getStrSet("
|
202
|
+
vector<string> addresses = options.getStrSet("server_api_addresses",
|
204
203
|
false);
|
205
204
|
if (addresses.size() == SERVER_KIT_MAX_SERVER_ENDPOINTS) {
|
206
|
-
fprintf(stderr, "ERROR: you may specify up to %u --
|
205
|
+
fprintf(stderr, "ERROR: you may specify up to %u --api-listen addresses.\n",
|
207
206
|
SERVER_KIT_MAX_SERVER_ENDPOINTS);
|
208
207
|
exit(1);
|
209
208
|
}
|
210
209
|
addresses.push_back(argv[i + 1]);
|
211
|
-
options.setStrSet("
|
210
|
+
options.setStrSet("server_api_addresses", addresses);
|
212
211
|
i += 2;
|
213
212
|
} else {
|
214
|
-
fprintf(stderr, "ERROR: invalid address format for --
|
213
|
+
fprintf(stderr, "ERROR: invalid address format for --api-listen. The address "
|
215
214
|
"must be formatted as tcp://IP:PORT for TCP sockets, or unix:PATH "
|
216
215
|
"for Unix domain sockets.\n");
|
217
216
|
exit(1);
|
@@ -71,6 +71,9 @@ whenBufferingBody_onRequestBody(Client *client, Request *req,
|
|
71
71
|
psg_lstr_init(&header->key);
|
72
72
|
psg_lstr_append(&header->key, req->pool, "content-length",
|
73
73
|
sizeof("content-length") - 1);
|
74
|
+
psg_lstr_init(&header->origKey);
|
75
|
+
psg_lstr_append(&header->origKey, req->pool, "Content-Length",
|
76
|
+
sizeof("Content-Length") - 1);
|
74
77
|
psg_lstr_init(&header->val);
|
75
78
|
psg_lstr_append(&header->val, req->pool, contentLength, size);
|
76
79
|
|