Skip to content

Commit bf570ca

Browse files
committed
Add a USE_FASTBOOT=staging-experimental mode
1 parent 307930e commit bf570ca

File tree

2 files changed

+33
-15
lines changed

2 files changed

+33
-15
lines changed

config/nginx.conf.erb

+28-10
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ http {
107107

108108
upstream app_server {
109109
server localhost:8888 fail_timeout=0;
110-
}
110+
}
111111

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

133-
location / {
134-
proxy_pass http://app_server;
135-
}
136-
137-
<% if ENV['USE_FASTBOOT'] %>
138-
# Just in case, only forward "/policies" to Ember for a moment
139-
location = /policies {
140-
proxy_pass http://localhost:9000;
141-
}
133+
<% if ENV['USE_FASTBOOT'] == "staging-experimental" %>
134+
# Experimentally send all non-backend requests to FastBoot
135+
136+
location /api/ {
137+
proxy_pass http://app_server;
138+
}
139+
140+
# FastBoot
141+
location / {
142+
proxy_pass http://localhost:9000;
143+
}
144+
<% elsif ['USE_FASTBOOT'] %>
145+
# Fastboot is enabled only for allowed paths
146+
147+
location = /policies {
148+
proxy_pass http://localhost:9000;
149+
}
150+
151+
location / {
152+
proxy_pass http://app_server;
153+
}
154+
<% else %>
155+
# FastBoot is disabled, backend sends the static Ember index HTML for non-backend paths
156+
157+
location / {
158+
proxy_pass http://app_server;
159+
}
142160
<% end %>
143161

144162
location ~ ^/api/v./crates/new$ {

script/start-web.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#! /bin/bash
22
set -ue
33

4-
if [[ "${USE_FASTBOOT:-0}" = 1 ]]; then
5-
export USE_FASTBOOT=1
4+
if [[ -z "${USE_FASTBOOT}" ]]; then
5+
unset USE_FASTBOOT
6+
bin/start-nginx ./target/release/server
7+
else
8+
export USE_FASTBOOT
69
node --optimize_for_size --max_old_space_size=200 fastboot.js &
710
bin/start-nginx ./target/release/server &
811
wait -n
9-
else
10-
unset USE_FASTBOOT
11-
bin/start-nginx ./target/release/server
1212
fi

0 commit comments

Comments
 (0)