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