passenger 4.0.45 → 4.0.46

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 (94) hide show
  1. checksums.yaml +8 -8
  2. checksums.yaml.gz.asc +7 -7
  3. data.tar.gz.asc +7 -7
  4. data/.editorconfig +19 -0
  5. data/CHANGELOG +47 -0
  6. data/CONTRIBUTING.md +9 -1
  7. data/CONTRIBUTORS +4 -0
  8. data/Vagrantfile +7 -3
  9. data/build/agents.rb +1 -0
  10. data/build/misc.rb +6 -4
  11. data/dev/vagrant/bashrc +2 -0
  12. data/doc/Design and Architecture.txt +9 -7
  13. data/doc/Users guide Apache.idmap.txt +2 -0
  14. data/doc/Users guide Apache.txt +24 -4
  15. data/doc/Users guide Nginx.idmap.txt +4 -0
  16. data/doc/Users guide Nginx.txt +23 -4
  17. data/doc/images/code_walkthrough.jpg +0 -0
  18. data/doc/users_guide_snippets/installation.txt +38 -0
  19. data/ext/common/AgentsStarter.h +6 -1
  20. data/ext/common/ApplicationPool2/Common.h +17 -2
  21. data/ext/common/ApplicationPool2/DirectSpawner.h +5 -11
  22. data/ext/common/ApplicationPool2/DummySpawner.h +2 -4
  23. data/ext/common/ApplicationPool2/ErrorRenderer.h +119 -0
  24. data/ext/common/ApplicationPool2/Implementation.cpp +159 -11
  25. data/ext/common/ApplicationPool2/Options.h +16 -7
  26. data/ext/common/ApplicationPool2/Pool.h +28 -24
  27. data/ext/common/ApplicationPool2/Process.h +1 -9
  28. data/ext/common/ApplicationPool2/SmartSpawner.h +15 -18
  29. data/ext/common/ApplicationPool2/Spawner.h +18 -14
  30. data/ext/common/ApplicationPool2/SpawnerFactory.h +12 -30
  31. data/ext/common/Constants.h +1 -1
  32. data/ext/common/Exceptions.h +15 -2
  33. data/ext/common/UnionStation/Core.h +9 -0
  34. data/ext/common/Utils/JsonUtils.h +53 -0
  35. data/ext/common/Utils/ProcessMetricsCollector.h +1 -1
  36. data/ext/common/Utils/SpeedMeter.h +7 -3
  37. data/ext/common/Utils/SystemMetricsCollector.h +8 -6
  38. data/ext/common/agents/HelperAgent/Main.cpp +4 -4
  39. data/ext/common/agents/HelperAgent/RequestHandler.h +115 -56
  40. data/ext/nginx/ConfigurationCommands.c +1 -1
  41. data/ext/nginx/ConfigurationCommands.c.erb +6 -1
  42. data/ext/nginx/ContentHandler.c +2 -1
  43. data/ext/nginx/config +1 -1
  44. data/helper-scripts/node-loader.js +23 -0
  45. data/helper-scripts/wsgi-loader.py +12 -4
  46. data/lib/phusion_passenger.rb +1 -1
  47. data/lib/phusion_passenger/active_support3_extensions/init.rb +39 -78
  48. data/lib/phusion_passenger/constants.rb +3 -1
  49. data/lib/phusion_passenger/loader_shared_helpers.rb +10 -5
  50. data/lib/phusion_passenger/nginx/config_options.rb +3 -1
  51. data/lib/phusion_passenger/packaging.rb +1 -0
  52. data/lib/phusion_passenger/public_api.rb +108 -16
  53. data/lib/phusion_passenger/rack/thread_handler_extension.rb +1 -0
  54. data/lib/phusion_passenger/request_handler.rb +2 -2
  55. data/lib/phusion_passenger/request_handler/thread_handler.rb +28 -46
  56. data/lib/phusion_passenger/standalone/command.rb +8 -1
  57. data/lib/phusion_passenger/standalone/main.rb +0 -1
  58. data/lib/phusion_passenger/standalone/start_command.rb +4 -0
  59. data/lib/phusion_passenger/union_station/connection.rb +67 -0
  60. data/lib/phusion_passenger/{analytics_logger.rb → union_station/core.rb} +55 -256
  61. data/lib/phusion_passenger/union_station/transaction.rb +168 -0
  62. data/lib/phusion_passenger/utils.rb +4 -0
  63. data/lib/phusion_passenger/utils/lock.rb +62 -0
  64. data/resources/mime.types +1 -0
  65. data/resources/templates/error_layout.html.template +2 -0
  66. data/resources/templates/standalone/config.erb +1 -0
  67. data/test/cxx/ApplicationPool2/DirectSpawnerTest.cpp +5 -3
  68. data/test/cxx/ApplicationPool2/PoolTest.cpp +13 -3
  69. data/test/cxx/ApplicationPool2/SmartSpawnerTest.cpp +16 -13
  70. data/test/cxx/ApplicationPool2/SpawnerTestCases.cpp +6 -0
  71. data/test/cxx/FileBackedPipeTest.cpp +1 -1
  72. data/test/cxx/RequestHandlerTest.cpp +158 -2
  73. data/test/cxx/ServerInstanceDirTest.cpp +2 -0
  74. data/test/cxx/TestSupport.h +21 -2
  75. data/test/cxx/UtilsTest.cpp +1 -0
  76. data/test/ruby/classic_rails/loader_spec.rb +0 -1
  77. data/test/ruby/classic_rails/preloader_spec.rb +0 -1
  78. data/test/ruby/rails3.0/loader_spec.rb +2 -2
  79. data/test/ruby/rails3.0/preloader_spec.rb +2 -2
  80. data/test/ruby/rails3.1/loader_spec.rb +2 -2
  81. data/test/ruby/rails3.1/preloader_spec.rb +2 -2
  82. data/test/ruby/rails3.2/loader_spec.rb +2 -2
  83. data/test/ruby/rails3.2/preloader_spec.rb +2 -2
  84. data/test/ruby/rails4.0/loader_spec.rb +2 -2
  85. data/test/ruby/rails4.0/preloader_spec.rb +2 -2
  86. data/test/ruby/request_handler_spec.rb +8 -8
  87. data/test/ruby/shared/rails/{analytics_logging_extensions_sharedspec.rb → union_station_extensions_sharedspec.rb} +5 -4
  88. data/test/ruby/union_station_spec.rb +283 -0
  89. data/test/stub/wsgi/passenger_wsgi.py +41 -5
  90. metadata +12 -7
  91. metadata.gz.asc +7 -7
  92. data/helper-scripts/wsgi-preloader.py +0 -1
  93. data/lib/phusion_passenger/standalone/package_runtime_command.rb +0 -105
  94. data/test/ruby/analytics_logger_spec.rb +0 -283
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OTQxZWYyOGY1YmIzMDg1MjllZTY3YzNkZmE0ZWIwZTE2NWI5MjdjZg==
4
+ NTMzMjIwYzg3NGQxMTFmZDllM2ExZGU0MmUyM2E2MGFjODU0MDQyNQ==
5
5
  data.tar.gz: !binary |-
