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 !
Refactor stuff in favor of Rack support.
Hongli Lai (Phusion) (author)
Fri May 09 03:20:00 -0700 2008
commit  aee0150ab937bad93c6b258170f5a9d5542d58b2
tree    f42db53ab19d5a3227931b367a49d399f027fbc9
parent  92da962f3a2ec9c13ae33e7be336ab2fc2d59570
...
31
32
33
34
 
35
36
37
38
39
40
 
41
42
43
...
105
106
107
108
 
109
110
111
...
31
32
33
 
34
35
36
37
38
39
 
40
41
42
43
...
105
106
107
 
108
109
110
111
0
@@ -31,13 +31,13 @@ using namespace boost;
0
 /**
0
  * A persistent pool of Applications.
0
  *
0
- * Spawning Ruby on Rails application instances is a very expensive operation.
0
+ * Spawning application instances, especially Ruby on Rails ones, is a very expensive operation.
0
  * Despite best efforts to make the operation less expensive (see SpawnManager),
0
  * it remains expensive compared to the cost of processing an HTTP request/response.
0
  * So, in order to solve this, some sort of caching/pooling mechanism will be required.
0
  * ApplicationPool provides this.
0
  *
0
- * Normally, one would use SpawnManager to spawn a new RoR application instance,
0
+ * Normally, one would use SpawnManager to spawn a new RoR/Rack application instance,
0
  * then use Application::connect() to create a new session with that application
0
  * instance, and then use the returned Session object to send the request and
0
  * to read the HTTP response. ApplicationPool replaces the first step with
0
@@ -105,7 +105,7 @@ public:
0
    * directory, but does not have to be an absolute path.
0
    * @param lowerPrivilege Whether to lower the application's privileges.
0
    * @param lowestUser The user to fallback to if lowering privilege fails.
0
- * @param environment The RAILS_ENV environment that should be used. May not be empty.
0
+ * @param environment The RAILS_ENV/RACK_ENV environment that should be used. May not be empty.
0
    * @param spawnMethod The spawn method to use. Either "smart" or "conservative".
0
     * See the Ruby class SpawnManager for details.
0
     * @param appType The application type. Either "rails" or "rack".
...
54
55
56
57
 
 
58
59
60
...
72
73
74
75
 
 
76
77
78
...
135
136
137
 
 
 
 
 
138
139
140
...
143
144
145
 
 
 
 
 
146
147
148
...
153
154
155
156
 
157
158
159
...
247
248
249
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
250
251
252
...
260
261
262
 
263
264
265
266
267
268
 
269
270
271
...
317
318
319
 
 
 
 
 
 
 
320
321
322
...
54
55
56
 
57
58
59
60
61
...
73
74
75
 
76
77
78
79
80
...
137
138
139
140
141
142
143
144
145
146
147
...
150
151
152
153
154
155
156
157
158
159
160
...
165
166
167
 
168
169
170
171
...
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
...
289
290
291
292
293
294
295
296
297
298
299
300
301
302
...
348
349
350
351
352
353
354
355
356
357
358
359
360
0
@@ -54,7 +54,8 @@ extern "C" {
0
 void *
0
 passenger_config_create_dir(apr_pool_t *p, char *dirspec) {
0
   DirConfig *config = create_dir_config_struct(p);
0
- config->autoDetect = DirConfig::UNSET;
0
+ config->autoDetectRails = DirConfig::UNSET;
0
+ config->autoDetectRack = DirConfig::UNSET;
0
   config->allowModRewrite = DirConfig::UNSET;
0
   config->env = NULL;
0
   config->spawnMethod = DirConfig::SM_UNSET;
0
@@ -72,7 +73,8 @@ passenger_config_merge_dir(apr_pool_t *p, void *basev, void *addv) {
0
     config->base_uris.insert(*it);
0
   }
0
   
0
- config->autoDetect = (add->autoDetect == DirConfig::UNSET) ? base->autoDetect : add->autoDetect;
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->spawnMethod = (add->spawnMethod == DirConfig::SM_UNSET) ? base->spawnMethod : add->spawnMethod;
0
@@ -135,6 +137,11 @@ passenger_config_merge_all_servers(apr_pool_t *pool, server_rec *main_server) {
0
   }
0
 }
0
 
0
+
0
+/*************************************************
0
+ * Passenger settings
0
+ *************************************************/
0
+
0
 static const char *
