Skip to content

Commit

Permalink
Add a healthcheck (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
joecorall authored Nov 14, 2024
1 parent b35eaa8 commit d998fd5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"fmt"
"log/slog"
"net/http"

Expand All @@ -10,6 +11,10 @@ import (
func main() {
http.HandleFunc("/workbench/check", handlers.CheckMyWork)
http.HandleFunc("/workbench/transform", handlers.TransformCsv)
http.HandleFunc("/healthcheck", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
fmt.Fprintln(w, "OK")
})

slog.Info("Starting server on :8080")
if err := http.ListenAndServe(":8080", nil); err != nil {
Expand Down
10 changes: 9 additions & 1 deletion scripts/download-transform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,16 @@ else
exit 1
fi

nohup ./fabricator -server=1 &
nohup ./fabricator &
echo $! > fabricator_pid.txt
while true; do
STATUS=$(curl -s -w '%{http_code}' -o /dev/null http://localhost:8080/healthcheck)
if [ "${STATUS}" -eq 200 ]; then
break
fi
echo "Waiting for fabricator to come online"
sleep 1
done

# make sure the sheet passes the check my work
STATUS=$(curl -v \
Expand Down

0 comments on commit d998fd5

Please sign in to comment.