00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _PASSENGER_CONFIGURATION_H_
00026 #define _PASSENGER_CONFIGURATION_H_
00027
00028 #ifdef __cplusplus
00029 #include "Utils.h"
00030 #include "MessageChannel.h"
00031 #include "Logging.h"
00032 #endif
00033
00034
00035
00036
00037
00038
00039
00040
00041 #include <apr_pools.h>
00042 #include <httpd.h>
00043 #include <http_config.h>
00044
00045
00046
00047
00048
00049
00050
00051 #ifdef __cplusplus
00052 #include <set>
00053 #include <string>
00054
00055 namespace Passenger {
00056
00057 using namespace std;
00058
00059
00060
00061
00062
00063
00064
00065 struct DirConfig {
00066 enum Threeway { ENABLED, DISABLED, UNSET };
00067 enum SpawnMethod { SM_UNSET, SM_SMART, SM_SMART_LV2, SM_CONSERVATIVE };
00068
00069 Threeway enabled;
00070
00071 std::set<std::string> railsBaseURIs;
00072 std::set<std::string> rackBaseURIs;
00073
00074
00075 Threeway autoDetectRails;
00076
00077
00078 Threeway autoDetectRack;
00079
00080
00081 Threeway autoDetectWSGI;
00082
00083
00084 Threeway allowModRewrite;
00085
00086
00087
00088 const char *railsEnv;
00089
00090
00091
00092
00093
00094
00095 const char *appRoot;
00096
00097
00098
00099 const char *rackEnv;
00100
00101
00102 SpawnMethod spawnMethod;
00103
00104
00105
00106
00107
00108
00109 long frameworkSpawnerTimeout;
00110
00111
00112
00113
00114
00115
00116 long appSpawnerTimeout;
00117
00118
00119
00120
00121
00122 unsigned long maxRequests;
00123
00124
00125
00126 bool maxRequestsSpecified;
00127
00128
00129
00130
00131
00132 unsigned long memoryLimit;
00133
00134
00135
00136 bool memoryLimitSpecified;
00137
00138
00139
00140
00141
00142 Threeway resolveSymlinksInDocRoot;
00143
00144
00145 Threeway highPerformance;
00146
00147
00148 Threeway useGlobalQueue;
00149
00150
00151
00152
00153
00154
00155 Threeway allowEncodedSlashes;
00156
00157
00158
00159
00160
00161 unsigned long statThrottleRate;
00162
00163
00164
00165 bool statThrottleRateSpecified;
00166
00167
00168
00169
00170
00171 const char *restartDir;
00172
00173
00174
00175
00176
00177 const char *uploadBufferDir;
00178
00179
00180
00181
00182 bool isEnabled() const {
00183 return enabled != DISABLED;
00184 }
00185
00186 string getAppRoot(const char *documentRoot) const {
00187 if (appRoot == NULL) {
00188 if (resolveSymlinksInDocRoot == DirConfig::ENABLED) {
00189 return extractDirName(resolveSymlink(documentRoot));
00190 } else {
00191 return extractDirName(documentRoot);
00192 }
00193 } else {
00194 return appRoot;
00195 }
00196 }
00197
00198 string getAppRoot(const string &documentRoot) const {
00199 if (appRoot == NULL) {
00200 if (resolveSymlinksInDocRoot == DirConfig::ENABLED) {
00201 return extractDirName(resolveSymlink(documentRoot));
00202 } else {
00203 return extractDirName(documentRoot);
00204 }
00205 } else {
00206 return appRoot;
00207 }
00208 }
00209
00210 const char *getRailsEnv() const {
00211 if (railsEnv != NULL) {
00212 return railsEnv;
00213 } else {
00214 return "production";
00215 }
00216 }
00217
00218 const char *getRackEnv() const {
00219 if (rackEnv != NULL) {
00220 return rackEnv;
00221 } else {
00222 return "production";
00223 }
00224 }
00225
00226 const char *getSpawnMethodString() {
00227 switch (spawnMethod) {
00228 case SM_SMART:
00229 return "smart";
00230 case SM_SMART_LV2:
00231 return "smart-lv2";
00232 case SM_CONSERVATIVE:
00233 return "conservative";
00234 default:
00235 return "smart-lv2";
00236 }
00237 }
00238
00239 unsigned long getMaxRequests() {
00240 if (maxRequestsSpecified) {
00241 return maxRequests;
00242 } else {
00243 return 0;
00244 }
00245 }
00246
00247 unsigned long getMemoryLimit() {
00248 if (memoryLimitSpecified) {
00249 return memoryLimit;
00250 } else {
00251 return 200;
00252 }
00253 }
00254
00255 bool highPerformanceMode() const {
00256 return highPerformance == ENABLED;
00257 }
00258
00259 bool usingGlobalQueue() const {
00260 return useGlobalQueue == ENABLED;
00261 }
00262
00263 bool allowsEncodedSlashes() const {
00264 return allowEncodedSlashes == ENABLED;
00265 }
00266
00267 unsigned long getStatThrottleRate() const {
00268 if (statThrottleRateSpecified) {
00269 return statThrottleRate;
00270 } else {
00271 return 0;
00272 }
00273 }
00274
00275 const char *getRestartDir() const {
00276 if (restartDir != NULL) {
00277 return restartDir;
00278 } else {
00279 return "";
00280 }
00281 }
00282
00283 string getUploadBufferDir() const {
00284 if (uploadBufferDir != NULL) {
00285 return uploadBufferDir;
00286 } else {
00287 return getPassengerTempDir() + "/webserver_private";
00288 }
00289 }
00290
00291
00292 };
00293
00294
00295
00296
00297
00298
00299
00300 struct ServerConfig {
00301
00302 const char *ruby;
00303
00304
00305 const char *root;
00306
00307
00308 unsigned int logLevel;
00309
00310
00311
00312 unsigned int maxPoolSize;
00313
00314
00315
00316 bool maxPoolSizeSpecified;
00317
00318
00319
00320 unsigned int maxInstancesPerApp;
00321
00322
00323
00324 bool maxInstancesPerAppSpecified;
00325
00326
00327
00328 unsigned int poolIdleTime;
00329
00330
00331
00332 bool poolIdleTimeSpecified;
00333
00334
00335 bool userSwitching;
00336
00337
00338
00339 bool userSwitchingSpecified;
00340
00341
00342
00343
00344 const char *defaultUser;
00345
00346
00347
00348
00349 const char *tempDir;
00350
00351 const char *getRuby() const {
00352 if (ruby != NULL) {
00353 return ruby;
00354 } else {
00355 return "ruby";
00356 }
00357 }
00358
00359 const char *getDefaultUser() const {
00360 if (defaultUser != NULL) {
00361 return defaultUser;
00362 } else {
00363 return "nobody";
00364 }
00365 }
00366
00367 const char *getTempDir() const {
00368 if (tempDir != NULL) {
00369 return tempDir;
00370 } else {
00371 return getSystemTempDir();
00372 }
00373 }
00374 };
00375 }
00376
00377 extern "C" {
00378 #endif
00379
00380
00381 void *passenger_config_create_dir(apr_pool_t *p, char *dirspec);
00382
00383
00384 void *passenger_config_merge_dir(apr_pool_t *p, void *basev, void *addv);
00385
00386
00387 void *passenger_config_create_server(apr_pool_t *p, server_rec *s);
00388
00389
00390 void *passenger_config_merge_server(apr_pool_t *p, void *basev, void *overridesv);
00391
00392 void passenger_config_merge_all_servers(apr_pool_t *pool, server_rec *main_server);
00393
00394
00395 extern const command_rec passenger_commands[];
00396
00397 #ifdef __cplusplus
00398 }
00399 #endif
00400
00401
00402
00403
00404
00405 #endif