00001 /* 00002 * Phusion Passenger - http://www.modrails.com/ 00003 * Copyright (C) 2008 Phusion 00004 * 00005 * Phusion Passenger is a trademark of Hongli Lai & Ninh Bui. 00006 * 00007 * This program is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; version 2 of the License. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License along 00017 * with this program; if not, write to the Free Software Foundation, Inc., 00018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00019 */ 00020 #ifndef _PASSENGER_CONFIGURATION_H_ 00021 #define _PASSENGER_CONFIGURATION_H_ 00022 00023 #include <apr_pools.h> 00024 #include <httpd.h> 00025 #include <http_config.h> 00026 00027 /** 00028 * @defgroup Configuration Apache module configuration 00029 * @ingroup Core 00030 * @{ 00031 */ 00032 00033 /** Module version number. */ 00034 #define PASSENGER_VERSION "2.0.6" 00035 00036 #ifdef __cplusplus 00037 #include <set> 00038 #include <string> 00039 00040 namespace Passenger { 00041 00042 using namespace std; 00043 00044 /** 00045 * Per-directory configuration information. 00046 */ 00047 struct DirConfig { 00048 enum Threeway { ENABLED, DISABLED, UNSET }; 00049 00050 std::set<std::string> railsBaseURIs; 00051 std::set<std::string> rackBaseURIs; 00052 00053 /** Whether to autodetect Rails applications. */ 00054 Threeway autoDetectRails; 00055 00056 /** Whether to autodetect Rack applications. */ 00057 Threeway autoDetectRack; 00058 00059 /** Whether to autodetect WSGI applications. */ 00060 Threeway autoDetectWSGI; 00061 00062 /** Whether mod_rewrite should be allowed for Rails applications. */ 00063 Threeway allowModRewrite; 00064 00065 /** The environment (i.e. value for RAILS_ENV) under which 00066 * Rails applications should operate. */ 00067 const char *railsEnv; 00068 00069 /** The environment (i.e. value for RACK_ENV) under which 00070 * Rack applications should operate. */ 00071 const char *rackEnv; 00072 00073 enum SpawnMethod { SM_UNSET, SM_SMART, SM_CONSERVATIVE }; 00074 /** The Rails spawn method to use. */ 00075 SpawnMethod spawnMethod; 00076 }; 00077 00078 /** 00079 * Server-wide (global, not per-virtual host) configuration information. 00080 */ 00081 struct ServerConfig { 00082 /** The filename of the Ruby interpreter to use. */ 00083 const char *ruby; 00084 00085 /** The Passenger root folder. */ 00086 const char *root; 00087 00088 /** The log verbosity. */ 00089 unsigned int logLevel; 00090 00091 /** The maximum number of simultaneously alive application 00092 * instances. */ 00093 unsigned int maxPoolSize; 00094 00095 /** Whether the maxPoolSize option was explicitly specified in 00096 * this server config. */ 00097 bool maxPoolSizeSpecified; 00098 00099 /** The maximum number of simultaneously alive Rails application 00100 * that a single Rails application may occupy. */ 00101 unsigned int maxInstancesPerApp; 00102 00103 /** Whether the maxInstancesPerApp option was explicitly specified in 00104 * this server config. */ 00105 bool maxInstancesPerAppSpecified; 00106 00107 /** The maximum number of seconds that an application may be 00108 * idle before it gets terminated. */ 00109 unsigned int poolIdleTime; 00110 00111 /** Whether the poolIdleTime option was explicitly specified in 00112 * this server config. */ 00113 bool poolIdleTimeSpecified; 00114 00115 /** Whether global queuing should be used. */ 00116 bool useGlobalQueue; 00117 00118 /** Whether the useGlobalQueue option was explicitly specified 00119 * in this server config. */ 00120 bool useGlobalQueueSpecified; 00121 00122 /** Whether user switching support is enabled. */ 00123 bool userSwitching; 00124 00125 /** Whether the userSwitching option was explicitly specified in 00126 * this server config. */ 00127 bool userSwitchingSpecified; 00128 00129 /** The user that applications must run as if user switching 00130 * fails or is disabled. NULL means the option is not specified. 00131 */ 00132 const char *defaultUser; 00133 00134 bool getUseGlobalQueue() const { 00135 if (useGlobalQueueSpecified) { 00136 return useGlobalQueue; 00137 } else { 00138 return false; 00139 } 00140 } 00141 }; 00142 } 00143 00144 extern "C" { 00145 #endif 00146 00147 /** Configuration hook for per-directory configuration structure creation. */ 00148 void *passenger_config_create_dir(apr_pool_t *p, char *dirspec); 00149 00150 /** Configuration hook for per-directory configuration structure merging. */ 00151 void *passenger_config_merge_dir(apr_pool_t *p, void *basev, void *addv); 00152 00153 /** Configuration hook for per-server configuration structure creation. */ 00154 void *passenger_config_create_server(apr_pool_t *p, server_rec *s); 00155 00156 /** Configuration hook for per-server configuration structure merging. */ 00157 void *passenger_config_merge_server(apr_pool_t *p, void *basev, void *overridesv); 00158 00159 void passenger_config_merge_all_servers(apr_pool_t *pool, server_rec *main_server); 00160 00161 /** Apache module commands array. */ 00162 extern const command_rec passenger_commands[]; 00163 00164 #ifdef __cplusplus 00165 } 00166 #endif 00167 00168 /** 00169 * @} 00170 */ 00171 00172 #endif /* _PASSENGER_CONFIGURATION_H_ */