From bf570ca3b14ecb69ef248363f51365671a280e47 Mon Sep 17 00:00:00 2001 From: Justin Geibel Date: Fri, 15 Nov 2019 13:05:22 -0500 Subject: [PATCH] Add a `USE_FASTBOOT=staging-experimental` mode --- config/nginx.conf.erb | 38 ++++++++++++++++++++++++++++---------- script/start-web.sh | 10 +++++----- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/config/nginx.conf.erb b/config/nginx.conf.erb index 1067911f9f..3435fc6dc4 100644 --- a/config/nginx.conf.erb +++ b/config/nginx.conf.erb @@ -107,7 +107,7 @@ http { upstream app_server { server localhost:8888 fail_timeout=0; - } + } server { listen <%= ENV["PORT"] %>; @@ -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$ { diff --git a/script/start-web.sh b/script/start-web.sh index 47317d0867..dce52263cd 100755 --- a/script/start-web.sh +++ b/script/start-web.sh @@ -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