6
- ODI1MDFmYzg5YWQyMjU4MzQ4MmU3MmJjNzM4MTAzN2M4OTY0M2I0MQ==
6
+ MTM5NmRmMWQyYz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UrWqlHo0z
8
- aOrJzsh/KS2Jr0694elf+uMmn3AKnqbPU4neGliOIeiSHM2LO36WSaBOZiagiWXK
9
- Eti3XYSmClE8tFOUmjdVfHJAom0UrBCTFUI6UhBPFuyq1bdUcbNcnKT9hKClphjL
10
- jYpx3G1iCuacbCMbF93LHxN3wh4U0f0hkW41Sirz/P7ItT4Ieet3hOg95OZkiv8=
11
- =Y+ZE
5
+ iQEcBAABAgAGBQJTxCOxAAoJECrHRaUKISqMCdsIAKR9HnGsLlsxmpu0zMWExqVb
6
+ dHyyHP/ckMjqEsJs1jeS0iYniI59IxCLfcMCG0lYf0tLR1OSRbnTUSuDG7JQeKfN
7
+ sA1OZ7i8UNPbFEhmzN/xAqmxioCNY0C85vPpUk4Vff11oLRmXN/YOKHKL0ukZIJs
8
+ eaN9U+I+KtKCLkst5afwuzNlRMxDMxKnArdoWVD16iFbltMxHH+2l2wYF/APt4JS
9
+ NAzBGbweQ8xi/7p1+ReVDG617Imh5aUt0tNEwlSbTS4P+fHObL4FaVPcVzzDGi17
10
+ DxNCiqErNYCjEsy+6F4CjWPgO9fZ+IcwYqAk9NaW3z3ZrlQSK9F+hB+fiCalCRA=
11
+ =BldL
12
12
  -----END PGP SIGNATURE-----
