passenger 4.0.41 → 4.0.42

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of passenger might be problematic. Click here for more details.

Files changed (136) hide show
  1. checksums.yaml +8 -8
  2. checksums.yaml.gz.asc +7 -7
  3. data.tar.gz.asc +7 -7
  4. data/.travis.yml +3 -3
  5. data/CHANGELOG +26 -0
  6. data/build/agents.rb +1 -1
  7. data/build/apache2.rb +3 -0
  8. data/build/debian.rb +1 -1
  9. data/build/integration_tests.rb +4 -4
  10. data/build/nginx.rb +3 -0
  11. data/build/packaging.rb +3 -5
  12. data/build/preprocessor.rb +2 -1
  13. data/build/ruby_extension.rb +5 -5
  14. data/build/test_basics.rb +2 -1
  15. data/debian.template/control.template +9 -4
  16. data/debian.template/rules.template +16 -4
  17. data/dev/run_travis.sh +32 -8
  18. data/doc/Users guide Apache.txt +55 -10
  19. data/doc/Users guide Nginx.txt +10 -8
  20. data/doc/Users guide Standalone.txt +5 -2
  21. data/doc/users_guide_snippets/installation.txt +14 -0
  22. data/ext/common/ApplicationPool2/Process.h +8 -0
  23. data/ext/common/ApplicationPool2/Spawner.h +51 -1
  24. data/ext/common/Constants.h +1 -1
  25. data/ext/common/Utils/Curl.h +4 -0
  26. data/ext/common/agents/HelperAgent/RequestHandler.h +14 -2
  27. data/ext/common/agents/LoggingAgent/LoggingServer.h +4 -4
  28. data/ext/common/agents/LoggingAgent/RemoteSender.h +66 -5
  29. data/ext/nginx/StaticContentHandler.c +0 -7
  30. data/lib/phusion_passenger.rb +3 -3
  31. data/lib/phusion_passenger/config/about_command.rb +0 -4
  32. data/lib/phusion_passenger/config/build_native_support_command.rb +78 -0
  33. data/lib/phusion_passenger/config/detach_process_command.rb +0 -4
  34. data/lib/phusion_passenger/config/main.rb +12 -5
  35. data/lib/phusion_passenger/config/restart_app_command.rb +0 -4
  36. data/lib/phusion_passenger/config/validate_install_command.rb +0 -4
  37. data/lib/phusion_passenger/platform_info/compiler.rb +58 -41
  38. data/lib/phusion_passenger/platform_info/cxx_portability.rb +5 -0
  39. data/lib/phusion_passenger/standalone/command.rb +29 -10
  40. data/lib/phusion_passenger/standalone/help_command.rb +2 -2
  41. data/lib/phusion_passenger/standalone/start_command.rb +5 -1
  42. data/lib/phusion_passenger/utils/tee_input.rb +1 -0
  43. data/resources/mime.types +1 -1
  44. data/resources/oss-binaries.phusionpassenger.com.crt +124 -0
  45. data/resources/templates/apache2/deployment_example.txt.erb +2 -0
  46. data/resources/templates/standalone/config.erb +3 -1
  47. data/resources/templates/undisclosed_error.html.template +38 -1
  48. data/resources/union_station_gateway.crt +21 -0
  49. data/test/cxx/ApplicationPool2/SpawnerTestCases.cpp +34 -0
  50. data/test/cxx/RequestHandlerTest.cpp +10 -3
  51. data/test/cxx/TemplateTest.cpp +1 -1
  52. data/test/integration_tests/apache2_tests.rb +90 -106
  53. data/test/integration_tests/nginx_tests.rb +2 -0
  54. data/test/stub/rack/config.ru +7 -14
  55. data/test/stub/rack/library.rb +16 -0
  56. data/test/support/test_helper.rb +0 -3
  57. metadata +4 -80
  58. metadata.gz.asc +7 -7
  59. data/test/stub/rails2.3-mycook/Rakefile +0 -10
  60. data/test/stub/rails2.3-mycook/app/controllers/application_controller.rb +0 -12
  61. data/test/stub/rails2.3-mycook/app/controllers/recipes_controller.rb +0 -5
  62. data/test/stub/rails2.3-mycook/app/controllers/uploads_controller.rb +0 -15
  63. data/test/stub/rails2.3-mycook/app/controllers/welcome_controller.rb +0 -71
  64. data/test/stub/rails2.3-mycook/app/helpers/application_helper.rb +0 -3
  65. data/test/stub/rails2.3-mycook/app/helpers/recipes_helper.rb +0 -2
  66. data/test/stub/rails2.3-mycook/app/helpers/test_helper.rb +0 -2
  67. data/test/stub/rails2.3-mycook/app/helpers/uploads_helper.rb +0 -2
  68. data/test/stub/rails2.3-mycook/app/helpers/welcome_helper.rb +0 -2
  69. data/test/stub/rails2.3-mycook/app/views/layouts/default.rhtml +0 -26
  70. data/test/stub/rails2.3-mycook/app/views/recipes/create.rhtml +0 -13
  71. data/test/stub/rails2.3-mycook/app/views/recipes/index.rhtml +0 -3
  72. data/test/stub/rails2.3-mycook/app/views/recipes/new.rhtml +0 -8
  73. data/test/stub/rails2.3-mycook/app/views/uploads/index.rhtml +0 -1
  74. data/test/stub/rails2.3-mycook/app/views/uploads/new.html.erb +0 -8
  75. data/test/stub/rails2.3-mycook/app/views/welcome/cached.rhtml +0 -1
  76. data/test/stub/rails2.3-mycook/app/views/welcome/index.rhtml +0 -20
  77. data/test/stub/rails2.3-mycook/config/boot.rb +0 -110
  78. data/test/stub/rails2.3-mycook/config/database.yml +0 -19
  79. data/test/stub/rails2.3-mycook/config/environment.rb +0 -61
  80. data/test/stub/rails2.3-mycook/config/environments/development.rb +0 -18
  81. data/test/stub/rails2.3-mycook/config/environments/production.rb +0 -19
  82. data/test/stub/rails2.3-mycook/config/initializers/inflections.rb +0 -10
  83. data/test/stub/rails2.3-mycook/config/initializers/mime_types.rb +0 -5
  84. data/test/stub/rails2.3-mycook/config/routes.rb +0 -38
  85. data/test/stub/rails2.3-mycook/log/useless.txt +0 -1
  86. data/test/stub/rails2.3-mycook/public/.htaccess +0 -42
  87. data/test/stub/rails2.3-mycook/public/404.html +0 -30
  88. data/test/stub/rails2.3-mycook/public/422.html +0 -30
  89. data/test/stub/rails2.3-mycook/public/500.html +0 -30
  90. data/test/stub/rails2.3-mycook/public/dispatch.cgi +0 -10
  91. data/test/stub/rails2.3-mycook/public/dispatch.fcgi +0 -24
  92. data/test/stub/rails2.3-mycook/public/dispatch.rb +0 -10
  93. data/test/stub/rails2.3-mycook/public/favicon.ico +0 -0
  94. data/test/stub/rails2.3-mycook/public/images/angrywizard.gif +0 -0
  95. data/test/stub/rails2.3-mycook/public/images/cookbook.gif +0 -0
  96. data/test/stub/rails2.3-mycook/public/images/header.png +0 -0
  97. data/test/stub/rails2.3-mycook/public/images/rails.png +0 -0
  98. data/test/stub/rails2.3-mycook/public/robots.txt +0 -5
  99. data/test/stub/rails2.3-mycook/public/uploads.html +0 -26
  100. data/test/stub/rails2.3-mycook/public/uploads/.gitignore +0 -0
  101. data/test/stub/rails2.3-mycook/public/welcome/cached.html +0 -26
  102. data/test/stub/rails2.3-mycook/script/about +0 -3
  103. data/test/stub/rails2.3-mycook/script/console +0 -3
  104. data/test/stub/rails2.3-mycook/script/dbconsole +0 -3
  105. data/test/stub/rails2.3-mycook/script/destroy +0 -3
  106. data/test/stub/rails2.3-mycook/script/generate +0 -3
  107. data/test/stub/rails2.3-mycook/script/performance/benchmarker +0 -3
  108. data/test/stub/rails2.3-mycook/script/performance/profiler +0 -3
  109. data/test/stub/rails2.3-mycook/script/performance/request +0 -3
  110. data/test/stub/rails2.3-mycook/script/plugin +0 -3
  111. data/test/stub/rails2.3-mycook/script/process/inspector +0 -3
  112. data/test/stub/rails2.3-mycook/script/process/reaper +0 -3
  113. data/test/stub/rails2.3-mycook/script/process/spawner +0 -3
  114. data/test/stub/rails2.3-mycook/script/runner +0 -3
  115. data/test/stub/rails2.3-mycook/script/server +0 -3
  116. data/test/stub/rails2.3-mycook/sites/some.site/public/uploads.html +0 -26
  117. data/test/stub/rails2.3-mycook/sites/some.site/public/welcome/cached.html +0 -26
  118. data/test/stub/rails2.3-mycook/tmp/cache/useless.txt +0 -1
  119. data/test/stub/rails2.3-mycook/tmp/pids/useless.txt +0 -1
  120. data/test/stub/rails2.3-mycook/tmp/sessions/useless.txt +0 -1
  121. data/test/stub/rails2.3-mycook/tmp/sockets/useless.txt +0 -1
  122. data/test/stub/vendor_rails/minimal/README +0 -1
  123. data/test/stub/vendor_rails/minimal/actionmailer/lib/action_mailer.rb +0 -0
  124. data/test/stub/vendor_rails/minimal/actionpack/lib/action_controller.rb +0 -22
  125. data/test/stub/vendor_rails/minimal/actionpack/lib/action_pack.rb +0 -0
  126. data/test/stub/vendor_rails/minimal/actionpack/lib/action_view.rb +0 -0
  127. data/test/stub/vendor_rails/minimal/activerecord/lib/active_record.rb +0 -7
  128. data/test/stub/vendor_rails/minimal/activeresource/lib/active_resource.rb +0 -0
  129. data/test/stub/vendor_rails/minimal/activesupport/lib/active_support.rb +0 -17
  130. data/test/stub/vendor_rails/minimal/activesupport/lib/active_support/whiny_nil.rb +0 -0
  131. data/test/stub/vendor_rails/minimal/railties/lib/dispatcher.rb +0 -0
  132. data/test/stub/vendor_rails/minimal/railties/lib/initializer.rb +0 -57
  133. data/test/stub/vendor_rails/minimal/railties/lib/ruby_version_check.rb +0 -1
  134. data/test/stub/zsfa/header.png +0 -0
  135. data/test/stub/zsfa/index.html +0 -14
  136. data/test/stub/zsfa/zsfa.png +0 -0
