Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
holi-app-volunteering
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Operate
Terraform modules
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
app
holi-app-volunteering
Commits
8466b925
Commit
8466b925
authored
4 months ago
by
Ole Langbehn
Browse files
Options
Downloads
Patches
Plain Diff
feat: /ready and /health endpoints, readiness/liveness checks
parent
b4cb6ed4
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/server.ts
+6
-6
6 additions, 6 deletions
app/server.ts
terraform/environments/deployment.tf
+9
-1
9 additions, 1 deletion
terraform/environments/deployment.tf
with
15 additions
and
7 deletions
app/server.ts
+
6
−
6
View file @
8466b925
...
...
@@ -263,10 +263,9 @@ const isDbConnectionAlive = async (sql: Sql): Promise<Response> => {
if
(
e
instanceof
DeadlineError
)
{
console
.
error
(
`Liveness check timed out after
${
timeout
}
ms`
)
return
new
Response
(
null
,
{
status
:
503
})
}
else
{
console
.
error
(
'
Liveness check failed, reason:
'
,
e
)
return
new
Response
(
null
,
{
status
:
500
})
}
console
.
error
(
'
Liveness check failed, reason:
'
,
e
)
return
new
Response
(
null
,
{
status
:
500
})
}
}
...
...
@@ -299,8 +298,9 @@ export const startServer = (config: ServerConfig, sql: postgres.Sql): Deno.HttpS
hostname
:
'
0.0.0.0
'
,
handler
:
(
req
:
Request
)
=>
{
const
url
=
new
URL
(
req
.
url
)
if
(
url
.
pathname
.
startsWith
(
'
/liveness
'
))
return
isDbConnectionAlive
(
sql
)
else
return
graphQLServer
.
handleRequest
(
req
)
const
pathname
=
url
.
pathname
if
(
pathname
.
startsWith
(
'
/health
'
)
||
pathname
.
startsWith
(
'
/ready
'
))
return
isDbConnectionAlive
(
client
)
return
graphQLServer
.
handleRequest
(
req
)
},
onListen
({
port
,
hostname
})
{
logger
.
info
(
...
...
@@ -308,7 +308,7 @@ export const startServer = (config: ServerConfig, sql: postgres.Sql): Deno.HttpS
)
if
(
config
.
fake
)
{
logger
.
info
(
`
Server is serving fake data due to FAKE env var set to true
`
,
'
Server is serving fake data due to FAKE env var set to true
'
,
)
}
},
...
...
This diff is collapsed.
Click to expand it.
terraform/environments/deployment.tf
+
9
−
1
View file @
8466b925
...
...
@@ -54,9 +54,17 @@ resource "google_cloud_run_service" "volunteering_api" {
ports
{
container_port
=
8004
}
startup_probe
{
http_get
{
path
=
"/ready"
}
timeout_seconds
=
10
period_seconds
=
10
failure_threshold
=
6
}
liveness_probe
{
http_get
{
path
=
"/
liveness
"
path
=
"/
health
"
}
timeout_seconds
=
10
period_seconds
=
60
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment