Skip to content

Commit

Permalink
tidying frontend deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
allthingsclowd committed Sep 26, 2018
1 parent 4fd5880 commit 7299f9a
Show file tree
Hide file tree
Showing 16 changed files with 35 additions and 2,762 deletions.
15 changes: 0 additions & 15 deletions conf/nginx.ctpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,6 @@ server {
listen 9090 default_server;

location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
#
# Custom headers and headers various browsers *should* be OK with but aren't
#
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
#
# Tell client that this pre-flight info is valid for 20 days
#
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
proxy_pass http://goapp;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
Expand Down
15 changes: 11 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func main() {
r.HandleFunc("/", indexHandler).Methods("GET")
r.HandleFunc("/health", healthHandler).Methods("GET")
r.HandleFunc("/crash", crashHandler).Methods("POST")
r.HandleFunc("/crash", indexHandler).Methods("GET")
r.HandleFunc("/crash", optionsHandler).Methods("OPTIONS")
http.Handle("/", r)
http.ListenAndServe(portDetail.String(), r)

Expand Down Expand Up @@ -127,18 +127,25 @@ func healthHandler(w http.ResponseWriter, r *http.Request) {

}

func optionsHandler(w http.ResponseWriter, r *http.Request) {

enableCors(&w)
return

}

func crashHandler(w http.ResponseWriter, r *http.Request) {

enableCors(&w)
goapphealth = "FORCEDCRASH"
fmt.Printf("You Killed Me!!!!!! Application Status: %v \n", goapphealth)
goapphealth = "Killing service on port " + targetPort + "on server " + thisServer + "(" + targetIP + ")!"
fmt.Printf("Application Status: %v \n", goapphealth)
fmt.Fprintf(w, "%v", goapphealth)
dataDog := sendDataDogEvent("WebCounter Crashed", targetPort)
if !dataDog {
fmt.Printf("Failed to send datadog event.")
}
// added delay to ensure event is sent before process terminates
time.Sleep(2 * time.Second)
time.Sleep(3 * time.Second)
os.Exit(1)

}
Expand Down
25 changes: 24 additions & 1 deletion scripts/install_webserver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,30 @@ EOF
echo 'Register nginx service with Consul Service Discovery Complete'
}

sudo cp -R /usr/local/bootstrap/webclient/wpc-fe /var/www/wpc-fe
# Added loop below to overcome Travis-CI download issue
RETRYDOWNLOAD="1"

while [ ${RETRYDOWNLOAD} -lt 5 ] && [ ! -d /var/www/wpc-fe ]
do
pushd /tmp/wpc-fe
echo 'Web Front end Download'
# download binary and template file from latest release
sudo bash -c 'curl -s https://api.github.com/repos/allthingsclowd/wep_page_counter_front-end/releases/latest \
| grep "browser_download_url" \
| cut -d : -f 2,3 \
| tr -d \" | wget -i - '
sudo tar -xvf webcounterpagefrontend.tar.gz -C /var/www
popd
RETRYDOWNLOAD=$[${RETRYDOWNLOAD}+1]
sleep 5
done


[ -f /var/www/wpc-fe/index.html ] &>/dev/null || {
echo 'Web Front End Download Failed'
exit 1
}

sudo cp /usr/local/bootstrap/conf/wpc-fe.conf /etc/nginx/conf.d/wpc-fe.conf

# remove nginx default website
Expand Down
45 changes: 0 additions & 45 deletions webclient/wpc-fe/3rdpartylicenses.txt

This file was deleted.

Binary file removed webclient/wpc-fe/assets/HashiCorp_Icon_Black.png
Binary file not shown.
Binary file removed webclient/wpc-fe/favicon.ico
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 7299f9a

Please sign in to comment.