@@ -12,6 +12,8 @@ Apache configuration file and set its DocumentRoot to <b>/somewhere/public</b>:
12
12
  AllowOverride all
13
13
  # MultiViews must be turned off.
14
14
  Options -MultiViews
15
+ # Uncomment this if you're on Apache >= 2.4:
16
+ #Require all granted
15
17
  </Directory>
16
18
  </VirtualHost>
17
19
  </b>
@@ -62,7 +62,9 @@ http {
62
62
  <% if @options[:rolling_restarts] %>passenger_rolling_restarts on;<% end %>
63
63
  <% if @options[:resist_deployment_errors] %>passenger_resist_deployment_errors on;<% end %>
64
64
 
65
- <% unless @options[:friendly_error_pages] %>passenger_friendly_error_pages off;<% end %>
65
+ <% if !@options[:friendly_error_pages].nil? -%>
66
+ passenger_friendly_error_pages <%= boolean_config_value(@options[:friendly_error_pages]) %>;
67
+ <% end %>
66
68
 
67
69
  <% if @options[:union_station_gateway_address] %>
68
70
  union_station_gateway_address <%= @options[:union_station_gateway_address] %>;
@@ -4,7 +4,7 @@
4
4
  <title>We're sorry, but something went wrong (500)</title>
5
5
  <style type="text/css">
6
6
  body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
7
+ .dialog {
8
8
  width: 25em;
9
9
  padding: 0 4em;
10
10
  margin: 4em auto 0 auto;
@@ -13,6 +13,14 @@
13
13
  border-bottom-color: #999;
14
14
  }
15
15
  h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ #operator_info_panel {
17
+ width: 27em;
18
+ margin: 4em auto 0 auto;
19
+ line-height: 1.2em;
20
+ }
21
+ #show_operator_info { text-decoration: none; color: #99f; font-size: smaller; }
22
+ #show_operator_info:hover { text-decoration: underline; }
23
+ #operator_info { color: #444; text-align: justify; }
16
24
  </style>
