Skip to content

Add a USE_FASTBOOT=staging-experimental mode #1907

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 28 additions & 10 deletions config/nginx.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ http {

upstream app_server {
server localhost:8888 fail_timeout=0;
}
}

server {
listen <%= ENV["PORT"] %>;
Expand All @@ -130,15 +130,33 @@ http {
rewrite ^ https://$host$request_uri? permanent;
}

location / {
proxy_pass http://app_server;
}

<% if ENV['USE_FASTBOOT'] %>
# Just in case, only forward "/policies" to Ember for a moment
location = /policies {
proxy_pass http://localhost:9000;
}
<% if ENV['USE_FASTBOOT'] == "staging-experimental" %>
# Experimentally send all non-backend requests to FastBoot

location /api/ {
proxy_pass http://app_server;
}

# FastBoot
location / {
proxy_pass http://localhost:9000;
}
<% elsif ['USE_FASTBOOT'] %>
# Fastboot is enabled only for allowed paths

location = /policies {
proxy_pass http://localhost:9000;
}

location / {
proxy_pass http://app_server;
}
<% else %>
# FastBoot is disabled, backend sends the static Ember index HTML for non-backend paths

location / {
proxy_pass http://app_server;
}
<% end %>

location ~ ^/api/v./crates/new$ {
Expand Down
6 changes: 3 additions & 3 deletions script/ember.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ set -ue

export FASTBOOT_DISABLED

if [ "${USE_FASTBOOT:-0}" = '1' ]; then
unset FASTBOOT_DISABLED
else
if [ -z "${USE_FASTBOOT-}" ]; then
FASTBOOT_DISABLED=1
else
unset FASTBOOT_DISABLED
fi

ember "$@"
10 changes: 5 additions & 5 deletions script/start-web.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#! /bin/bash
set -ue

if [[ "${USE_FASTBOOT:-0}" = 1 ]]; then
export USE_FASTBOOT=1
if [[ -z "${USE_FASTBOOT-}" ]]; then
unset USE_FASTBOOT
bin/start-nginx ./target/release/server
else
export USE_FASTBOOT
node --optimize_for_size --max_old_space_size=200 fastboot.js &
bin/start-nginx ./target/release/server &
wait -n
else
unset USE_FASTBOOT
bin/start-nginx ./target/release/server
fi