@@ -0,0 +1,19 @@
1
+ # http://EditorConfig.org
2
+
3
+ root = true
4
+
5
+ [*]
6
+ end_of_line = lf
7
+ charset = utf-8
8
+
9
+ [{*.cpp,*.c,*.h,*.hpp,*.rb,*.js}]
10
+ indent_style = tab
11
+ indent_size = 4
12
+ trim_trailing_whitespace = true
13
+
14
+ [{*.cpp,*.c,*.h,*.hpp}]
15
+ insert_final_newline = true
16
+
17
+ [ext/nginx/{*.c,*.h}]
18
+ indent_style = space
19
+ indent_size = 4
data/CHANGELOG CHANGED
@@ -1,3 +1,50 @@
1
+ Release 4.0.46
2
+ --------------
3
+
4
+ * Further improved Node.js and Socket.io compatibility.
5
+ * Sticky session cookies have been made more reliable.
6
+ * Fixed WebSocket upgrade issues on Firefox. Closes GH-1232.
7
+ * The Python application loader now inserts the application root into `sys.path`.
8
+ The fact that this was not done previously caused a lot of confusion amongst
9
+ Python users, who wondered why their `passenger_wsgi.py` could not import any
10
+ modules from the same directory.
11
+ * Fixed a compatibility problem with Django, which could cause Django apps to
12
+ freeze indefinitely. Closes GH-1215.
13
+ * Logging of application spawning errors has been much improved. Full details
14
+ about the error, such as environment variables, are saved to a private log file.
15
+ In the past, these details were only viewable in the browser. This change also
16
+ fixes a bug on Phusion Passenger Enterprise, where enabling Deployment Error
17
+ Resistance causes error messages to get lost. Closes GH-1021 and GH-1175.
18
+ * Fixed a regression in Node.js support. When a Node.js app is deployed on
19
+ a HTTPS host, the `X-Forwarded-Proto` header wasn't set in 4.0.45.
20
+ Closes GH-1231.
21
+ * Passenger Standalone no longer, by default, loads shell startup files before
22
+ loading the application. This is because Passenger Standalone is often invoked
23
+ from the shell anyway. Indeed, loading shell startup files again can interfere
24
+ with any environment variables already set in the invoking shell. You can
25
+ still tell Passenger Standalone to load shell startup files by passing
26
+ `--load-shell-envvars`. Passenger for Apache and Passenger for Nginx still
27
+ load shell startup files by default.
28
+ * Passenger Standalone now works properly when the HOME environment variable
29
+ isn't set. Closes GH-713.
30
+ * Passenger Standalone's `package-runtime` command has been removed. It has
31
+ been broken for a while and has nowadays been obsolete by our automatic
32
+ [binary generation system](https://github.com/phusion/passenger_autobuilder).
33
+ Closes GH-1133.
34
+ * The `passenger_startup_file` option now also works on Python apps. Closes GH-1233.
35
+ * If you are a [Union Station](https://www.unionstationapp.com) customer, then
36
+ Phusion Passenger will now also log application spawning errors to Union Station.
37
+ This data isn't shown in the Union Station interface yet, but it will be
38
+ implemented in the future.
39
+ * Fixed compilation problems on OmniOS and OpenIndiana. Closes GH-1212.
40
+ * Fixed compilation problems when Nginx is configured with OpenResty.
41
+ Thanks to Yichun Zhang. Closes GH-1226.
42
+ * Fixed Nginx HTTP POST failures on ARM platforms. Thanks to nocelic for the fix.
43
+ Closes GH-1151.
44
+ * Documentation contributions by Tim Bishop and Tugdual de Kerviler.
45
+ * Minor Nginx bug fix by Feng Gu. Closes GH-1235.
46
+
47
+
1
48
  Release 4.0.45
2
49
  --------------
3
50
 
@@ -9,6 +9,7 @@
9
9
  * [Contributing code](#contrib_code)
10
10
  * [Developer QuickStart](#dev_quickstart)
11
11
  * [Design and Architecture](#design_and_architecture)
12
+ * [Code Walkthrough](#code_walkthrough)
12
13
  * [Compilation and build system](#build_system)
13
14
  * [Running the unit tests](#unit_tests)
14
15
  * [Directory structure](#dir_structure)
@@ -97,6 +98,13 @@ We provide an easy and convenient development environment that contributors can
97
98
 
98
99
  Phusion Passenger's design and architecture is documented in detail in the [Design & Architecture](https://www.phusionpassenger.com/documentation/Design%20and%20Architecture.html) document.
99
100
 
101
+ <a name="code_walkthrough"></a>
102
+ ### Code Walkthrough
103
+
104
+ <a href="http://vimeo.com/phusionnl/review/98027409/03ba678684"><img src="http://blog.phusion.nl/wp-content/uploads/2014/06/code_walkthrough.png"></a>
105
+
106
+ We have [a video](http://vimeo.com/phusionnl/review/98027409/03ba678684) which walks you through the Phusion Passenger codebase, showing you step-by-step how things fit together. It complements the [Design & Architecture](https://www.phusionpassenger.com/documentation/Design%20and%20Architecture.html) document.
107
+
100
108
  <a name="build_system"></a>
101
109
  ### Compilation and build system
102
110
 
@@ -112,7 +120,7 @@ It is recommended that you install ccache and set the `USE_CCACHE=1` environment
112
120
  <a name="unit_tests"></a>
113
121
  ### Running the unit tests
114
122
 
115
- The tests depend on the Phusion Passenger developer tools. Make sure they're installed:
123
+ The tests depend on the Phusion Passenger developer tools. If you're not using our [Vagrant environment](https://github.com/phusion/passenger/blob/master/doc/DeveloperQuickstart.md), you need to make sure they're installed:
116
124
 
117
125
  rake test:install_deps
118
126
 
@@ -65,10 +65,14 @@ Ryan Schwartz
65
65
  Ryo Onodera
66
66
  Saimon Moore
67
67
  Sam Pohlenz
68
+ Sean Wilkinson
68
69
  Sebastian Delmont
69
70
  Slippy Douglas
71
+ Tim Bishop
70
72
  Tim Carey-Smith
71
73
  Tinco Andringa (Phusion)
74
+ Tugdual de Kerviler
72
75
  W. Andrew Loe III
73
76
  Weyert de Boer
77
+ Yichun Zhang
74
78
  亀田 義裕
@@ -1,4 +1,6 @@
1
- # This Vagrantfile sets up an Ubuntu VM, for the purpose of developing Phusion Passenger.
1
+ # This Vagrantfile sets up an Ubuntu VM, for the purpose of developing Phusion Passenger itself.
2
+ # It is NOT for setting up a Vagrant VM for the purpose of developing your own app. See:
3
+ # https://github.com/phusion/passenger/issues/1230#issuecomment-48337881
2
4
 
3
5
  # Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
4
6
  VAGRANTFILE_API_VERSION = "2"
@@ -11,6 +13,10 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
11
13
  config.vm.box_url = "https://oss-binaries.phusionpassenger.com/vagrant/boxes/latest/ubuntu-14.04-amd64-vbox.box"
12
14
  config.ssh.forward_agent = true
13
15
 
16
+ # Use NFS to mount /vagrant because our unit tests expect a
17
+ # POSIX compliant filesystem.
18
+ config.vm.synced_folder ".", "/vagrant", :type => "nfs"
19
+
14
20
  # Passenger Standalone and 'rails server'
15
21
  config.vm.network :forwarded_port, :host => 3000, :guest => 3000
16
22
  config.vm.network :forwarded_port, :host => 3001, :guest => 3001
@@ -33,9 +39,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
33
39
  config.vm.network :forwarded_port, :host => 8110, :guest => 8110
34
40
 
35
41
  config.vm.provider :virtualbox do |vb, override|
36
- # VirtualBox shared folders are WAAAAY too slow
37
42
  override.vm.network :private_network, :type => "dhcp"
38
- override.vm.synced_folder ".", "/vagrant", :type => "nfs"
39
43
  vb.cpus = CPUS
40
44
  vb.memory = MEMORY
41
45
  end
@@ -84,6 +84,7 @@ dependencies = [
84
84
  'ext/common/ApplicationPool2/SpawnerFactory.h',
85
85
  'ext/common/ApplicationPool2/SmartSpawner.h',
86
86
  'ext/common/ApplicationPool2/DirectSpawner.h',
87
+ 'ext/common/ApplicationPool2/ErrorRenderer.h',
87
88
  LIBBOOST_OXT,
88
89
  helper_agent_libs.link_objects,
89
90
  LIBEV_TARGET,
@@ -94,9 +94,9 @@ task :changelog_as_html do
94
94
  end
95
95
 
96
96
  # Auto-link to issue tracker.
97
- text.gsub!(/(bug|issue) #(\d+)/i) do
97
+ text.gsub!(/(bug #|issue #|GH-)(\d+)/i) do
98
98
  url = "https://github.com/phusion/passenger/issues/#{$2}"
99
- %Q(<{a href="#{url}"}>#{$1} ##{$2}<{/a}>)
99
+ %Q(<{a href="#{url}"}>#{$1}#{$2}<{/a}>)
100
100
  end
101
101
 
102
102
  text.strip!
@@ -117,9 +117,9 @@ task :changelog_as_markdown do
117
117
  contents, items = extract_latest_news_contents_and_items
118
118
 
119
119
  # Auto-link to issue tracker.
120
- contents.gsub!(/(bug|issue) #(\d+)/i) do
120
+ contents.gsub!(/(bug #|issue #|GH-)(\d+)/i) do
121
121
  url = "https://github.com/phusion/passenger/issues/#{$2}"
122
- %Q([#{$1} ##{$2}](#{url}))
122
+ %Q([#{$1}#{$2}](#{url}))
123
123
  end
124
124
 
125
125
  puts contents
@@ -139,6 +139,8 @@ task :contributors do
139
139
  entries.push "Goffert van Gool (Phusion)"
140
140
  entries.delete "Gokulnath"
141
141
  entries.push "Gokulnath Manakkattil"
142
+ entries.push "Sean Wilkinson"
143
+ entries.push "Yichun Zhang"
142
144
  File.open("CONTRIBUTORS", "w") do |f|
143
145
  f.puts(entries.sort{ |a, b| a.downcase <=> b.downcase }.join("\n"))
144
146
  end
@@ -15,6 +15,8 @@ export CCACHE_COMPRESS=1
15
15
  # Tell Phusion Passenger Standalone to run in debug mode.
16
16
  export PASSENGER_DEBUG=1
17
17
 
18
+ export PASSENGER_VAGRANT_ENVIRONMENT=1
19
+
18
20
  alias ls='ls -Fh --color'
19
21
  alias dir='ls -l'
20
22
  alias free='free -m'
@@ -2,10 +2,12 @@
2
2
 
3
3
  image:images/phusion_banner.png[link="http://www.phusion.nl/"]
4
4
 
5
- This guide describes Phusion Passenger's design and architecture in detail. With this guide, we hope that contributors can quickly find their way around the Phusion Passenger codebase.
5
+ This guide describes link:https://www.phusionpassenger.com/[Phusion Passenger]'s design and architecture in detail. With this guide, we hope that contributors can quickly find their way around the Phusion Passenger codebase.
6
6
 
7
7
  The guide assumes that you're familiar with using Phusion Passenger and with Nginx or Apache, and that you've read the link:https://github.com/phusion/passenger/blob/master/CONTRIBUTING.md[Contributors Guide] and the link:https://github.com/phusion/passenger/blob/master/doc/DeveloperQuickstart.md[Developer QuickStart].
8
8
 
9
+ image:images/code_walkthrough.jpg[link="http://vimeo.com/phusionnl/review/98027409/03ba678684"] +
10
+ 'You should also watch the complementary video: link:http://vimeo.com/phusionnl/review/98027409/03ba678684[Phusion Passenger Code Walkthrough]'
9
11
 
10
12
  == Introduction
11
13
 
@@ -191,9 +193,9 @@ If the ApplicationPool replied with an exception, the RequestHandler sends back
191
193
 
192
194
  ==== I/O model
193
195
 
194
- The RequestHandler uses the **evented I/O model**. This means that the RequestHandler handles many clients (requests) at the same time, using a single thread, inside a single process. This is possible through the use of I/O event multiplexing mechanisms, which are provided by the OS. Examples of such mechanisms include the `select()`, `poll()`, `epoll()` and `kqueue()` system calls. But those mechanisms are very low-level and OS-specific, so the RequestHandler uses two libraries which abstract away the differences and provide a higher-level API, link:http://software.schmorp.de/pkg/libev.html[libev] and link:http://software.schmorp.de/pkg/libeio.html[libeio].
196
+ The RequestHandler uses the **evented I/O model**. This means that the RequestHandler handles many clients (requests) at the same time, using a single thread, inside a single process. This is possible through the use of I/O event multiplexing mechanisms, which are provided by the OS. Examples of such mechanisms include the `select()`, `poll()`, `epoll()` and `kqueue()` system calls. But those mechanisms are very low-level and OS-specific, so the RequestHandler uses two libraries which abstract away the differences and provide a higher-level API: link:http://software.schmorp.de/pkg/libev.html[libev] and link:http://software.schmorp.de/pkg/libeio.html[libeio].
195
197
 
196
- The evented I/O model is also used in Nginx. It is in contrast to the single-threaded multi-process model which handles 1 client per process (used by Apache with the prefork MPM), or the multi-threaded model which handles 1 client per thread (used by Apache with the worker MPM). You can learn more about evented I/O and the different I/O models using these resources:
198
+ The evented I/O model is also used in Nginx. It is in contrast to the single-threaded multi-process model which handles 1 client per process (used by Apache with the prefork MPM), or the multi-threaded model which handles 1 client per thread (used by Apache with the worker MPM). You can learn more about evented I/O and the different I/O models through these resources:
197
199
 
198
200
  * link:http://www.slideshare.net/marc.seeger/seeger-aysnc-io[Event-Driven I/O: A hands-on introduction] -- Marc Seeger, 2010
199
201
  * link:http://stackoverflow.com/questions/5807246/event-driven-io-and-blocking-vs-nonblocking[Event Driven IO And Blocking vs NonBlocking] -- Stack Overflow
@@ -211,11 +213,11 @@ The ApplicationPool subsystem is responsible for:
211
213
  * Enforcing resource limits. Ensuring that not too many processes are spawned, ensuring that processes that use too much memory are shut down, etc.
212
214
  * Restarting processes on demand (e.g. when the timestamp of `restart.txt` has changed).
213
215
  * Restarting processes that have crashed.
214
- * Queuing requests and limiting concurrency. Each process tells the ApplicationPool how many concurrent requests it can handle. If more concurrent requests come in than the processes say they can handle, then the excess requests are queued within the ApplicationPool subsystem. Similarly, if requests come in while a process is being spawned, then those requests are queued until the process is done spawning.
216
+ * Queuing requests and limiting concurrency. Each process tells the ApplicationPool how many concurrent requests it can handle. If more concurrent requests come in than the processes says it can handle, then the excess requests are queued within the ApplicationPool subsystem. Similarly, if requests come in while a process is being spawned, then those requests are queued until the process is done spawning.
215
217
 
216
218
  The main interface into the subsystem is the Pool class, with its `asyncGet()` method. The RequestHandler calls something like `pool->asyncGet(options, callback)` inside its `checkoutSession()` method. `asyncGet()` replies with a Session, or an exception.
217
219
 
218
- Pool is the core of the subsystem. It contains high-level process management logic but not the low-level details of spawning processes. The code is further divided into the following classes, each of which contain the core code managing its respective domain:
220
+ The Pool class is the core of the subsystem. It contains high-level process management logic but not low-level details, such as the details of spawning processes. The code is further divided into the following classes, each of which contain the core code managing its respective domain:
219
221
 
220
222
  **SuperGroup**::
221
223
  A logical collection of different applications. It's designed to be able to contain one or more Groups, but currently it always contains exactly 1 Group.
@@ -478,13 +480,13 @@ Information about the supported application types, startup files, loaders and pr
478
480
  [[instance_state_and_communication]]
479
481
  == Instance state and communication
480
482
 
481
- Every time you start Phusion Passenger, you've created a new *instance*. Every instance consists of multiple processes that work together (Watchdog, HelperAgent, LoggingAgent, application processes). All those processes have to work together and have to be able to communicate with each other. Those processes must also *not* communicate with the processes belonging to other instances. For example, if you start Apache+Passenger *and Nginx+Passenger, then we don't want the HelperAgent that's started from Apache to use LoggingAgent that's started from Nginx.
483
+ Every time you start Phusion Passenger, you've created a new *instance*. Every instance consists of multiple processes that work together (Watchdog, HelperAgent, LoggingAgent, application processes). All those processes have to be able to communicate with each other. Those processes must also *not* communicate with the processes belonging to other instances. For example, if you start Apache+Passenger *and* Nginx+Passenger, then we don't want the HelperAgent that's started from Apache to use LoggingAgent that's started from Nginx.
482
484
 
483
485
  Clearly, the processes can't listen on a specific TCP port for communication. Nor can they listen on a fixed Unix domain socket filename.
484
486
 
485
487
  That is where the 'server instance directory' comes in. Every Phusion Passenger instance has its own, unique temporary directory. That directory is removed when the instance halts. The directory contains Unix domain socket files that the processes listen on. Every Phusion Passenger related process knows where its own server instance directory is, and thus, knows how to communicate with other processes belonging to the same instance. The server instance directory is implemented in `ext/common/ServerInstanceDir.h`.
486
488
 
487
- Administration tools such as `passenger-status` query information using server instance directories. First, they check which server instance directories exist on the system. If they find only one, then they query the sockets inside that sole server instance directory. Otherwise, they abort with an error and asks the user to specifically select the instance to query.
489
+ Administration tools such as `passenger-status` query information using server instance directories. First, they check which server instance directories exist on the system. If they find only one, then they query the sockets inside that sole server instance directory. Otherwise, they abort with an error and ask the user to specifically select the instance to query.
488
490
 
489
491
 
490
492
  [appendix]
@@ -120,6 +120,8 @@
120
120
 
121
121
  5.4. Redeploying (restarting the WSGI application) => redeploying-restarting-the-wsgi-application--na7pmf
122
122
 
123
+ 5.5. Sample passenger_wsgi.py for Django => sample-passenger-wsgi-py-for-django-slb9m8
124
+
123
125
  6. Deploying a Node.js application => deploying-a-node-js-application-882ecy
124
126
 
125
127
  7. Deploying a Meteor application => deploying-a-meteor-application-mxfmir
@@ -380,7 +380,7 @@ So '/webapps/wsgiapp' must, at minimum, look like this:
380
380
  ----------------------
381
381
  /webapps/wsgiapp
382
382
  |
383
- +-- config.ru
383
+ +-- passenger_wsgi.py
384
384
  |
385
385
  +-- public/
386
386
  |
@@ -540,6 +540,19 @@ command line:
540
540
  touch /webapps/wsgiapp/tmp/restart.txt
541
541
  -------------------------------------------
542
542
 
543
+ === Sample `passenger_wsgi.py` for Django
544
+
545
+ For Django applications, `passenger_wsgi.py` should look like this:
546
+
547
+ [code,python]
548
+ -------------------------------------------
549
+ import myproject.wsgi
550
+ application = myproject.wsgi.application
551
+ -------------------------------------------
552
+
553
+ Replace `myproject` with your project's module name.
554
+
555
+
543
556
  == Deploying a Node.js application
544
557
 
545
558
  Please refer to link:https://github.com/phusion/passenger/wiki/Phusion-Passenger%3A-Node.js-tutorial[the Node.js tutorial].
@@ -557,10 +570,17 @@ Nevertheless, the system administrator may be interested in changing
557
570
  Phusion Passenger's behavior. Phusion Passenger's Apache module supports the
558
571
  following configuration options:
559
572
 
573
+ [[PassengerRoot]]
560
574
  === PassengerRoot <directory> ===
561
575
  The location to the Phusion Passenger root directory. This configuration option
562
576
  is essential to Phusion Passenger, and allows Phusion Passenger to locate its own
563
- data files. The correct value is given by the installer.
577
+ data files. If you do not set this option, or if you set this option to the wrong value, then Phusion Passenger will make Apache abort with an error.
578
+
579
+ While installing Phusion Passenger, you have been told to set this option in your Apache configuration file, and you have been told what value to set it to. So under normal conditions, you don't have ask yourself what value to set for this option. But in case you lost the value (e.g. because you accidentally removed the Apache configuration file, and you are trying to reconstruct it), or in case you didn't follow the installation instructions correctly, then here's how you can find out the correct value:
580
+
581
+ * If you installed Phusion Passenger through <<install_on_debian_ubuntu,our APT repository>>, then the value can be obtained by running `/usr/bin/passenger-config --root`.
582
+ * If you installed Phusion Passenger through RubyGems, then the value can be obtained by running `passenger-config --root`.
583
+ * If you installed Phusion Passenger through the source tarball, then the value is the path to the Phusion Passenger directory. For example, if you extracted the tarball's contents to `/opt/passenger/passenger-x.x.x`, then `passenger_root` must be `/opt/passenger/passenger-x.x.x`.
564
584
 
565
585
  If you've moved Phusion Passenger to a different directory then you need to update
566
586
  this option as well. Please read
@@ -1971,7 +1991,7 @@ In each place, it may be specified at most once. The default value is '100'.
1971
1991
 
1972
1992
  [[PassengerStickySessions]]
1973
1993
  ==== PassengerStickySessions <on|off>
1974
- :version: 4.0.55
1994
+ :version: 4.0.45
1975
1995
  include::users_guide_snippets/since_version.txt[]
1976
1996
 
1977
1997
  When sticky sessions are enabled, all requests that a client sends will be routed to the same originating application process, whenever possible. When sticky sessions are disabled, requests may be distributed over multiple processes, and may not necessarily be routed to the originating process, in order to balance traffic over multiple CPU cores. Because of this, sticky sessions should only be enabled in specific circumstances.
@@ -2002,7 +2022,7 @@ In each place, it may be specified at most once. The default value is `off`.
2002
2022
 
2003
2023
  [[PassengerStickySessionsCookieName]]
2004
2024
  ==== PassengerStickySessionsCookieName
2005
- :version: 4.0.55
2025
+ :version: 4.0.45
2006
2026
  include::users_guide_snippets/since_version.txt[]
2007
2027
 
2008
2028
  Sets the name of the <<PassengerStickySessions,sticky sessions>> cookie.
@@ -30,6 +30,8 @@
30
30
 
31
31
  2.3.2. Installing packages => installing-packages-j9glez
32
32
 
33
+ 2.3.3. Inserting passenger_root into nginx.conf => inserting-passenger-root-into-nginx-conf--1pmj19o
34
+
33
35
  2.4. Installing or upgrading on Red Hat, Fedora, CentOS or ScientificLinux => installing-or-upgrading-on-red-hat-fedora-centos-or-scientificlinux-1uus5a1
34
36
 
35
37
  2.5. Generic installation, upgrade and downgrade method: via RubyGems => generic-installation-upgrade-and-downgrade-method-via-rubygems-76uol7
@@ -120,6 +122,8 @@
120
122
 
121
123
  5.4. Redeploying (restarting the WSGI application) => redeploying-restarting-the-wsgi-application--10zdh2k
122
124
 
125
+ 5.5. Sample passenger_wsgi.py for Django => sample-passenger-wsgi-py-for-django-1cvndls
126
+
123
127
  6. Deploying a Node.js application => deploying-a-node-js-application-15wbczd
124
128
 
125
129
  7. Deploying a Meteor application => deploying-a-meteor-application-1b51wl9
@@ -350,7 +350,7 @@ So '/webapps/wsgiapp' must, at minimum, look like this:
350
350
  ----------------------
351
351
  /webapps/wsgiapp
352
352
  |
353
- +-- config.ru
353
+ +-- passenger_wsgi.py
354
354
  |
355
355
  +-- public/
356
356
  |
@@ -496,6 +496,18 @@ command line:
496
496
  touch /webapps/wsgiapp/tmp/restart.txt
497
497
  -------------------------------------------
498
498
 
499
+ === Sample `passenger_wsgi.py` for Django
500
+
501
+ For Django applications, `passenger_wsgi.py` should look like this:
502
+
503
+ [code,python]
504
+ -------------------------------------------
505
+ import myproject.wsgi
506
+ application = myproject.wsgi.application
507
+ -------------------------------------------
508
+
509
+ Replace `myproject` with your project's module name.
510
+
499
511
 
500
512
  == Deploying a Node.js application
501
513
 
@@ -514,10 +526,17 @@ Nevertheless, the system administrator may be interested in changing
514
526
  Phusion Passenger's behavior. Phusion Passenger supports the following configuration
515
527
  options in the Nginx configuration file:
516
528
 
529
+ [[PassengerRoot]]
517
530
  === passenger_root <directory> ===
518
531
  The location to the Phusion Passenger root directory. This configuration option
519
532
  is essential to Phusion Passenger, and allows Phusion Passenger to locate its own
520
- data files. The correct value is given by the installer.
533
+ data files. If you do not set this option, then Phusion Passenger will disable itself, and Nginx will behave as if Phusion Passenger was never installed. If you set this option to the wrong value, then Phusion Passenger will make Nginx abort with an error.
534
+
535
+ While installing Phusion Passenger, you have been told to set this option in your Nginx configuration file, and you have been told what value to set it to. So under normal conditions, you don't have ask yourself what value to set for this option. But in case you lost the value (e.g. because you accidentally removed the Nginx configuration file, and you are trying to reconstruct it), or in case you didn't follow the installation instructions correctly, then here's how you can find out the correct value:
536
+
537
+ * If you installed Phusion Passenger through <<install_on_debian_ubuntu,our APT repository>>, then follow the instructions in <<inserting_passenger_root_for_apt,Inserting `passenger_root` into nginx.conf>>.
538
+ * If you installed Phusion Passenger through RubyGems, then the value can be obtained by running `passenger-config --root`.
539
+ * If you installed Phusion Passenger through the source tarball, then the value is the path to the Phusion Passenger directory. For example, if you extracted the tarball's contents to `/opt/passenger/passenger-x.x.x`, then `passenger_root` must be `/opt/passenger/passenger-x.x.x`.
521
540
 
522
541
  If you've moved Phusion Passenger to a different directory then you need to update
523
542
  this option as well. Please read
@@ -1737,7 +1756,7 @@ In each place, it may be specified at most once. The default value is '503'.
1737
1756
 
1738
1757
  [[PassengerStickySessions]]
1739
1758
  ==== passenger_sticky_sessions <on|off>
1740
- :version: 4.0.55
1759
+ :version: 4.0.45
1741
1760
  include::users_guide_snippets/since_version.txt[]
1742
1761
 
1743
1762
  When sticky sessions are enabled, all requests that a client sends will be routed to the same originating application process, whenever possible. When sticky sessions are disabled, requests may be distributed over multiple processes, and may not necessarily be routed to the originating process, in order to balance traffic over multiple CPU cores. Because of this, sticky sessions should only be enabled in specific circumstances.
@@ -1768,7 +1787,7 @@ In each place, it may be specified at most once. The default value is `off`.
1768
1787
 
1769
1788
  [[PassengerStickySessionsCookieName]]
1770
1789
  ==== passenger_sticky_sessions_cookie_name
1771
- :version: 4.0.55
1790
+ :version: 4.0.45
1772
1791
  include::users_guide_snippets/since_version.txt[]
1773
1792
 
1774
1793
  Sets the name of the <<PassengerStickySessions,sticky sessions>> cookie.