17
25
  </head>
18
26
 
@@ -21,5 +29,34 @@
21
29
  <h1>We're sorry, but something went wrong.</h1>
22
30
  <p>We've been notified about this issue and we'll take a look at it shortly.</p>
23
31
  </div>
32
+ <div id="operator_info_panel">
33
+ <a id="show_operator_info" href="javascript:void(showOperatorInfo())">Information for the administrator of this website</a>
34
+ <div id="operator_info" style="display: none">
35
+ <p>The {{PROGRAM_NAME}} application server encountered an error while starting your web application.
36
+ Because you are running this web application in staging or production mode, the details of the error
37
+ have been omitted from this web page for security reasons.</p>
38
+ <p><strong>Please read the web server error log to find the details of the error.</strong>
39
+ If you don't know where the web server error log is, read the troubleshooting documentation below.</p>
40
+ <p>Alternatively, you can turn on the "friendly error pages" feature (see below), which will make {{PROGRAM_NAME}} show many details about the error right in the browser.</p>
41
+ <p>{{PROGRAM_NAME}} troubleshooting documentation:</p>
42
+ <ul>
43
+ <li><a href="{{NGINX_DOC_URL|raw}}#troubleshooting">Nginx integration mode</a></li>
44
+ <li><a href="{{APACHE2_DOC_URL|raw}}#troubleshooting">Apache integration mode</a></li>
45
+ <li><a href="{{STANDALONE_DOC_URL|raw}}#troubleshooting">Standalone mode</a></li>
46
+ </ul>
47
+ <p>To turn on friendly error pages:</p>
48
+ <ul>
49
+ <li><a href="{{NGINX_DOC_URL|raw}}#PassengerFriendlyErrorPages">Nginx integration mode</a></li>
50
+ <li><a href="{{APACHE2_DOC_URL|raw}}#PassengerFriendlyErrorPages">Apache integration mode</a></li>
51
+ <li>Standalone mode: pass the <code>--friendly-error-pages</code> parameter to the <code>passenger</code> command.</li>
52
+ </ul>
53
+ </div>
54
+ </div>
55
+
56
+ <script>
57
+ function showOperatorInfo() {
58
+ document.getElementById('operator_info').style.display = 'block';
59
+ }
60
+ </script>
24
61
  </body>
25
62
  </html>
