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