0
 cmd_passenger_root(cmd_parms *cmd, void *pcfg, const char *arg) {
0
   ServerConfig *config = (ServerConfig *) ap_get_module_config(
0
@@ -143,6 +150,11 @@ cmd_passenger_root(cmd_parms *cmd, void *pcfg, const char *arg) {
0
   return NULL;
0
 }
0
 
0
+
0
+/*************************************************
0
+ * Rails-specific settings
0
+ *************************************************/
0
+
0
 static const char *
0
 cmd_rails_base_uri(cmd_parms *cmd, void *pcfg, const char *arg) {
0
   DirConfig *config = (DirConfig *) pcfg;
0
@@ -153,7 +165,7 @@ cmd_rails_base_uri(cmd_parms *cmd, void *pcfg, const char *arg) {
0
 static const char *
0
 cmd_rails_auto_detect(cmd_parms *cmd, void *pcfg, int arg) {
0
   DirConfig *config = (DirConfig *) pcfg;
0
- config->autoDetect = (arg) ? DirConfig::ENABLED : DirConfig::DISABLED;
0
+ config->autoDetectRails = (arg) ? DirConfig::ENABLED : DirConfig::DISABLED;
0
   return NULL;
0
 }
0
 
0
@@ -247,6 +259,23 @@ cmd_rails_default_user(cmd_parms *cmd, void *dummy, const char *arg) {
0
   return NULL;
0
 }
0
 
0
+
0
+/*************************************************
0
+ * Rack-specific settings
0
+ *************************************************/
0
+
0
+static const char *
0
+cmd_rack_auto_detect(cmd_parms *cmd, void *pcfg, int arg) {
0
+ DirConfig *config = (DirConfig *) pcfg;
0
+ config->autoDetectRack = (arg) ? DirConfig::ENABLED : DirConfig::DISABLED;
0
+ return NULL;
0
+}
0
+
0
+
0
+/*************************************************
0
+ * Obsolete settings
0
+ *************************************************/
0
+
0
 static const char *
0
 cmd_rails_spawn_server(cmd_parms *cmd, void *pcfg, const char *arg) {
0
   fprintf(stderr, "WARNING: The 'RailsSpawnServer' option is obsolete. "
0
@@ -260,12 +289,14 @@ cmd_rails_spawn_server(cmd_parms *cmd, void *pcfg, const char *arg) {
0
 typedef const char * (*Take1Func)(); // Workaround for some weird C++-specific compiler error.
0
 
0
 const command_rec passenger_commands[] = {
0
+ // Passenger settings.
0
   AP_INIT_TAKE1("PassengerRoot",
0
     (Take1Func) cmd_passenger_root,
0
     NULL,
0
     RSRC_CONF,
0
     "The Passenger root folder."),
0
 
0
+ // Rails-specific settings.
0
   AP_INIT_TAKE1("RailsBaseURI",
0
     (Take1Func) cmd_rails_base_uri,
0
     NULL,
0
@@ -317,6 +348,13 @@ const command_rec passenger_commands[] = {
0
     RSRC_CONF,
0
     "The user that Rails applications must run as when user switching fails or is disabled."),
0
   
0
+ // Rack-specific settings.
0
+ AP_INIT_FLAG("RackAutoDetect",
0
+ (Take1Func) cmd_rack_auto_detect,
0
+ NULL,
0
+ RSRC_CONF,
0
+ "Whether auto-detection of Rack applications should be enabled."),
0
+
0
   // Obsolete options.
0
   AP_INIT_TAKE1("RailsSpawnServer",
0
     (Take1Func) cmd_rails_spawn_server,
...
46
47
48
49
 
 
50
51
52
...
46
47
48
 
49
50
51
52
53
0
@@ -46,7 +46,8 @@
0
       enum Threeway { ENABLED, DISABLED, UNSET };
0
       
0
       std::set<std::string> base_uris;
0
- Threeway autoDetect;
0
+ Threeway autoDetectRails;
0
+ Threeway autoDetectRack;
0
       Threeway allowModRewrite;
0
       
0
       /** The environment (i.e. value for RAILS_ENV) under which the
...
100
101
102
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
104
105
...
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
0
@@ -100,6 +100,31 @@ public:
0
 };
0
 
0
 /**
0
+ * A filesystem error, as returned by the operating system. This may include,
0
+ * for example, permission errors.
0
+ *
0
+ * @ingroup Exceptions
0
+ */
0
+class FileSystemException: public SystemException {
0
+private:
0
+ string m_filename;
0
+public:
0
+ FileSystemException(const string &message, int errorCode,
0
+ const string &filename)
0
+ : SystemException(message, errorCode),
0
+ m_filename(filename) {}
0
+
0
+ virtual ~FileSystemException() throw() {}
0
+
0
+ /**
0
+ * The filename that's associated to the error.
0
+ */
0
+ string filename() const throw() {
0
+ return m_filename;
0
+ }
0
+};
0
+
0
+/**
0
  * Represents an error that occured during an I/O operation.
0
  *
0
  * @ingroup Exceptions
...
76
77
78
79
 
 
80
81
82
83
 
 
84
85
86
...
213
214
215
216
217
218
219
220
221
 
 
222
223
224
...
251
252
253
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254
255
256
...
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
 
 
 
 
 
 
 
545
546
 
547
548
549
...
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
 
 
 
 
 
 
 
 
659
660
661
662
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
 
 
 
 
 
 
 
699
700
701
702
703
704
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
705
706
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
707
708
709
710
 
711
712
713
...
76
77
78
 
79
80
81
82
83
 
84
85
86
87
88
...
215
216
217
 
 
218
219
220
221
222
223
224
225
226
...
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
...
550
551
552
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
553
554
555
556
557
558
559
560
 
561
562
563
564
...
648
649
650
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
651
652
653
654
655
656
657
658
659
 
 
 
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
682
683
684
685
686
687
688
689
 
 
 
 
 
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
 
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
 
730
731
732
733
0
@@ -76,11 +76,13 @@ private:
0
   ApplicationType appType;
0
   
0
   inline bool shouldAutoDetectRails() {
0
- return config->autoDetect == DirConfig::ENABLED || config->autoDetect == DirConfig::UNSET;
0
+ return config->autoDetectRails == DirConfig::ENABLED ||
0
+ config->autoDetectRails == DirConfig::UNSET;
0
   }
0
   
0
   inline bool shouldAutoDetectRack() {
0
- return config->autoDetect == DirConfig::ENABLED || config->autoDetect == DirConfig::UNSET;
0
+ return config->autoDetectRack == DirConfig::ENABLED ||
0
+ config->autoDetectRack == DirConfig::UNSET;
0
   }
0
   
0
 public:
0
@@ -213,12 +215,12 @@ public:
0
       getBaseURI();
0
     }
0
     switch (appType) {
0
- case NONE:
0
- return NULL;
0
     case RAILS:
0
       return "rails";
0
     case RACK:
0
       return "rack";
0
+ default:
0
+ return NULL;
0
     };
0
   }
0
 };
0
@@ -251,6 +253,27 @@ private:
0
     return (ServerConfig *) ap_get_module_config(s->module_config, &passenger_module);
0
   }
0
   
0
+ void reportDocumentRootDeterminationError(request_rec *r) {
0
+ ap_set_content_type(r, "text/html; charset=UTF-8");
0
+ ap_rputs("<h1>Passenger error #1</h1>\n", r);
0
+ ap_rputs("Cannot determine the document root for the current request.", r);
0
+ }
0
+
0
+ void reportFileSystemError(request_rec *r, const FileSystemException &e) {
0
+ ap_set_content_type(r, "text/html; charset=UTF-8");
0
+ ap_rputs("<h1>Passenger error #2</h1>\n", r);
0
+ ap_rputs("An error occurred while trying to access '", r);
0
+ ap_rputs(ap_escape_html(r->pool, e.filename().c_str()), r);
0
+ ap_rputs("': ", r);
0
+ ap_rputs(ap_escape_html(r->pool, e.what()), r);
0
+ if (e.code() == EPERM) {
0
+ ap_rputs("<p>", r);
0
+ ap_rputs("Apache doesn't have read permissions to that file. ", r);
0
+ ap_rputs("Please fix the relevant file permissions.", r);
0
+ ap_rputs("</p>", r);
0
+ }
0
+ }
0
+
0
   /**
0
    * Convert an HTTP header name to a CGI environment name.
0
    */
0
@@ -527,23 +550,15 @@ public:
0
       return DECLINED;
0
     }
0
     
0
- if (mapper.getPublicDirectory().empty()) {
0
- ap_set_content_type(r, "text/html; charset=UTF-8");
0
- ap_rputs("<h1>Passenger error #1</h1>\n", r);
0
- ap_rputs("Cannot determine the location of the Rails application's \"public\" directory.", r);
0
- return OK;
0
- } // TODO: could throw exception...
0
- /*
0
- ap_set_content_type(r, "text/html; charset=UTF-8");
0
- ap_rputs("<h1>Passenger error #2</h1>\n", r);
0
- ap_rputs("Passenger thought that the Rails application's \"public\" directory is \"", r);
0
- ap_rputs(ap_escape_html(r->pool, railsDir.c_str()), r);
0
- ap_rputs("\". But upon further inspection, it doesn't seem to be a valid Rails ", r);
0
- ap_rputs("\"public\" folder. It is possible that Apache doesn't have read ", r);
0
- ap_rputs("permissions to your Rails application's folder. Please check your ", r);
0
- ap_rputs("file permissions.", r);
0
+ try {
0
+ if (mapper.getPublicDirectory().empty()) {
0
+ reportDocumentRootDeterminationError(r);
0
+ return OK;
0
+ }
0
+ } catch (const FileSystemException &e) {
0
+ reportFileSystemError(r, e);
0
       return OK;
0
- } */
0
+ }
0
     
0
     int httpStatus = ap_setup_client_block(r, REQUEST_CHUNKED_ERROR);
0
         if (httpStatus != OK) {
0
@@ -633,81 +648,86 @@ public:
0
   mapToStorage(request_rec *r) {
0
     DirConfig *config = getDirConfig(r);
0
     DirectoryMapper mapper(r, config);
0
- bool forwardToRails;
0
-
0
- // TODO: this can throw an exception...
0
- if (mapper.getBaseURI() == NULL || fileExists(r->filename)) {
0
- /*
0
- * fileExists():
0
- * If the file already exists, serve it directly.
0
- * This is for static assets like .css and .js files.
0
- */
0
- forwardToRails = false;
0
- } else if (r->method_number == M_GET) {
0
- char *html_file;
0
- size_t len;
0
-
0
- len = strlen(r->filename);
0
- if (len > 0 && r->filename[len - 1] == '/') {
0
- html_file = apr_pstrcat(r->pool, r->filename, "index.html", NULL);
0
- } else {
0
- html_file = apr_pstrcat(r->pool, r->filename, ".html", NULL);
0
- }
0
- if (fileExists(html_file)) {
0
- /* If a .html version of the URI exists, serve it directly.
0
- * We're essentially accelerating Rails page caching.
0
+ bool forwardToApplication;
0
+
0
+ try {
0
+ if (mapper.getBaseURI() == NULL || fileExists(r->filename)) {
0
+ /*
0
+ * fileExists():
0
+ * If the file already exists, serve it directly.
0
+ * This is for static assets like .css and .js files.
0
          */
0
- r->filename = html_file;
0
- r->canonical_filename = html_file;
0
- forwardToRails = false;
0
+ forwardToApplication = false;
0
+ } else if (r->method_number == M_GET) {
0
+ char *html_file;
0
+ size_t len;
0
+
0
+ len = strlen(r->filename);
0
+ if (len > 0 && r->filename[len - 1] == '/') {
0
+ html_file = apr_pstrcat(r->pool, r->filename, "index.html", NULL);
0
+ } else {
0
+ html_file = apr_pstrcat(r->pool, r->filename, ".html", NULL);
0
+ }
0
+ if (fileExists(html_file)) {
0
+ /* If a .html version of the URI exists, serve it directly.
0
+ * We're essentially accelerating Rails page caching.
0
+ */
0
+ r->filename = html_file;
0
+ r->canonical_filename = html_file;
0
+ forwardToApplication = false;
0
+ } else {
0
+ forwardToApplication = true;
0
+ }
0
       } else {
0
- forwardToRails = true;
0
- }
0
- } else {
0
- /*
0
- * Non-GET requests are always forwarded to Rails.
0
- * This important because of REST conventions, e.g.
0
- * 'POST /foo' maps to 'FooController.create',
0
- * while 'GET /foo' maps to 'FooController.index'.
0
- * We wouldn't want our page caching support to interfere
0
- * with that.
0
- */
0
- forwardToRails = true;
0
- }
0
-
0
- if (forwardToRails) {
0
- /* Apache's default map_to_storage process does strange
0
- * things with the filename. Suppose that the DocumentRoot
0
- * is /website, on server http://test.com/. If we access
0
- * http://test.com/foo/bar, and /website/foo/bar does not
0
- * exist, then Apache will change the filename to
0
- * /website/foo instead of the expected /website/bar.
0
- * We make sure that doesn't happen.
0
- *
0
- * Incidentally, this also disables mod_rewrite. That is a
0
- * good thing because the default Rails .htaccess file
0
- * interferes with Passenger anyway (it delegates requests
0
- * to the CGI script dispatch.cgi).
0
- */
0
- if (config->allowModRewrite == DirConfig::UNSET
0
- || config->allowModRewrite == DirConfig::DISABLED) {
0
- /* Of course, we only do that if the config allows us
0
- * to. Some people have complex mod_rewrite rules that
0
- * they don't want to abandon. Those people will have to
0
- * make sure that the Rails app's .htaccess doesn't
0
- * interfere.
0
+ /*
0
+ * Non-GET requests are always forwarded to the application.
0
+ * This important because of REST conventions, e.g.
0
+ * 'POST /foo' maps to 'FooController.create',
0
+ * while 'GET /foo' maps to 'FooController.index'.
0
+ * We wouldn't want our page caching support to interfere
0
+ * with that.
0
          */
0
- return OK;
0
- } else if (strcmp(r->uri, mapper.getBaseURI()) == 0) {
0
- /* But we ignore RailsAllowModRewrite for the base URI of
0
- * the Rails application. Otherwise, Apache will show a
0
- * directory listing. This fixes issue #11.
0
+ forwardToApplication = true;
0
+ }
0
+
0
+ if (forwardToApplication) {
0
+ /* Apache's default map_to_storage process does strange
0
+ * things with the filename. Suppose that the DocumentRoot
0
+ * is /website, on server http://test.com/. If we access
0
+ * http://test.com/foo/bar, and /website/foo/bar does not
0
+ * exist, then Apache will change the filename to
0
+ * /website/foo instead of the expected /website/bar.
0
+ * We make sure that doesn't happen.
0
+ *
0
+ * Incidentally, this also disables mod_rewrite. That is a
0
+ * good thing because the default Rails .htaccess file
0
+ * interferes with Passenger anyway (it delegates requests
0
+ * to the CGI script dispatch.cgi).
0
          */
0
- return OK;
0
+ if (config->allowModRewrite != DirConfig::ENABLED
0
+ && mapper.getApplicationType() == DirectoryMapper::RAILS) {
0
+ /* Of course, we only do that if all of the following
0
+ * are true:
0
+ * - the config allows us to. Some people have complex
0
+ * mod_rewrite rules that they don't want to abandon.
0
+ * Those people will have to make sure that the Rails
0
+ * app's .htaccess doesn't interfere.
0
+ * - this is a Rails application.
0
+ */
0
+ return OK;
0
+ } else if (strcmp(r->uri, mapper.getBaseURI()) == 0) {
0
+ /* If the request URI is the application's base URI,
0
+ * then we'll want to take over control. Otherwise,
0
+ * Apache will show a directory listing. This fixes issue #11.
0
+ */
0
+ return OK;
0
+ } else {
0
+ return DECLINED;
0
+ }
0
       } else {
0
         return DECLINED;
0
       }
0
- } else {
0
+ } catch (const FileSystemException &e) {
0
       return DECLINED;
0
     }
0
   }
...
45
46
47
48
 
49
50
51
 
 
52
53
54
...
236
237
238
239
 
240
241
242
...
446
447
448
449
 
450
451
452
...
477
478
479
480
 
481
482
483
...
45
46
47
 
48
49
 
 
50
51
52
53
54
...
236
237
238
 
239
240
241
242
...
446
447
448
 
449
450
451
452
...
477
478
479
 
480
481
482
483
0
@@ -45,10 +45,10 @@ using namespace std;
0
 using namespace boost;
0
 
0
 /**
0
- * @brief Spawning of Ruby on Rails application instances.
0
+ * @brief Spawning of Ruby on Rails/Rack application instances.
0
  *
0
- * This class is responsible for spawning new instances of Ruby on Rails applications.
0
- * Use the spawn() method to do so.
0
+ * This class is responsible for spawning new instances of Ruby on Rails or
0
+ * Rack applications. Use the spawn() method to do so.
0
  *
0
  * @note This class is fully thread-safe.
0
  *
0
@@ -236,7 +236,7 @@ private:
0
    * @param appRoot The application root of the application to spawn.
0
    * @param lowerPrivilege Whether to lower the application's privileges.
0
    * @param lowestUser The user to fallback to if lowering privilege fails.
0
- * @param environment The RAILS_ENV environment that should be used.
0
+ * @param environment The RAILS_ENV/RACK_ENV environment that should be used.
0
    * @param spawnMethod The spawn method to use.
0
    * @param appType The application type.
0
    * @return An Application smart pointer, representing the spawned application.
0
@@ -446,7 +446,7 @@ public:
0
   }
0
   
0
   /**
0
- * Spawn a new instance of a Ruby on Rails application.
0
+ * Spawn a new instance of a Ruby on Rails or Rack application.
0
    *
0
    * If the spawn server died during the spawning process, then the server
0
    * will be automatically restarted, and another spawn attempt will be made.
0
@@ -477,7 +477,7 @@ public:
0
    * but the path does not have to be absolute.
0
    * @param lowerPrivilege Whether to lower the application's privileges.
0
    * @param lowestUser The user to fallback to if lowering privilege fails.
0
- * @param environment The RAILS_ENV environment that should be used. May not be empty.
0
+ * @param environment The RAILS_ENV/RACK_ENV environment that should be used. May not be empty.
0
    * @param spawnMethod The spawn method to use. Either "smart" or "conservative".
0
    * See the Ruby class SpawnManager for details.
0
    * @param appType The application type. Either "rails" or "rack".
...
55
56
57
58
 
59
60
61
...
55
56
57
 
58
59
60
61
0
@@ -55,7 +55,7 @@ fileExists(const char *filename) {
0
       string message("Cannot stat '");
0
       message.append(filename);
0
       message.append("'");
0
- throw SystemException(message, e);
0
+ throw FileSystemException(message, e, filename);
0
     }
0
   }
0
 }
...
130
131
132
133
 
134
135
136
...
172
173
174
175
 
176
177
178
...
181
182
183
184
 
185
186
187
...
130
131
132
 
133
134
135
136
...
172
173
174
 
175
176
177
178
...
181
182
183
 
184
185
186
187
0
@@ -130,7 +130,7 @@ void split(const string &str, char sep, vector<string> &output);
0
  *
0
  * @param filename The filename to check.
0
  * @return Whether the file exists.
0
- * @throws SystemException Unable to check because of a system error.
0
+ * @throws FileSystemException Unable to check because of a system error.
0
  * @ingroup Support
0
  */
0
 bool fileExists(const char *filename);
0
@@ -172,7 +172,7 @@ string canonicalizePath(const string &path);
0
  * Check whether the specified directory is a valid Ruby on Rails
0
  * 'public' directory.
0
  *
0
- * @throws SystemException Unable to check because of a system error.
0
+ * @throws FileSystemException Unable to check because of a system error.
0
  * @ingroup Support
0
  */
0
 bool verifyRailsDir(const string &dir);
0
@@ -181,7 +181,7 @@ bool verifyRailsDir(const string &dir);
0
  * Check whether the specified directory is a valid Rack 'public'
0
  * directory.
0
  *
0
- * @throws SystemException Unable to check because of a system error.
0
+ * @throws FileSystemException Unable to check because of a system error.
0
  * @ingroup Support
0
  */
0
 bool verifyRackDir(const string &dir);
...
28
29
30
 
31
32
33
...
28
29
30
31
32
33
34
0
@@ -28,6 +28,7 @@ class RackSpawner
0
         $0 = "Rack: #{app_root}"
0
         a.close
0
         channel = MessageChannel.new(b)
0
+ ENV['RACK_ENV'] = environment
0
         app = load_rack_app(app_root)
0
         
0
         reader, writer = IO.pipe

Comments

    No one has commented yet.