@@ -30,3 +30,24 @@ Fj0lBkzVUOlt2nWhLIW/uN3bjM9TsXaw8qUGWhvn4z3FHGHEdnLy3wMzwCSVq1tg
30
30
  QilKaQe+8Y4SePo110Tmkfls6vyEhcN6KpRWdpQSXUXmMY7IxjfNJnKTeGvWd1Y9
31
31
  CaY=
32
32
  -----END CERTIFICATE-----
33
+ -----BEGIN CERTIFICATE-----
34
+ MIIDhDCCAmwCCQDb6ONI7ndilzANBgkqhkiG9w0BAQUFADCBgzELMAkGA1UEBhMC
35
+ TkwxEzARBgNVBAgTCk92ZXJpanNzZWwxEDAOBgNVBAoTB1BodXNpb24xJDAiBgNV
36
+ BAMTG2dhdGV3YXkudW5pb25zdGF0aW9uYXBwLmNvbTEnMCUGCSqGSIb3DQEJARYY
37
+ aW5mb0B1bmlvbnN0YXRpb25hcHAuY29tMB4XDTE0MDQxMjE3MzUwOVoXDTQxMDgy
38
+ NzE3MzUwOVowgYMxCzAJBgNVBAYTAk5MMRMwEQYDVQQIEwpPdmVyaWpzc2VsMRAw
39
+ DgYDVQQKEwdQaHVzaW9uMSQwIgYDVQQDExtnYXRld2F5LnVuaW9uc3RhdGlvbmFw
40
+ cC5jb20xJzAlBgkqhkiG9w0BCQEWGGluZm9AdW5pb25zdGF0aW9uYXBwLmNvbTCC
41
+ ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANiimsW31XeYugqhRN6UqJVz
42
+ vkj6dIe8oEXC5kCQo9Snqt+3zXg/ETvQTFkKhpg3ZJowOX9C2D5Llu/6ddzaS/jM
43
+ MTxVs19g1n24hINhmuuADd2ETu5pxscaRyz7B6YutQZqIzZsy36vggAlJ1lABeCv
44
+ VqUafl09eyAYjmSUuNak2rTdAE7jM4Sa2QuhzDy1XYKxd88r1sLe4yK54Oq+mUco
45
+ 8GvEoKur8vyyQ4EC1v7Konmq8i5A1nq/BJMpUCK534EbM6tU7qFzNL4K3BwWllwo
46
+ zOjc6wEHAP9jqomcHNjTilT+WPxv3Gyrokzh25SQjQGUe7D4FnOfMrS38s2VOVMC
47
+ AwEAATANBgkqhkiG9w0BAQUFAAOCAQEAbR0lOyAJPm9xH0E3cWIeqNyJMTH9y3wa
48
+ 5HT5XAB9pd4alr0ALK0MXNFVRVqV7xmMji2ghANyObMPARkzGkqHrR1GKKcdSzec
49
+ uk3TtwA0OkTCc4ZKc95OcNOvyy63EG89pwMIM2qc7KcPYXEAWLclpWHYWuj4YJYD
50
+ RGgusQIrP4xlrqNGmevLL6dGXgtG0QEGJDx4J00+9W6WXHwNpsDfVI6Ai1Ghf2HN
51
+ ril0Fx4QPiMiO1a9C4BFHW2WK69jziVveAp++xsqEf5g31lfhyrb/uY0DYB0OsEl
52
+ 73aw9eJVkpc24cJEsUe7Hwg2xH1FWBvmcGZfj7Bz+yJ/XCdBFuAZZA==
53
+ -----END CERTIFICATE-----
@@ -317,6 +317,40 @@
317
317
  && gatheredOutput.find("hello stderr!\n") != string::npos;
318
318
  );
319
319
  }
320
+
321
+ TEST_METHOD(11) {
322
+ // It infers the code revision from the REVISION file.
323
+ TempDirCopy dir("stub/rack", "tmp.rack");
324
+ createFile("tmp.rack/REVISION", "hello\n");
325
+
326
+ Options options = createOptions();
327
+ options.appRoot = "tmp.rack";
328
+ options.startCommand = "ruby\t" "start.rb";
329
+ options.startupFile = "start.rb";
330
+ SpawnerPtr spawner = createSpawner(options);
331
+ process = spawner->spawn(options);
332
+ process->requiresShutdown = false;
333
+
334
+ ensure_equals(process->codeRevision, "hello");
335
+ }
336
+
337
+ TEST_METHOD(12) {
338
+ // It infers the code revision from the app root symlink,
339
+ // if the app root is called "current".
340
+ TempDir dir1("tmp.rack");
341
+ TempDirCopy dir2("stub/rack", "tmp.rack/today");
342
+ symlink("today", "tmp.rack/current");
343
+
344
+ Options options = createOptions();
345
+ options.appRoot = "tmp.rack/current";
346
+ options.startCommand = "ruby\t" "start.rb";
347
+ options.startupFile = "start.rb";
348
+ SpawnerPtr spawner = createSpawner(options);
349
+ process = spawner->spawn(options);
350
+ process->requiresShutdown = false;
351
+
352
+ ensure_equals(process->codeRevision, "today");
353
+ }
320
354
 
321
355
  // It raises an exception if getStartupCommand() is empty.
322
356
 
