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