diff --git a/content/doc/applications/java/java-gradle.md b/content/doc/applications/java/java-gradle.md index 0009b801..fcefda16 100644 --- a/content/doc/applications/java/java-gradle.md +++ b/content/doc/applications/java/java-gradle.md @@ -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" >}} diff --git a/content/doc/applications/java/java-jar.md b/content/doc/applications/java/java-jar.md index dc9e3da2..058065c6 100644 --- a/content/doc/applications/java/java-jar.md +++ b/content/doc/applications/java/java-jar.md @@ -158,3 +158,5 @@ For Groovy applications, just use the `System.getProperty("MY_VARIABLE")`. {{< readfile file="more-config.md" >}} +{{< readfile file="url_healthcheck.md" >}} + diff --git a/content/doc/applications/java/java-maven.md b/content/doc/applications/java/java-maven.md index ec0093db..76ff8705 100644 --- a/content/doc/applications/java/java-maven.md +++ b/content/doc/applications/java/java-maven.md @@ -146,3 +146,5 @@ CC_RUN_COMMAND="java -jar somefile.jar " {{< readfile file="link-addon.md" >}} {{< readfile file="more-config.md" >}} + +{{< readfile file="url_healthcheck.md" >}} diff --git a/content/doc/applications/java/java-war.md b/content/doc/applications/java/java-war.md index 5e97a1e4..b076d984 100644 --- a/content/doc/applications/java/java-war.md +++ b/content/doc/applications/java/java-war.md @@ -46,9 +46,9 @@ The supported containers are listed below: Apache Tomcat 4.1 (TOMCAT4) Jetty 6.1 (JETTY6) - Jboss 6.1 (JBOSS6) + Jboss 6.1
(JBOSS6) Glassfish 3.1 (GLASSFISH3) - Payara 4.1 (PAYARA4) + Payara 4.1
(PAYARA4) Resin 3.1 (RESIN3) WildFly 9.0.2 (WILDFLY9) @@ -57,7 +57,7 @@ The supported containers are listed below: Jetty 7.6 (JETTY7) Jboss AS 7.1 (JBOSS7) Glassfish 4.1 (GLASSFISH4) - + Payara 5.2022 (PAYARA5) WildFly 17.0.1 (WILDFLY17) @@ -66,7 +66,7 @@ The supported containers are listed below: Jetty 8.1 (JETTY8) - + Payara 6.2023 (PAYARA6) WildFly 23.0.2 (WILDFLY23) @@ -348,6 +348,8 @@ Here's the list of the configuration values for the "container" field in `war.js +{{< readfile file="url_healthcheck.md" >}} + ## Custom run command If you need to run a custom command diff --git a/content/doc/applications/java/play-framework-1.md b/content/doc/applications/java/play-framework-1.md index 9b8c4017..04f68a67 100644 --- a/content/doc/applications/java/play-framework-1.md +++ b/content/doc/applications/java/play-framework-1.md @@ -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" >}} diff --git a/content/doc/applications/java/play-framework-2.md b/content/doc/applications/java/play-framework-2.md index 34d4ec35..0220abc6 100644 --- a/content/doc/applications/java/play-framework-2.md +++ b/content/doc/applications/java/play-framework-2.md @@ -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" >}} \ No newline at end of file diff --git a/content/doc/develop/healthcheck.md b/content/doc/develop/healthcheck.md new file mode 100644 index 00000000..08ae0a21 --- /dev/null +++ b/content/doc/develop/healthcheck.md @@ -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" >}} + + diff --git a/content/doc/reference/reference-environment-variables.md b/content/doc/reference/reference-environment-variables.md index 4233662f..81c6edad 100644 --- a/content/doc/reference/reference-environment-variables.md +++ b/content/doc/reference/reference-environment-variables.md @@ -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 | @@ -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. diff --git a/go.mod b/go.mod index b4146328..f7bf3285 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index e6a21f6a..8322cf94 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/static/partials/url_healthcheck.md b/static/partials/url_healthcheck.md new file mode 100644 index 00000000..53528431 --- /dev/null +++ b/static/partials/url_healthcheck.md @@ -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