@@ -345,7 +345,8 @@ namespace tut {
345
345
  /***** Error page tests *****/
346
346
 
347
347
  TEST_METHOD(10) {
348
- set_test_name("If the app crashes at startup without an error page then it renders a generic error page.");
348
+ set_test_name("If the app crashes at startup without an error page, "
349
+ "and friendly error pages are turned on, then it renders a generic error page.");
349
350
  TempDir tempdir("tmp.handler");
350
351
  writeFile("tmp.handler/start.rb",
351
352
  "STDERR.puts 'I have failed'");
@@ -357,6 +358,7 @@ namespace tut {
357
358
  "PASSENGER_APP_ROOT", (root + "/test/tmp.handler").c_str(),
358
359
  "PASSENGER_APP_TYPE", "",
359
360
  "PASSENGER_START_COMMAND", ("ruby\t" + root + "/test/tmp.handler/start.rb").c_str(),
361
+ "PASSENGER_FRIENDLY_ERROR_PAGES", "true",
360
362
  "PATH_INFO", "/",
361
363
  NULL);
362
364
  string response = readAll(connection);
@@ -366,7 +368,8 @@ namespace tut {
366
368
  }
367
369
 
368
370
  TEST_METHOD(11) {
369
- set_test_name("If the app crashes at startup with an error page then it renders a friendly error page.");
371
+ set_test_name("If the app crashes at startup with an error page, "
372
+ "and friendly error pages are turned on, then it renders a friendly error page.");
370
373
  TempDir tempdir("tmp.handler");
371
374
  writeFile("tmp.handler/start.rb",
372
375
  "STDERR.puts 'Error'\n"
@@ -380,6 +383,7 @@ namespace tut {
380
383
  "PASSENGER_APP_ROOT", (root + "/test/tmp.handler").c_str(),
381
384
  "PASSENGER_APP_TYPE", "",
382
385
  "PASSENGER_START_COMMAND", ("ruby\t" + root + "/test/tmp.handler/start.rb").c_str(),
386
+ "PASSENGER_FRIENDLY_ERROR_PAGES", "true",
383
387
  "PATH_INFO", "/",
384
388
  NULL);
385
389
  string response = readAll(connection);
@@ -391,7 +395,8 @@ namespace tut {
391
395
  }
392
396
 
393
397
  TEST_METHOD(12) {
394
- set_test_name("If spawning fails because of an internal error then it reports the error appropriately.");
398
+ set_test_name("If spawning fails because of an internal error, "
399
+ "and friendly error pages are on, then it reports the error appropriately.");
395
400
  TempDir tempdir("tmp.handler");
396
401
  writeFile("tmp.handler/start.rb", "");
397
402
 
@@ -402,6 +407,7 @@ namespace tut {
402
407
  "PASSENGER_APP_ROOT", (root + "/test/tmp.handler").c_str(),
403
408
  "PASSENGER_APP_TYPE", "",
404
409
  "PASSENGER_START_COMMAND", ("ruby\t" + root + "/test/tmp.handler/start.rb").c_str(),
410
+ "PASSENGER_FRIENDLY_ERROR_PAGES", "true",
405
411
  "PASSENGER_RAISE_INTERNAL_ERROR", "true",
406
412
  "PATH_INFO", "/",
407
413
  NULL);
@@ -429,6 +435,7 @@ namespace tut {
429
435
  "PASSENGER_APP_ROOT", (root + "/test/tmp.handler").c_str(),
430
436
  "PASSENGER_APP_TYPE", "",
431
437
  "PASSENGER_START_COMMAND", ("ruby\t" + root + "/test/tmp.handler/start.rb").c_str(),
438
+ "PASSENGER_FRIENDLY_ERROR_PAGES", "true",
432
439
  "PASSENGER_STATUS_LINE", "false",
433
440
  "PATH_INFO", "/",
434
441
  NULL);
@@ -6,7 +6,7 @@ using namespace Passenger;
6
6
 
7
7
  namespace tut {
8
8
  struct TemplateTest {
9
- string apply(const StaticString &templateContent, ...) {
9
+ string apply(const char *templateContent, ...) {
10
10
  va_list ap;
11
11
  const char *arg;
12
12
  StringMap<StaticString> params;
@@ -271,127 +271,132 @@ describe "Apache 2 module" do
271
271
  create_apache2_controller
272
272
  @apache2 << "PassengerMaxPoolSize 3"
273
273
 
274
- @mycook = ClassicRailsStub.new('rails2.3-mycook')
275
- @mycook_url_root = "http://1.passenger.test:#{@apache2.port}"
276
- @apache2.set_vhost('1.passenger.test', "#{@mycook.full_app_root}/public") do |vhost|
274
+ @stub = RackStub.new('rack')
275
+ @stub_url_root = "http://5.passenger.test:#{@apache2.port}"
276
+ @apache2.set_vhost('5.passenger.test', "#{@stub.full_app_root}/public") do |vhost|
277
+ vhost << "PassengerBufferUpload off"
278
+ vhost << "PassengerFriendlyErrorPages on"
277
279
  vhost << "AllowEncodedSlashes on"
278
280
  end
279
281
 
280
- @foobar = ClassicRailsStub.new('rails2.3')
281
- @foobar_url_root = "http://3.passenger.test:#{@apache2.port}"
282
- @apache2.set_vhost('3.passenger.test', "#{@foobar.full_app_root}/public") do |vhost|
282
+ @stub2 = RackStub.new('rack')
283
+ @stub2_url_root = "http://6.passenger.test:#{@apache2.port}"
284
+ @apache2.set_vhost('6.passenger.test', "#{@stub2.full_app_root}/public") do |vhost|
283
285
  vhost << "RailsEnv development"
284
286
  vhost << "PassengerSpawnMethod conservative"
285
- vhost << "PassengerRestartDir #{@foobar.full_app_root}/public"
286
- end
287
-
288
- @mycook2 = ClassicRailsStub.new('rails2.3-mycook')
289
- @mycook2_url_root = "http://4.passenger.test:#{@apache2.port}"
290
- @apache2.set_vhost('4.passenger.test', "#{@mycook2.full_app_root}/sites/some.site/public") do |vhost|
291
- vhost << "PassengerAppRoot #{@mycook2.full_app_root}"
292
- end
293
-
294
- @stub = RackStub.new('rack')
295
- @stub_url_root = "http://5.passenger.test:#{@apache2.port}"
296
- @apache2.set_vhost('5.passenger.test', "#{@stub.full_app_root}/public") do |vhost|
297
- vhost << "PassengerBufferUpload off"
287
+ vhost << "PassengerRestartDir #{@stub2.full_app_root}/public"
288
+ vhost << "AllowEncodedSlashes off"
298
289
  end
299
290
 
300
291
  @apache2.start
301
292
  end
302
293
 
303
294
  after :all do
304
- @mycook.destroy
305
- @foobar.destroy
306
- @mycook2.destroy
307
295
  @stub.destroy
296
+ @stub2.destroy
308
297
  @apache2.stop if @apache2
309
298
  end
310
299
 
311
300
  before :each do
312
- @mycook.reset
313
- @foobar.reset
314
- @mycook2.reset
315
301
  @stub.reset
302
+ @stub2.reset
316
303
  end
317
304
 
318
305
  specify "RailsEnv is per-virtual host" do
319
- @server = @mycook_url_root
320
- get('/welcome/rails_env').should == "production"
306
+ @server = @stub_url_root
307
+ get('/system_env').should =~ /RAILS_ENV = production/
321
308
 
322
- @server = @foobar_url_root
323
- get('/foo/rails_env').should == "development"
309
+ @server = @stub2_url_root
310
+ get('/system_env').should =~ /RAILS_ENV = development/
324
311
  end
325
312
 
326
313
  it "looks for restart.txt in the directory specified by PassengerRestartDir" do
327
- @server = @foobar_url_root
328
- controller = "#{@foobar.app_root}/app/controllers/bar_controller.rb"
329
- restart_file = "#{@foobar.app_root}/public/restart.txt"
330
-
331
- File.write(controller, %Q{
332
- class BarController < ApplicationController
333
- def index
334
- render :text => 'hello world'
314
+ @server = @stub2_url_root
315
+ startup_file = "#{@stub2.app_root}/config.ru"
316
+ restart_file = "#{@stub2.app_root}/public/restart.txt"
317
+
318
+ File.write(startup_file, %Q{
319
+ require File.expand_path(File.dirname(__FILE__) + "/library")
320
+
321
+ app = lambda do |env|
322
+ case env['PATH_INFO']
323
+ when '/'
324
+ text_response("hello world")
325
+ else
326
+ [404, { "Content-Type" => "text/plain" }, ["Unknown URI"]]
335
327
  end
336
328
  end
329
+
330
+ run app
337
331
  })
338
332
 
339
333
  now = Time.now
340
334
  File.touch(restart_file, now - 5)
341
- get('/bar').should == "hello world"
335
+ get('/').should == "hello world"
336
+
337
+ File.write(startup_file, %Q{
338
+ require File.expand_path(File.dirname(__FILE__) + "/library")
342
339
 
343
- File.write(controller, %Q{
344
- class BarController < ApplicationController
345
- def index
346
- render :text => 'oh hai'
340
+ app = lambda do |env|
341
+ case env['PATH_INFO']
342
+ when '/'
343
+ text_response("oh hai")
344
+ else
345
+ [404, { "Content-Type" => "text/plain" }, ["Unknown URI"]]
347
346
  end
348
347
  end
348
+
349
+ run app
349
350
  })
350
351
 
351
352
  File.touch(restart_file, now - 10)
352
- get('/bar').should == "oh hai"
353
+ get('/').should == "oh hai"
353
354
  end
354
355
 
355
356
  describe "PassengerAppRoot" do
356
357
  before :each do
357
- @server = @mycook2_url_root
358
+ @server = @stub_url_root
359
+ File.write("#{@stub.full_app_root}/public/cached.html", "Static cached.html")
360
+ File.write("#{@stub.full_app_root}/public/dir.html", "Static dir.html")
361
+ Dir.mkdir("#{@stub.full_app_root}/public/dir")
358
362
  end
359
363
 
360
364
  it "supports page caching on non-index URIs" do
361
- get('/welcome/cached.html').should =~ %r{This is the cached version of some.site/public/welcome/cached}
365
+ get('/cached').should == "Static cached.html"
362
366
  end
363
367
 
364
- it "supports page caching on index URIs" do
365
- get('/uploads.html').should =~ %r{This is the cached version of some.site/public/uploads}
368
+ it "supports page caching on directory index URIs" do
369
+ get('/dir').should == "Static dir.html"
366
370
  end
367
371
 
368
- it "works as a rails application" do
369
- result = get('/welcome/parameters_test?hello=world&recipe[name]=Green+Bananas')
370
- result.should =~ %r{<hello>world</hello>}
371
- result.should =~ %r{<recipe>}
372
- result.should =~ %r{<name>Green Bananas</name>}
372
+ it "works" do
373
+ result = get('/parameters?first=one&second=Green+Bananas')
374
+ result.should =~ %r{First: one\n}
375
+ result.should =~ %r{Second: Green Bananas\n}
373
376
  end
374
377
  end
375
378
 
376
- specify "it resolves symlinks in the document root if PassengerResolveSymlinksInDocumentRoot is set" do
377
- orig_mycook_app_root = @mycook.app_root
378
- @mycook.move(File.expand_path('tmp.mycook.symlinktest'))
379
- FileUtils.mkdir_p(orig_mycook_app_root)
380
- File.symlink("#{@mycook.app_root}/public", "#{orig_mycook_app_root}/public")
379
+ it "resolves symlinks in the document root if PassengerResolveSymlinksInDocumentRoot is set" do
380
+ orig_app_root = @stub.app_root
381
+ @stub.move(File.expand_path('tmp.mycook.symlinktest'))
382
+ FileUtils.mkdir_p(orig_app_root)
383
+ File.symlink("#{@stub.app_root}/public", "#{orig_app_root}/public")
381
384
  begin
382
- File.write("#{@mycook.app_root}/public/.htaccess", "PassengerResolveSymlinksInDocumentRoot on")
383
- @server = @mycook_url_root
384
- get('/').should =~ /Welcome to MyCook/
385
+ File.write("#{@stub.app_root}/public/.htaccess", "PassengerResolveSymlinksInDocumentRoot on")
386
+ @server = @stub_url_root
387
+ get('/').should == "front page"
385
388
  ensure
386
- FileUtils.rm_rf(orig_mycook_app_root)
387
- @mycook.move(orig_mycook_app_root)
389
+ FileUtils.rm_rf(orig_app_root)
390
+ @stub.move(orig_app_root)
388
391
  end
389
392
  end
390
393
 
391
394
  it "supports encoded slashes in the URL if AllowEncodedSlashes is turned on" do
392
- @server = @mycook_url_root
393
- File.write("#{@mycook.app_root}/public/.htaccess", "PassengerAllowEncodedSlashes on")
394
- get('/welcome/show_id/foo%2fbar').should == 'foo/bar'
395
+ @server = @stub_url_root
396
+ get('/env/foo%2fbar').should =~ %r{PATH_INFO = /env/foo/bar\n}
397
+
398
+ @server = @stub2_url_root
399
+ get('/env/foo%2fbar').should =~ %r{404 Not Found}
395
400
  end
396
401
 
397
402
  describe "when handling POST requests with 'chunked' transfer encoding, if PassengerBufferUpload is off" do
@@ -430,62 +435,41 @@ describe "Apache 2 module" do
430
435
  FileUtils.mkdir_p('tmp.webdir')
431
436
  @webdir = File.expand_path('tmp.webdir')
432
437
  @apache2.set_vhost('1.passenger.test', @webdir) do |vhost|
433
- vhost << "RailsBaseURI /app-with-nonexistant-rails-version/public"
434
438
  vhost << "RailsBaseURI /app-that-crashes-during-startup/public"
435
439
  end
436
440
 
437
- @mycook = ClassicRailsStub.new('rails2.3-mycook')
438
- @mycook_url_root = "http://2.passenger.test:#{@apache2.port}"
439
- @apache2.set_vhost('2.passenger.test', "#{@mycook.full_app_root}/public")
441
+ @stub = RackStub.new('rack')
442
+ @stub_url_root = "http://2.passenger.test:#{@apache2.port}"
443
+ @apache2.set_vhost('2.passenger.test', "#{@stub.full_app_root}/public")
440
444
 
441
445
  @apache2.start
442
446
  end
443
447
 
444
448
  after :all do
445
449
  FileUtils.rm_rf('tmp.webdir')
446
- @mycook.destroy
450
+ @stub.destroy
447
451
  @apache2.stop if @apache2
448
452
  end
449
453
 
450
454
  before :each do
451
455
  @server = "http://1.passenger.test:#{@apache2.port}"
452
456
  @error_page_signature = /<meta name="generator" content="Phusion Passenger">/
453
- @mycook.reset
454
- end
455
-
456
- it "displays an error page if the Rails application requires a nonexistant Rails version" do
457
- ClassicRailsStub.use('rails2.3', "#{@webdir}/app-with-nonexistant-rails-version") do |stub|
458
- File.write(stub.environment_rb) do |content|
459
- content.sub(/^RAILS_GEM_VERSION = .*$/, "RAILS_GEM_VERSION = '1.9.1234'")
460
- end
461
- get("/app-with-nonexistant-rails-version/public").should =~ @error_page_signature
462
- end
457
+ @stub.reset
463
458
  end
464
459
 
465
- it "displays an error page if the Rails application crashes during startup" do
466
- ClassicRailsStub.use('rails2.3', "#{@webdir}/app-that-crashes-during-startup") do |stub|
467
- File.prepend(stub.environment_rb, "raise 'app crash'")
460
+ it "displays an error page if the application crashes during startup" do
461
+ RackStub.use('rack', "#{@webdir}/app-that-crashes-during-startup") do |stub|
462
+ File.prepend(stub.startup_file, "raise 'app crash'")
468
463
  result = get("/app-that-crashes-during-startup/public")
469
464
  result.should =~ @error_page_signature
470
465
  result.should =~ /app crash/
471
466
  end
472
467
  end
473
468
 
474
- it "displays an error if a filesystem permission error was encountered while autodetecting the application type" do
475
- @server = @mycook_url_root
476
- # This test used to fail because we were improperly blocking mod_autoindex,
477
- # resulting in it displaying a directory index before we could display an
478
- # error message.
479
- File.chmod(0000, "#{@mycook.app_root}/config")
480
- # Don't let mod_rewrite kick in so that mod_autoindex has a chance to run.
481
- File.unlink("#{@mycook.app_root}/public/.htaccess")
482
- get('/').should =~ /Please fix the relevant file permissions/
483
- end
484
-
485
469
  it "doesn't display a Ruby spawn error page if PassengerFriendlyErrorPages is off" do
486
- ClassicRailsStub.use('rails2.3', "#{@webdir}/app-that-crashes-during-startup") do |stub|
470
+ RackStub.use('rack', "#{@webdir}/app-that-crashes-during-startup") do |stub|
487
471
  File.write("#{stub.app_root}/public/.htaccess", "PassengerFriendlyErrorPages off")
488
- File.prepend(stub.environment_rb, "raise 'app crash'")
472
+ File.prepend(stub.startup_file, "raise 'app crash'")
489
473
  result = get("/app-that-crashes-during-startup/public")
490
474
  result.should_not =~ @error_page_signature
491
475
  result.should_not =~ /app crash/
@@ -498,27 +482,27 @@ describe "Apache 2 module" do
498
482
 
499
483
  before :all do
500
484
  create_apache2_controller
501
- @mycook = ClassicRailsStub.new('rails2.3-mycook')
502
- @mycook_url_root = "http://1.passenger.test:#{@apache2.port}"
503
- @apache2.set_vhost('1.passenger.test', "#{@mycook.full_app_root}/public")
485
+ @stub = RackStub.new('rack')
486
+ @stub_url_root = "http://1.passenger.test:#{@apache2.port}"
487
+ @apache2.set_vhost('1.passenger.test', "#{@stub.full_app_root}/public")
504
488
  @apache2.start
505
489
  @server = "http://1.passenger.test:#{@apache2.port}"
506
490
  end
507
491
 
508
492
  after :all do
509
- @mycook.destroy
493
+ @stub.destroy
510
494
  @apache2.stop if @apache2
511
495
  end
512
496
 
513
497
  before :each do
514
- @mycook.reset
498
+ @stub.reset
515
499
  end
516
500
 
517
501
  it "is restarted if it crashes" do
518
502
  # Make sure that all Apache worker processes have connected to
519
503
  # the helper server.
520
504
  10.times do
521
- get('/welcome').should =~ /Welcome to MyCook/
505
+ get('/').should == "front page"
522
506
  sleep 0.1
523
507
  end
524
508
 
@@ -530,14 +514,14 @@ describe "Apache 2 module" do
530
514
  # Each worker process should detect that the old
531
515
  # helper server has died, and should reconnect.
532
516
  10.times do
533
- get('/welcome').should =~ /Welcome to MyCook/
517
+ get('/').should == "front page"
534
518
  sleep 0.1
535
519
  end
536
520
  end
537
521
 
538
522
  it "exposes the application pool for passenger-status" do
539
- File.touch("#{@mycook.app_root}/tmp/restart.txt", 1) # Get rid of all previous app processes.
540
- get('/welcome').should =~ /Welcome to MyCook/
523
+ File.touch("#{@stub.app_root}/tmp/restart.txt", 1) # Get rid of all previous app processes.
524
+ get('/').should == "front page"
541
525
  instance = AdminTools::ServerInstance.list.first
542
526
 
543
527
  # Wait until the server has processed the session close event.
@@ -547,7 +531,7 @@ describe "Apache 2 module" do
547
531
  instance.processes(client)
548
532
  end
549
533
  processes.should have(1).item
550
- processes[0].group.name.should == @mycook.full_app_root + "#default"
534
+ processes[0].group.name.should == @stub.full_app_root + "#default"
551
535
  processes[0].processed.should == 1
552
536
  end
553
537
  end