We got nominated! Help us out and vote for GitHub as Best Bootstrapped Startup of 2008. (You can vote once a day.) [ hide ]

public
Description: Phusion Passenger (mod_rails)
Homepage: http://www.modrails.com/
Clone URL: git://github.com/FooBarWidget/passenger.git
Click here to lend your support to: passenger and make a donation at www.pledgie.com !
Add 'RackEnv' configuration option.
Hongli Lai (Phusion) (author)
Fri May 09 03:28:46 -0700 2008
commit  afc6bb226dc68644350c003c59c6f3c41b82e209
tree    478782ca2613f3e57b1aa08ac4c1034af56507bb
parent  aee0150ab937bad93c6b258170f5a9d5542d58b2
...
57
58
59
60
 
 
61
62
63
...
76
77
78
79
 
 
80
81
82
...
187
188
189
190
 
191
192
193
...
271
272
273
 
 
 
 
 
 
 
274
275
276
...
354
355
356
 
 
 
 
 
357
358
359
...
57
58
59
 
60
61
62
63
64
...
77
78
79
 
80
81
82
83
84
...
189
190
191
 
192
193
194
195
...
273
274
275
276
277
278
279
280
281
282
283
284
285
...
363
364
365
366
367
368
369
370
371
372
373
0
@@ -57,7 +57,8 @@ passenger_config_create_dir(apr_pool_t *p, char *dirspec) {
0
   config->autoDetectRails = DirConfig::UNSET;
0
   config->autoDetectRack = DirConfig::UNSET;
0
   config->allowModRewrite = DirConfig::UNSET;
0
- config->env = NULL;
0
+ config->railsEnv = NULL;
0
+ config->rackEnv = NULL;
0
   config->spawnMethod = DirConfig::SM_UNSET;
0
   return config;
0
 }
0
@@ -76,7 +77,8 @@ passenger_config_merge_dir(apr_pool_t *p, void *basev, void *addv) {
0
   config->autoDetectRails = (add->autoDetectRails == DirConfig::UNSET) ? base->autoDetectRails : add->autoDetectRails;
0
   config->autoDetectRack = (add->autoDetectRack == DirConfig::UNSET) ? base->autoDetectRack : add->autoDetectRack;
0
   config->allowModRewrite = (add->allowModRewrite == DirConfig::UNSET) ? base->allowModRewrite : add->allowModRewrite;
0
- config->env = (add->env == NULL) ? base->env : add->env;
0
+ config->railsEnv = (add->railsEnv == NULL) ? base->railsEnv : add->railsEnv;
0
+ config->rackEnv = (add->rackEnv == NULL) ? base->rackEnv : add->rackEnv;
0
   config->spawnMethod = (add->spawnMethod == DirConfig::SM_UNSET) ? base->spawnMethod : add->spawnMethod;
0
   return config;
0
 }
0
@@ -187,7 +189,7 @@ cmd_rails_ruby(cmd_parms *cmd, void *pcfg, const char *arg) {
0
 static const char *
0
 cmd_rails_env(cmd_parms *cmd, void *pcfg, const char *arg) {
0
   DirConfig *config = (DirConfig *) pcfg;
0
- config->env = arg;
0
+ config->railsEnv = arg;
0
   return NULL;
0
 }
0
 
0
@@ -271,6 +273,13 @@ cmd_rack_auto_detect(cmd_parms *cmd, void *pcfg, int arg) {
0
   return NULL;
0
 }
0
 
0
+static const char *
0
+cmd_rack_env(cmd_parms *cmd, void *pcfg, const char *arg) {
0
+ DirConfig *config = (DirConfig *) pcfg;
0
+ config->rackEnv = arg;
0
+ return NULL;
0
+}
0
+
0
 
0
 /*************************************************
0
  * Obsolete settings
0
@@ -354,6 +363,11 @@ const command_rec passenger_commands[] = {
0
     NULL,
0
     RSRC_CONF,
0
     "Whether auto-detection of Rack applications should be enabled."),
0
+ AP_INIT_TAKE1("RackEnv",
0
+ (Take1Func) cmd_rack_env,
0
+ NULL,
0
+ RSRC_CONF,
0
+ "The environment under which a Rack app must run."),
0
   
0
   // Obsolete options.
0
   AP_INIT_TAKE1("RailsSpawnServer",
...
46
47
48
 
 
49
 
 
50
 
 
51
52
53
54
55
 
 
 
 
 
 
 
56
57
58
 
59
60
61
...
46
47
48
49
50
51
52
53
54
55
56
57
58
 
 
 
59
60
61
62
63
64
65
66
 
67
68
69
70
71
0
@@ -46,16 +46,26 @@
0
       enum Threeway { ENABLED, DISABLED, UNSET };
0
       
0
       std::set<std::string> base_uris;
0
+
0
+ /** Whether to autodetect Rails applications. */
0
       Threeway autoDetectRails;
0
+
0
+ /** Whether to autodetect Rack applications. */
0
       Threeway autoDetectRack;
0
+
0
+ /** Whether mod_rewrite should be allowed for Rails applications. */
0
       Threeway allowModRewrite;
0
       
0
- /** The environment (i.e. value for RAILS_ENV) under which the
0
- * Rails application should operate. */
0
- const char *env;
0
+ /** The environment (i.e. value for RAILS_ENV) under which
0
+ * Rails applications should operate. */
0
+ const char *railsEnv;
0
+
0
+ /** The environment (i.e. value for RACK_ENV) under which
0
+ * Rack applications should operate. */
0
+ const char *rackEnv;
0
       
0
- /** The spawn method to use. */
0
       enum SpawnMethod { SM_UNSET, SM_SMART, SM_CONSERVATIVE };
0
+ /** The Rails spawn method to use. */
0
       SpawnMethod spawnMethod;
0
     };
0
     
...
48
49
50
51
 
 
52
53
54
...
586
587
588
589
590
 
 
 
 
 
 
591
592
 
 
 
 
 
593
594
595
...
48
49
50
 
51
52
53
54
55
...
587
588
589
 
 
590
591
592
593
594
595
596
 
597
598
599
600
601
602
603
604
0
@@ -48,7 +48,8 @@ using namespace Passenger;
0
 extern "C" module AP_MODULE_DECLARE_DATA passenger_module;
0
 
0
 #define DEFAULT_RUBY_COMMAND "ruby"
0
-#define DEFAULT_RAILS_ENV "production"
0
+#define DEFAULT_RAILS_ENV "production"
0
+#define DEFAULT_RACK_ENV "production"
0
 
0
 
0
 /**
0
@@ -586,10 +587,18 @@ public:
0
         } else {
0
           defaultUser = "nobody";
0
         }
0
- if (config->env == NULL) {
0
- environment = DEFAULT_RAILS_ENV;
0
+ if (mapper.getApplicationType() == DirectoryMapper::RAILS) {
0
+ if (config->railsEnv == NULL) {
0
+ environment = DEFAULT_RAILS_ENV;
0
+ } else {
0
+ environment = config->railsEnv;
0
+ }
0
         } else {
0
- environment = config->env;
0
+ if (config->rackEnv == NULL) {
0
+ environment = DEFAULT_RACK_ENV;
0
+ } else {
0
+ environment = config->rackEnv;
0
+ }
0
         }
0
         if (config->spawnMethod == DirConfig::SM_CONSERVATIVE) {
0
           spawnMethod = "conservative";

Comments

    No one has commented yet.