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
00049 #define PASSENGER_VERSION "2.2.0"
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 Threeway highPerformance;
00139
00140
00141 Threeway useGlobalQueue;
00142
00143
00144
00145
00146
00147 unsigned long statThrottleRate;
00148
00149
00150
00151 bool statThrottleRateSpecified;
00152
00153
00154
00155
00156
00157 const char *restartDir;
00158
00159
00160
00161 bool isEnabled() const {
00162 return enabled != DISABLED;
00163 }
00164
00165 string getAppRoot(const char *documentRoot) const {
00166 if (appRoot == NULL) {
00167 return extractDirName(documentRoot);
00168 } else {
00169 return appRoot;
00170 }
00171 }
00172
00173 string getAppRoot(const string &documentRoot) const {
00174 if (appRoot == NULL) {
00175 return extractDirName(documentRoot);
00176 } else {
00177 return appRoot;
00178 }
00179 }
00180
00181 const char *getRailsEnv() const {
00182 if (railsEnv != NULL) {
00183 return railsEnv;
00184 } else {
00185 return "production";
00186 }
00187 }
00188
00189 const char *getRackEnv() const {
00190 if (rackEnv != NULL) {
00191 return rackEnv;
00192 } else {
00193 return "production";
00194 }
00195 }
00196
00197 const char *getSpawnMethodString() {
00198 switch (spawnMethod) {
00199 case SM_SMART:
00200 return "smart";
00201 case SM_SMART_LV2:
00202 return "smart-lv2";
00203 case SM_CONSERVATIVE:
00204 return "conservative";
00205 default:
00206 return "smart-lv2";
00207 }
00208 }
00209
00210 unsigned long getMaxRequests() {
00211 if (maxRequestsSpecified) {
00212 return maxRequests;
00213 } else {
00214 return 0;
00215 }
00216 }
00217
00218 unsigned long getMemoryLimit() {
00219 if (memoryLimitSpecified) {
00220 return memoryLimit;
00221 } else {
00222 return 200;
00223 }
00224 }
00225
00226 bool highPerformanceMode() const {
00227 return highPerformance == ENABLED;
00228 }
00229
00230 bool usingGlobalQueue() const {
00231 return useGlobalQueue == ENABLED;
00232 }
00233
00234 unsigned long getStatThrottleRate() const {
00235 if (statThrottleRateSpecified) {
00236 return statThrottleRate;
00237 } else {
00238 return 0;
00239 }
00240 }
00241
00242 const char *getRestartDir() const {
00243 if (restartDir != NULL) {
00244 return restartDir;
00245 } else {
00246 return "";
00247 }
00248 }
00249
00250
00251 };
00252
00253
00254
00255
00256
00257
00258
00259 struct ServerConfig {
00260
00261 const char *ruby;
00262
00263
00264 const char *root;
00265
00266
00267 unsigned int logLevel;
00268
00269
00270
00271 unsigned int maxPoolSize;
00272
00273
00274
00275 bool maxPoolSizeSpecified;
00276
00277
00278
00279 unsigned int maxInstancesPerApp;
00280
00281
00282
00283 bool maxInstancesPerAppSpecified;
00284
00285
00286
00287 unsigned int poolIdleTime;
00288
00289
00290
00291 bool poolIdleTimeSpecified;
00292
00293
00294 bool userSwitching;
00295
00296
00297
00298 bool userSwitchingSpecified;
00299
00300
00301
00302
00303 const char *defaultUser;
00304
00305
00306
00307
00308 const char *tempDir;
00309
00310 const char *getDefaultUser() const {
00311 if (defaultUser != NULL) {
00312 return defaultUser;
00313 } else {
00314 return "nobody";
00315 }
00316 }
00317
00318 const char *getTempDir() const {
00319 if (tempDir != NULL) {
00320 return tempDir;
00321 } else {
00322 return getSystemTempDir();
00323 }
00324 }
00325 };
00326 }
00327
00328 extern "C" {
00329 #endif
00330
00331
00332 void *passenger_config_create_dir(apr_pool_t *p, char *dirspec);
00333
00334
00335 void *passenger_config_merge_dir(apr_pool_t *p, void *basev, void *addv);
00336
00337
00338 void *passenger_config_create_server(apr_pool_t *p, server_rec *s);
00339
00340
00341 void *passenger_config_merge_server(apr_pool_t *p, void *basev, void *overridesv);
00342
00343 void passenger_config_merge_all_servers(apr_pool_t *pool, server_rec *main_server);
00344
00345
00346 extern const command_rec passenger_commands[];
00347
00348 #ifdef __cplusplus
00349 }
00350 #endif
00351
00352
00353
00354
00355
00356 #endif