Add healthcheck command #2856

Merged
konrad merged 10 commits from ScribblerCoder/vikunja:main into main 2024-11-20 18:04:58 +00:00
Contributor

Currently vikunja has a /health endpoint that was added in #998. Currently docker/compose cannot utilize this feature, vikunja's docker image doesn't have curl/wget as it is pruned which is great for the image size. This PR adds a healthcheck command that send an http request to /health and exits with 0 or non-zero depending on the result

Currently vikunja has a `/health` endpoint that was added in https://kolaente.dev/vikunja/vikunja/pulls/998. Currently docker/compose cannot utilize this feature, vikunja's docker image doesn't have curl/wget as it is pruned which is great for the image size. This PR adds a `healthcheck` command that send an http request to `/health` and exits with 0 or non-zero depending on the result
ScribblerCoder added 1 commit 2024-11-19 18:10:21 +00:00
Add healthcheck command
Some checks failed
continuous-integration/drone/pr Build is failing
cbb4f9ae83
ScribblerCoder requested review from konrad 2024-11-19 18:10:55 +00:00
konrad requested changes 2024-11-19 18:20:50 +00:00
Dismissed
konrad left a comment
Owner

Welcome! Thanks for the PR. I have a few nits, but nothing too substantial.

Welcome! Thanks for the PR. I have a few nits, but nothing too substantial.
@ -0,0 +45,4 @@
}
port := strings.Split(config.ServiceInterface.GetString(), ":")
url := "http://localhost:%s/health"
resp, err := client.Get(fmt.Sprintf(url, port[len(port)-1]))
Owner

Can't you always do port[0] here?

Or why not add the interface config directly? Since it also contains a :. That would simplify the url building.

Can't you always do `port[0]` here? Or why not add the interface config directly? Since it also contains a `:`. That would simplify the url building.
Author
Contributor

looks like adding the entire interface works. if it is :3456 then the request is sent to localhost:3456

looks like adding the entire interface works. if it is `:3456` then the request is sent to `localhost:3456`
ScribblerCoder marked this conversation as resolved
@ -0,0 +55,4 @@
// Check the response status
if resp.StatusCode == http.StatusOK {
fmt.Println("API server is healthy")
os.Exit(0)
Owner

Can you add an early return here? Similar to the error handling.

Can you add an early return here? Similar to the error handling.
Author
Contributor

makes sense, will do.

makes sense, will do.
ScribblerCoder marked this conversation as resolved
Member

Hi ScribblerCoder!

Thank you for creating a PR!

I've deployed the frontend changes of this PR on a preview environment under this URL: https://2856-main--vikunja-frontend-preview.netlify.app

You can use this url to view the changes live and test them out.
You will need to manually connect this to an api running somewhere. The easiest to use is https://try.vikunja.io/.

This preview does not contain any changes made to the api, only the frontend.

Have a nice day!

Beep boop, I'm a bot.

Hi ScribblerCoder! Thank you for creating a PR! I've deployed the frontend changes of this PR on a preview environment under this URL: https://2856-main--vikunja-frontend-preview.netlify.app You can use this url to view the changes live and test them out. You will need to manually connect this to an api running somewhere. The easiest to use is https://try.vikunja.io/. This preview does not contain any changes made to the api, only the frontend. Have a nice day! > Beep boop, I'm a bot.
ScribblerCoder added 1 commit 2024-11-19 19:02:03 +00:00
add return and simplify url building
Some checks failed
continuous-integration/drone/pr Build is failing
deec2fcb2e
ScribblerCoder added 1 commit 2024-11-19 19:02:47 +00:00
rename variable
Some checks failed
continuous-integration/drone/pr Build is failing
946fd0c649
ScribblerCoder added 1 commit 2024-11-19 19:45:16 +00:00
remove redundant return
All checks were successful
continuous-integration/drone/pr Build is passing
a293268663
ScribblerCoder added 1 commit 2024-11-19 19:47:41 +00:00
Merge branch 'main' into main
All checks were successful
continuous-integration/drone/pr Build is passing
4aea3a7503
ScribblerCoder requested review from konrad 2024-11-19 20:15:02 +00:00
konrad reviewed 2024-11-20 11:09:09 +00:00
konrad left a comment
Owner

Almost ready, can you add the command to the docker image's healthcheck?

https://docs.docker.com/reference/dockerfile/#healthcheck

Almost ready, can you add the command to the docker image's healthcheck? https://docs.docker.com/reference/dockerfile/#healthcheck
ScribblerCoder added 2 commits 2024-11-20 14:26:30 +00:00
ScribblerCoder requested review from konrad 2024-11-20 14:27:13 +00:00
ScribblerCoder added 1 commit 2024-11-20 17:16:09 +00:00
Merge branch 'main' into main
All checks were successful
continuous-integration/drone/pr Build is passing
f5021f3692
ScribblerCoder added 1 commit 2024-11-20 17:23:15 +00:00
Merge branch 'main' into main
All checks were successful
continuous-integration/drone/pr Build is passing
ed992889d9
konrad approved these changes 2024-11-20 18:01:09 +00:00
konrad left a comment
Owner

Thanks!

Thanks!
ScribblerCoder added 1 commit 2024-11-20 18:02:10 +00:00
Merge branch 'main' into main
Some checks reported errors
continuous-integration/drone/pr Build was killed
cb5285a7e2
konrad merged commit a5cc5e3783 into main 2024-11-20 18:04:58 +00:00
Sign in to join this conversation.
No description provided.