tangled
alpha
login
or
join now
kacaii.dev
/
sigo
0
fork
atom
๐ฉโ๐ Firefighters API written in Gleam!
lustre
gleam
0
fork
atom
overview
issues
pulls
pipelines
:stethoscope: add server healthcheck
kacaii.dev
4 days ago
0215786f
04650816
verified
This commit was signed with the committer's
known signature
.
kacaii.dev
SSH Key Fingerprint:
SHA256:n9v7QGNWHCUv1x/483hCtPUvTsVabU5PzC5CSJMUNtI=
+10
2 changed files
expand all
collapse all
unified
split
justfile
server
src
server
router.gleam
+8
justfile
···
8
9
pod_name := "pod_sigo"
10
0
11
pg_image := "docker.io/postgres:18-alpine"
12
pg_env := "-e POSTGRES_USER -e POSTGRES_PASSWORD -e POSTGRES_DB"
13
pg_volume := "-v ./sql/create:/docker-entrypoint-initdb.d"
···
19
# server
20
run_server_locally := env("RUN_SERVER_LOCALLY", "false")
21
server_port := if run_server_locally == "false" { "-p 8000:8000" } else { "" }
0
0
0
0
22
23
# List available recipes
24
@_default:
···
90
--pod {{ pod_name }} \
91
--name server \
92
-e DATABASE_URL -e SECRET_KEY \
0
0
0
93
sigo-server
94
95
···
8
9
pod_name := "pod_sigo"
10
11
+
# database
12
pg_image := "docker.io/postgres:18-alpine"
13
pg_env := "-e POSTGRES_USER -e POSTGRES_PASSWORD -e POSTGRES_DB"
14
pg_volume := "-v ./sql/create:/docker-entrypoint-initdb.d"
···
20
# server
21
run_server_locally := env("RUN_SERVER_LOCALLY", "false")
22
server_port := if run_server_locally == "false" { "-p 8000:8000" } else { "" }
23
+
24
+
server_health_cmd := "--health-cmd 'wget -q --spider http://127.0.0.1:8000/api/health || exit 1'"
25
+
server_health_conf := "--health-interval 30s --health-retries 3 --health-timeout 10s"
26
+
server_health_start_period := "--health-start-period 10s"
27
28
# List available recipes
29
@_default:
···
95
--pod {{ pod_name }} \
96
--name server \
97
-e DATABASE_URL -e SECRET_KEY \
98
+
{{ server_health_cmd }} \
99
+
{{ server_health_conf }} \
100
+
{{ server_health_start_period }} \
101
sigo-server
102
103
+2
server/src/server/router.gleam
···
10
use req <- middleware(req, ctx)
11
12
case wisp.path_segments(req) {
0
0
13
["api", "login"] -> login.handle_request(req, ctx)
14
["api", "signup"] -> signup.handle_request(req, ctx)
15
["api", "whoami"] -> whoami.handle_request(req, ctx)
···
10
use req <- middleware(req, ctx)
11
12
case wisp.path_segments(req) {
13
+
["api", "health"] -> wisp.ok()
14
+
15
["api", "login"] -> login.handle_request(req, ctx)
16
["api", "signup"] -> signup.handle_request(req, ctx)
17
["api", "whoami"] -> whoami.handle_request(req, ctx)