Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

documentation for url healthcheck during deployment #83

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 2 additions & 0 deletions content/doc/applications/java/java-gradle.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,5 @@ Just create and commit the `gradlew` file and the wrapper `jar` and `properties`
{{< readfile file="deploy-git.md" >}}

{{< readfile file="more-config.md" >}}

{{< readfile file="url_healthcheck.md" >}}
2 changes: 2 additions & 0 deletions content/doc/applications/java/java-jar.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,5 @@ For Groovy applications, just use the `System.getProperty("MY_VARIABLE")`.

{{< readfile file="more-config.md" >}}

{{< readfile file="url_healthcheck.md" >}}

2 changes: 2 additions & 0 deletions content/doc/applications/java/java-maven.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,5 @@ CC_RUN_COMMAND="java -jar somefile.jar <options>"
{{< readfile file="link-addon.md" >}}

{{< readfile file="more-config.md" >}}

{{< readfile file="url_healthcheck.md" >}}
10 changes: 6 additions & 4 deletions content/doc/applications/java/java-war.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ The supported containers are listed below:
<tr>
<td>Apache Tomcat 4.1 (TOMCAT4)</td>
<td>Jetty 6.1 (JETTY6)</td>
<td>Jboss 6.1 (JBOSS6)</td>
<td>Jboss 6.1<br>(JBOSS6)</td>
<td>Glassfish 3.1 (GLASSFISH3)</td>
<td>Payara 4.1 (PAYARA4)</td>
<td>Payara 4.1<br>(PAYARA4)</td>
<td>Resin 3.1 (RESIN3)</td>
<td>WildFly 9.0.2 (WILDFLY9)</td>
</tr>
Expand All @@ -57,7 +57,7 @@ The supported containers are listed below:
<td>Jetty 7.6 (JETTY7)</td>
<td>Jboss AS 7.1 (JBOSS7)</td>
<td>Glassfish 4.1 (GLASSFISH4)</td>
<td></td>
<td>Payara 5.2022 (PAYARA5)</td>
<td></td>
<td>WildFly 17.0.1 (WILDFLY17)</td>
</tr>
Expand All @@ -66,7 +66,7 @@ The supported containers are listed below:
<td>Jetty 8.1 (JETTY8)</td>
<td></td>
<td></td>
<td></td>
<td>Payara 6.2023 (PAYARA6)</td>
<td></td>
<td>WildFly 23.0.2 (WILDFLY23)</td>
</tr>
Expand Down Expand Up @@ -348,6 +348,8 @@ Here's the list of the configuration values for the "container" field in `war.js
</tbody>
</table>

{{< readfile file="url_healthcheck.md" >}}

## Custom run command

If you need to run a custom command
Expand Down
2 changes: 2 additions & 0 deletions content/doc/applications/java/play-framework-1.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,5 @@ To access environment variables from your code, you need to reference them in yo
{{< readfile file="link-addon.md" >}}

{{< readfile file="more-config.md" >}}

{{< readfile file="url_healthcheck.md" >}}
2 changes: 2 additions & 0 deletions content/doc/applications/java/play-framework-2.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,5 @@ You can also use the `System.getenv("MY_VARIABLE")` method. Be aware that it can
{{< readfile file="link-addon.md" >}}

{{< readfile file="more-config.md" >}}

{{< readfile file="url_healthcheck.md" >}}
19 changes: 19 additions & 0 deletions content/doc/develop/healthcheck.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
type: docs
title: Deployment healthcheck path
shortdesc: Healthcheck allows to check if an url return always the 200 code.
tags:
- develop
keywords:
- apps
- healthcheck
type: docs
---

{{< callout type="info" >}}
This feature has yet to be released for all images. At the time of writing this documentation (2023-11-28), it is only available for Java applications.
{{< /callout >}}

{{< readfile file="url_healthcheck.md" >}}


