Skip to content
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
13 changes: 4 additions & 9 deletions codefresh/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,10 @@ steps:
working_directory: /deploy/
commands:
# Announce the release version
- "echo 'Preparing to deploy version ${{CF_RELEASE_TAG}}'"
# Fetch the build-harness
- "curl -sSL -o Makefile https://git.io/build-harness"
# Initialize the build-harness
- "make init"
# Install or upgrade tiller
- "make helm/toolbox/upsert"
# Deploy chart to cluster using helmfile
- "helmfile --namespace ${{NAMESPACE}} --selector color=blue sync"
- "echo 'Preparing to deploy ${{CF_REPO_NAME}}:${{CF_RELEASE_TAG}}'"
- echo dev > .ctlenv
# Deploy chart to cluster
- "/deploy/ctl --namespace=${{NAMESPACE}} blue-green"

set_github_deployment_status_to_success:
title: Set GitHub deployment status to "success"
Expand Down
36 changes: 25 additions & 11 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package main

import (
"context"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
)
Expand All @@ -14,33 +16,45 @@ func main() {
}
count := 0

m := http.NewServeMux()
s := http.Server{Addr: ":8080", Handler: m}

log.Printf("Server started\n")

// Healthcheck endpoint
http.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
m.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "OK")
})

// Take one for the team
boom, _ := ioutil.ReadFile("public/boom.html")
http.HandleFunc("/boom", func(w http.ResponseWriter, r *http.Request) {
// Simulate failure
boom, _ := ioutil.ReadFile("public/shutdown.html")
m.HandleFunc("/shutdown", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, string(boom))
fmt.Printf("Goodbye\n")
//os.Exit(0)
log.Printf("Received shutdown request\n")
go func() {
if err := s.Shutdown(context.Background()); err != nil {
log.Fatal(err)
}
}()
})

// Dashboard
dashboard, _ := ioutil.ReadFile("public/dashboard.html")
http.HandleFunc("/dashboard", func(w http.ResponseWriter, r *http.Request) {
m.HandleFunc("/dashboard", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, string(dashboard))
fmt.Printf("GET %s\n", r.URL.Path)
log.Printf("GET %s\n", r.URL.Path)
})

// Default
index, _ := ioutil.ReadFile("public/index.html")
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
m.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
count += 1
fmt.Fprintf(w, string(index), c, count)
fmt.Printf("GET %s\n", r.URL.Path)
//log.Printf("GET %s\n", r.URL.Path)
})

http.ListenAndServe(":8080", nil)
if err := s.ListenAndServe(); err != nil && err != http.ErrServerClosed {
log.Fatal(err)
}
log.Printf("Exiting")
}
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<html onclick="window.location.href = '/boom'">
<html onclick="window.location.href = '/shutdown'">
<head>
<meta http-equiv="refresh" content="2">
<style type="text/css">
Expand Down
File renamed without changes.