feat: add support for non-web healthchecks via app.json

This change converts existing CHECKS files into a healthchecks key that is understood by 'docker-container-healthchecker'. This tool supports a number of different types of container healthchecks - command, http, uptime - and can perform healthchecks against non-web processes.

The use of the old CHECKS file is now deprecated, and will be removed in the next minor version. Users can use the 'docker-container-healthchecker' to convert existing CHECKS files to the new format automatically.

Closes #2760
This commit is contained in:
Jose Diaz-Gonzalez
2023-08-05 12:28:11 -04:00
parent 6f0b32e86b
commit 26e9cc9b8c
16 changed files with 171 additions and 384 deletions

View File

@@ -1,5 +1,5 @@
SUBCOMMANDS = subcommands/report subcommands/set
TRIGGERS = triggers/app-json-process-deploy-parallelism triggers/core-post-deploy triggers/core-post-extract triggers/install triggers/post-app-clone-setup triggers/post-app-rename triggers/post-app-rename-setup triggers/post-create triggers/post-delete triggers/post-deploy triggers/pre-deploy triggers/report
TRIGGERS = triggers/app-json-process-deploy-parallelism triggers/app-json-get-content triggers/core-post-deploy triggers/core-post-extract triggers/install triggers/post-app-clone-setup triggers/post-app-rename triggers/post-app-rename-setup triggers/post-create triggers/post-delete triggers/post-deploy triggers/pre-deploy triggers/report
BUILD = commands subcommands triggers
PLUGIN_NAME = app-json

View File

@@ -22,6 +22,9 @@ func main() {
appName := flag.Arg(0)
processType := flag.Arg(1)
err = appjson.TriggerAppJSONProcessDeployParallelism(appName, processType)
case "app-json-get-content":
appName := flag.Arg(0)
err = appjson.TriggerAppJSONGetContent(appName)
case "core-post-deploy":
appName := flag.Arg(0)
err = appjson.TriggerCorePostDeploy(appName)

View File

@@ -37,6 +37,28 @@ func TriggerAppJSONProcessDeployParallelism(appName string, processType string)
return nil
}
// TriggerAppJSONGetContent outputs the contents of the app-json file, if any
func TriggerAppJSONGetContent(appName string) error {
if !hasAppJSON(appName) {
fmt.Print("{}")
return nil
}
b, err := os.ReadFile(getProcessSpecificAppJSONPath(appName))
if err != nil {
return fmt.Errorf("Cannot read app.json file: %v", err)
}
content := strings.TrimSpace(string(b))
if content == "" {
fmt.Print("{}")
return nil
}
fmt.Print(content)
return nil
}
// TriggerCorePostDeploy sets a property to
// allow the app to be restored on boot
func TriggerCorePostDeploy(appName string) error {