2 changes: 2 additions & 0 deletions content/doc/reference/reference-environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ So you can alter the build&start process for your application.
|`APP_FOLDER` | Folder in which the application is located (inside the git repository) | |
|`CC_DISABLE_GIT_SUBMODULES` | Disable Git submodules initialization & synchronization | |
|`CC_DISABLE_METRICS` | Disable metrics collection. | false |
|[`CC_HEALTH_CHECK_PATH`](/doc/develop/healthcheck) | Custom path to validate your application deployment | |
|`CC_NODE_VERSION`| Set Node.js version on non-Node.js application. Don't use it for Node.js applications, use [this](/doc/applications/javascript/nodejs/#select-node-version "Select node version") instead | |
|`CC_SSH_PRIVATE_KEY` | A ssh private key to setup for the user running your application | |
|`CC_SSH_PRIVATE_KEY_FILE` | The name to use for the file containing the private ssh key | id_ed25519 |
Expand All @@ -65,6 +66,7 @@ So you can alter the build&start process for your application.
|`CC_TASK` | If set as true, the deployer runs `CC_RUN_COMMAND` and close the instance after havind run the task. Trigger an execution using `git push` or starting your instance | false |
|[`CC_TROUBLESHOOT`](/doc/find-help/troubleshooting "Troubleshooting") | Enable debug log level, will also keep the VM up after failure for 15 minutes so you can SSH and debug. Don't forget to cancel deployment if you push a new commit. | false |


#### Deployment hooks

Use these to define [commands to run]({{< ref "doc/develop/build-hooks.md" >}}) between various steps of the deployment.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module github.com/cnivolle/hextra //to update

go 1.21

require github.com/imfing/hextra v0.6.5 // indirect
require github.com/imfing/hextra v0.7.0 // indirect
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ github.com/imfing/hextra v0.6.1 h1:l2PGNO3OgfYGrLcA74ngwVqxj00wg4tBwUHtemSPggw=
github.com/imfing/hextra v0.6.1/go.mod h1:cEfel3lU/bSx7lTE/+uuR4GJaphyOyiwNR3PTqFTXpI=
github.com/imfing/hextra v0.6.5 h1:1hRZsZp6J/dum0VEUH4gHP9Zi5sPMtyAaRuxMt1HuiM=
github.com/imfing/hextra v0.6.5/go.mod h1:cEfel3lU/bSx7lTE/+uuR4GJaphyOyiwNR3PTqFTXpI=
github.com/imfing/hextra v0.7.0 h1:4kK/R5Uks+LvZII4P4/bOGoTHxmM2MSRYLlRjhFCJDo=
github.com/imfing/hextra v0.7.0/go.mod h1:cEfel3lU/bSx7lTE/+uuR4GJaphyOyiwNR3PTqFTXpI=
43 changes: 43 additions & 0 deletions static/partials/url_healthcheck.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
## Enable health check during deployment

The healthcheck allows you to limit downtimes. Indeed, you can provide us with paths to check. If these paths return something else than 200, we will consider the deployment as failed.


All you need to do is add one (or several) environment variables as such:

```bash
CC_HEALTH_CHECK_PATH=my/awesome/path
```

Or

```bash
CC_HEALTH_CHECK_PATH_0=my/awesome/path
CC_HEALTH_CHECK_PATH_1=my/other/path
```

The deployment process will check all given paths. All of them must reply with a `200 OK` response code.

### Example

Using the path listed above, here are the logs you have to look to:

```
Response from GET /my/awesome/path is 200
Response from GET /my/other/path is 500
Health check failed:
- GET /my/other/path returned 500.
If the deployment fails after this message, please update your configuration and redeploy.
```

In this example, the 1st path is OK, but the 2nd one failed. This give you a hint on what failed in your application.


### Best practice for healthcheck endpoints

Un bon endpoint de healthcheck vérifie que les services critiques dont dépend votre application sont bien accessibles.

To make the most of a healthcheck endpoint, you should have it check your critical dependencies. For example:
- execute `SELECT 1 + 1;` on your database
- retrieve a specific Cellar file
- ping a specific IP through a VPN
Loading