Closed Bug 1151803 Opened 10 years ago Closed 9 years ago

Serve the UI on Heroku and Vagrant using gunicorn/WhiteNoise instead of Apache

Categories

(Tree Management :: Treeherder: Infrastructure, defect, P2)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: emorley, Assigned: emorley)

References

Details

Attachments

(1 file)

Blocks: 1151806
No longer blocks: 1151806
Depends on: 1170805
Attachment #8623766 - Flags: review?(mdoglio)
Attachment #8623766 - Flags: review?(mdoglio) → review+
We'll need to also watch out for a Virtualbox shared folders bug with sendfile: https://www.virtualbox.org/ticket/9069 https://www.virtualbox.org/ticket/12597 gunicorn have added a param that we could use to disable using sendfile in just the Vagrant environment, if needed: https://github.com/benoitc/gunicorn/issues/856 https://github.com/benoitc/gunicorn/commit/2849147f8aeb990c4f55a168e3d32ec2167ca093
(In reply to Ed Morley [:emorley] from comment #2) > gunicorn have added a param that we could use to disable using sendfile in > just the Vagrant environment, if needed: Which is only in gunicorn >v19.2, so this bug depends on bug 1175478 (just in case).
Depends on: 1175478
Status: NEW → ASSIGNED
Summary: Figure out the best way to serve static assets in a Heroku deployment → Serve the UI using gunicorn/WhiteNoise instead of Apache
Summary: Serve the UI using gunicorn/WhiteNoise instead of Apache → Serve the UI on Heroku using gunicorn/WhiteNoise instead of Apache
Summary: Serve the UI on Heroku using gunicorn/WhiteNoise instead of Apache → Serve the UI on Heroku and Vagrant using gunicorn/WhiteNoise instead of Apache
Commits pushed to master at https://github.com/mozilla/treeherder https://github.com/mozilla/treeherder/commit/15911f5d77157a4bc7752bc1b5fa7653c6f13cc3 Bug 1151803 - Docs: Remove instructions on how to restart varnish The Varnish config uses |return (pass)| unconditionally, so never caches anything, so there's no need to suggest restarting it after making changes to the UI. https://github.com/mozilla/treeherder/commit/fca98929db38f8283b3f727cabc00e31657c7190 Bug 1151803 - Vagrant: Remove socketio remnant from Varnish config Leftover from bug 1076710. https://github.com/mozilla/treeherder/commit/4c827ab288e251f9335905d36ee38be9e126a395 Bug 1151803 - Vagrant: Stop using Varnish to gzip json/text Since we should be doing this using Django's GZip middleware, not in Varnish, which is only used in development. At least with this removed, we won't check a local instance and believe we have everything set up correctly if its not. https://github.com/mozilla/treeherder/commit/c3efa7c400e20a5a0c4b03745b66ab6a0530a65a Bug 1151803 - Docs: Clarify the UI build/dist explanation & steps Explains the reasoning behind the dist directory, and separates out the "updating the dist directory" and "testing the dist directory" steps. https://github.com/mozilla/treeherder/commit/bf4c7c05ff4b76da79fd41304b293323a383bfcc Bug 1151803 - Serve the UI using gunicorn/WhiteNoise instead of Apache In order that we can serve the UI on Heroku, we wrap the Django wsgi app with WhiteNoise, so both the UI and API requests are served by gunicorn. In the Vagrant environment, Apache has been removed and Varnish instead now proxies all requests to gunicorn/Django runserver directly, without Apache as a go-between. The UI on production will not be affected by this commit, since the Apache config there will still intercept requests for the UI assets rather than proxying them to gunicorn. It's worth noting too, that we're not able to make use of WhiteNoise's automatic Django GZip/caching support since that assumes we are using Django templates and referring to resources using {% static "foo.css" %} However, we can sub-class WhiteNoise (or more specifically the DjangoWhiteNoise class) and override the is_immutable_file() method to add caching support at a later date: http://whitenoise.evans.io/en/latest/base.html#caching-headers Documentation for WhiteNoise can be found at: http://whitenoise.evans.io/
Deployed to Heroku, UI now visible at: https://treeherder-heroku.herokuapp.com/
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
I should add: I've set SERVE_MINIFIED_UI to True on Heroku; if we wanted to get rid of Apache in production, we'd need to set SERVE_MINIFIED_UI in the environment there too.
One thing to bear in mind if working on the UI locally using Vagrant rather than web-server.js, is that WhiteNoise caches the list of files in the UI directory (for perf reasons), so if you add a new file, you'll need to restarting runserver/gunicorn for WhiteNoise to see the new file (modifications to existing files are fine).
s/restarting/restart/
Blocks: 1176482
Blocks: 1197796
Blocks: 1197799
Depends on: 1199812
No longer depends on: 1199812
Depends on: 1205653
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: