Skip to content

Commit

Permalink
Add a USE_FASTBOOT=staging-experimental mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jtgeibel committed Nov 23, 2019
1 parent 307930e commit bf570ca
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 15 deletions.
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
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

0 comments on commit bf570ca

Please sign in to comment.