diff --git a/docs/appendices/0.36.0-migration-guide.md b/docs/appendices/0.36.0-migration-guide.md
new file mode 100644
index 000000000..2a79b6668
--- /dev/null
+++ b/docs/appendices/0.36.0-migration-guide.md
@@ -0,0 +1,6 @@
+# 0.35.0 Migration Guide
+
+## Changes
+
+- Process stop timeouts are now configured via the `ps` property `stop-timeout-seconds`. Existing `DOKKU_DOCKER_STOP_TIMEOUT` environment variables will be automatically migrated to the new value.
+- Processes now default to a `30` second stop timeout.
\ No newline at end of file
diff --git a/docs/configuration/environment-variables.md b/docs/configuration/environment-variables.md
index 3734d44c6..047571c22 100644
--- a/docs/configuration/environment-variables.md
+++ b/docs/configuration/environment-variables.md
@@ -112,7 +112,6 @@ The following config variables have special meanings and can be set in a variety
| `DOKKU_DISABLE_PROXY` | none | `dokku proxy:disable`
`dokku proxy:enable` | Disables the proxy in front of your application, resulting in publicly routing the docker container. |
| `DOKKU_DISABLE_ANSI_PREFIX_REMOVAL` | none | `dokku config:set`
`/etc/environment`
`~dokku/.dokkurc`
`~dokku/.dokkurc/*` | Disables removal of the ANSI prefix during deploys. Can be used in cases where the client deployer does not understand ansi escape codes. |
| `DOKKU_DISABLE_APP_AUTOCREATION` | none | `dokku config:set` | Disables automatic creation of a non-existent app on deploy. |
-| `DOKKU_DOCKER_STOP_TIMEOUT` | `10` | `dokku config:set` | Configurable grace period given to the `docker stop` command. If a container has not stopped by this time, a `kill -9` signal or equivalent is sent in order to force-terminate the container. Both the `ps:stop` and `apps:destroy` commands _also_ respect this value. If not specified, the docker defaults for the [docker stop command](https://docs.docker.com/engine/reference/commandline/stop/) will be used.|
| `DOKKU_DOCKERFILE_CACHE_BUILD` | none | `dokku config:set` | |
| `DOKKU_DOCKERFILE_START_CMD` | none | `dokku config:set` | |
| `DOKKU_PARALLEL_ARGUMENTS`. | none | `dokku config:set` | Allows passing custom arguments to parallel for `ps:*all` commands |
diff --git a/docs/deployment/zero-downtime-deploys.md b/docs/deployment/zero-downtime-deploys.md
index b811b2d1e..91bbf765e 100644
--- a/docs/deployment/zero-downtime-deploys.md
+++ b/docs/deployment/zero-downtime-deploys.md
@@ -36,12 +36,15 @@ dokku checks:set node-js-app wait-to-retire 30
Defaults to `60`.
+## Setting stop grace period
+
+You can set the `stop-timeout` property on the `ps` plugin to change this value (default: `30`). See the [process management documentation](/docs/processes/process-management.md#changing-process-management-settings) for more information.
+
## Configuring check settings using the `config` plugin
There are certain settings that can be configured via environment variables:
- `DOKKU_DEFAULT_CHECKS_WAIT`: (default: `10`) If no user-defined checks are specified - or if the process being checked is not a `web` process - this is the period of time Dokku will wait before checking that a container is still running.
-- `DOKKU_DOCKER_STOP_TIMEOUT`: (default: `10`) Configurable grace period given to the `docker stop` command. If a container has not stopped by this time, a `kill -9` signal or equivalent is sent in order to force-terminate the container. Both the `ps:stop` and `apps:destroy` commands *also* respect this value. If not specified, the Docker defaults for the [`docker stop` command](https://docs.docker.com/engine/reference/commandline/stop/) will be used.
The following settings may also be specified in the `app.json` file, though are available as environment variables in order to ease application reuse.
diff --git a/docs/processes/process-management.md b/docs/processes/process-management.md
index abc64ebac..c94796b87 100644
--- a/docs/processes/process-management.md
+++ b/docs/processes/process-management.md
@@ -107,6 +107,39 @@ proctype: qty
web: 1
```
+### Changing process management settings
+
+The `ps` plugin provides a number of settings that can be used to managed deployments on a per-app basis. The following table outlines ones not covered elsewhere:
+
+| Name | Description | Global Default |
+|-----------------------|---------------------------------------------------|--------------------|
+| `stop-timeout` | Configurable grace period given to the `docker stop` command. If a container has not stopped by this time, a `kill -9` signal or equivalent is sent in order to force-terminate the container. Both the `ps:stop` and `apps:destroy` commands *also* respect this value. If not specified, the Docker defaults for the [`docker stop` command](https://docs.docker.com/engine/reference/commandline/stop/) will be used. | `30` |
+
+All settings can be set via the `scheduler-k3s:set` command. Using `stop-timeout` as an example:
+
+```shell
+dokku scheduler-k3s:set node-js-app stop-timeout 60
+```
+
+The default value may be set by passing an empty value for the option in question:
+
+```shell
+dokku scheduler-k3s:set node-js-app stop-timeout
+```
+
+Properties can also be set globally. If not set for an app, the global value will apply.
+
+```shell
+dokku scheduler-k3s:set --global stop-timeout 60
+```
+
+The global default value may be set by passing an empty value for the option.
+
+```shell
+dokku scheduler-k3s:set --global stop-timeout
+```
+
+
### Defining Processes
#### Procfile
diff --git a/plugins/ports/triggers.go b/plugins/ports/triggers.go
index 4391170f1..bb4e7a83d 100644
--- a/plugins/ports/triggers.go
+++ b/plugins/ports/triggers.go
@@ -25,8 +25,16 @@ func TriggerInstall() error {
continue
}
- common.LogInfo1(fmt.Sprintf("Migrating DOKKU_PROXY_PORT_MAP to ports map property for %s", appName))
- portMapString := config.GetWithDefault(appName, "DOKKU_PROXY_PORT_MAP", "")
+ results, _ := common.CallPlugnTrigger(common.PlugnTriggerInput{
+ Trigger: "config-get",
+ Args: []string{appName, "DOKKU_PROXY_PORT_MAP"},
+ })
+ portMapString := results.StdoutContents()
+ if portMapString == "" {
+ continue
+ }
+
+ common.LogVerboseQuiet(fmt.Sprintf("Setting %s ports property 'map' to %v", appName, portMapString))
portMaps, _ := parsePortMapString(portMapString)
propertyValue := []string{}
@@ -38,7 +46,11 @@ func TriggerInstall() error {
return err
}
- if err := config.UnsetMany(appName, []string{"DOKKU_PROXY_PORT_MAP"}, false); err != nil {
+ _, err := common.CallPlugnTrigger(common.PlugnTriggerInput{
+ Trigger: "config-unset",
+ Args: []string{appName, "DOKKU_PROXY_PORT_MAP"},
+ })
+ if err != nil {
return err
}
}
diff --git a/plugins/ps/ps.go b/plugins/ps/ps.go
index 7e1e2f4d9..307306f24 100644
--- a/plugins/ps/ps.go
+++ b/plugins/ps/ps.go
@@ -13,13 +13,15 @@ const RunInSerial = 0
var (
// DefaultProperties is a map of all valid ps properties with corresponding default property values
DefaultProperties = map[string]string{
- "restart-policy": "on-failure:10",
- "procfile-path": "",
+ "restart-policy": "on-failure:10",
+ "procfile-path": "",
+ "stop-timeout-seconds": "30",
}
// GlobalProperties is a map of all valid global ps properties
GlobalProperties = map[string]bool{
- "procfile-path": true,
+ "procfile-path": true,
+ "stop-timeout-seconds": true,
}
)
diff --git a/plugins/ps/report.go b/plugins/ps/report.go
index 5e0ddfe40..74c4c17a9 100644
--- a/plugins/ps/report.go
+++ b/plugins/ps/report.go
@@ -15,15 +15,18 @@ func ReportSingleApp(appName string, format string, infoFlag string) error {
}
flags := map[string]common.ReportFunc{
- "--deployed": reportDeployed,
- "--processes": reportProcesses,
- "--ps-can-scale": reportCanScale,
- "--ps-restart-policy": reportRestartPolicy,
- "--ps-computed-procfile-path": reportComputedProcfilePath,
- "--ps-global-procfile-path": reportGlobalProcfilePath,
- "--ps-procfile-path": reportProcfilePath,
- "--restore": reportRestore,
- "--running": reportRunningState,
+ "--deployed": reportDeployed,
+ "--processes": reportProcesses,
+ "--ps-can-scale": reportCanScale,
+ "--ps-restart-policy": reportRestartPolicy,
+ "--ps-computed-procfile-path": reportComputedProcfilePath,
+ "--ps-global-procfile-path": reportGlobalProcfilePath,
+ "--ps-procfile-path": reportProcfilePath,
+ "--restore": reportRestore,
+ "--running": reportRunningState,
+ "--global-stop-timeout-seconds": reportGlobalStopTimeoutSeconds,
+ "--computed-stop-timeout-seconds": reportComputedStopTimeoutSeconds,
+ "--stop-timeout-seconds": reportStopTimeoutSeconds,
}
extraFlags := addStatusFlags(appName, infoFlag)
@@ -146,3 +149,20 @@ func reportRestore(appName string) string {
func reportRunningState(appName string) string {
return getRunningState(appName)
}
+
+func reportComputedStopTimeoutSeconds(appName string) string {
+ value := reportStopTimeoutSeconds(appName)
+ if value == "" {
+ value = reportGlobalStopTimeoutSeconds(appName)
+ }
+
+ return value
+}
+
+func reportGlobalStopTimeoutSeconds(appName string) string {
+ return common.PropertyGetDefault("ps", "--global", "stop-timeout-seconds", "30")
+}
+
+func reportStopTimeoutSeconds(appName string) string {
+ return common.PropertyGetDefault("ps", appName, "stop-timeout-seconds", "30")
+}
diff --git a/plugins/ps/triggers.go b/plugins/ps/triggers.go
index 674369db5..90a4e001b 100644
--- a/plugins/ps/triggers.go
+++ b/plugins/ps/triggers.go
@@ -164,8 +164,29 @@ func TriggerInstall() error {
if common.FileExists(dokkuScaleExtracted) {
os.Remove(dokkuScaleExtracted)
}
- }
+ results, _ := common.CallPlugnTrigger(common.PlugnTriggerInput{
+ Trigger: "config-get",
+ Args: []string{appName, "DOKKU_DOCKER_STOP_TIMEOUT"},
+ })
+ stopTimeout := results.StdoutContents()
+ if stopTimeout == "" {
+ continue
+ }
+
+ common.LogVerboseQuiet(fmt.Sprintf("Setting %s ps property 'stop-timeout-seconds' to %v", appName, stopTimeout))
+ if err := common.PropertyWrite("ps", appName, "stop-timeout-seconds", stopTimeout); err != nil {
+ return err
+ }
+
+ _, err := common.CallPlugnTrigger(common.PlugnTriggerInput{
+ Trigger: "config-unset",
+ Args: []string{appName, "DOKKU_DOCKER_STOP_TIMEOUT"},
+ })
+ if err != nil {
+ return err
+ }
+ }
return nil
}
@@ -320,3 +341,17 @@ func TriggerPsCurrentScale(appName string) error {
func TriggerPsSetScale(appName string, skipDeploy bool, clearExisting bool, processTuples []string) error {
return scaleSet(appName, skipDeploy, clearExisting, processTuples)
}
+
+func TriggerPsGetProperty(appName string, property string) error {
+ computedValueMap := map[string]common.ReportFunc{
+ "stop-timeout-seconds": reportComputedStopTimeoutSeconds,
+ }
+
+ fn, ok := computedValueMap[property]
+ if !ok {
+ return fmt.Errorf("Invalid network property specified: %v", property)
+ }
+
+ fmt.Println(fn(appName))
+ return nil
+}
diff --git a/plugins/scheduler-docker-local/internal-functions b/plugins/scheduler-docker-local/internal-functions
index ebce46b95..b0c32a137 100755
--- a/plugins/scheduler-docker-local/internal-functions
+++ b/plugins/scheduler-docker-local/internal-functions
@@ -114,7 +114,7 @@ fn-scheduler-docker-local-retire-container() {
return
fi
- DOKKU_DOCKER_STOP_TIMEOUT="$(config_get "$APP" DOKKU_DOCKER_STOP_TIMEOUT || true)"
+ DOKKU_DOCKER_STOP_TIMEOUT="$(plugn trigger ps-get-property "$APP" stop-timeout || true)"
[[ $DOKKU_DOCKER_STOP_TIMEOUT ]] && DOCKER_STOP_TIME_ARG="--time=${DOKKU_DOCKER_STOP_TIMEOUT}"
if [[ "$STATE" == "restarting" ]]; then
diff --git a/plugins/scheduler-docker-local/scheduler-deploy b/plugins/scheduler-docker-local/scheduler-deploy
index 3192c0e63..b222fef8f 100755
--- a/plugins/scheduler-docker-local/scheduler-deploy
+++ b/plugins/scheduler-docker-local/scheduler-deploy
@@ -32,7 +32,7 @@ trigger-scheduler-docker-local-scheduler-deploy() {
local oldids=$(get_app_container_ids "$APP" "$PROCESS_TYPE")
DOKKU_NETWORK_BIND_ALL="$(plugn trigger network-get-property "$APP" bind-all-interfaces)"
- DOKKU_DOCKER_STOP_TIMEOUT="$(config_get "$APP" DOKKU_DOCKER_STOP_TIMEOUT || true)"
+ DOKKU_DOCKER_STOP_TIMEOUT="$(plugn trigger ps-get-property "$APP" stop-timeout)"
[[ $DOKKU_DOCKER_STOP_TIMEOUT ]] && DOCKER_STOP_TIME_ARG="--time=${DOKKU_DOCKER_STOP_TIMEOUT}"
DOKKU_START_CMD="$(config_get "$APP" DOKKU_START_CMD || true)"
diff --git a/plugins/scheduler-docker-local/scheduler-run-stop b/plugins/scheduler-docker-local/scheduler-run-stop
index d46f9ad72..85b124fdd 100755
--- a/plugins/scheduler-docker-local/scheduler-run-stop
+++ b/plugins/scheduler-docker-local/scheduler-run-stop
@@ -51,7 +51,7 @@ trigger-scheduler-docker-local-scheduler-run-stop() {
verify_app_name "$APP"
- DOKKU_DOCKER_STOP_TIMEOUT="$(config_get "$APP" DOKKU_DOCKER_STOP_TIMEOUT || true)"
+ DOKKU_DOCKER_STOP_TIMEOUT="$(plugn trigger ps-get-property "$APP" stop-timeout || true)"
if [[ -n "$CONTAINER_NAME" ]]; then
fn-scheduler-docker-local-stop-container "$CONTAINER_NAME" "$DOKKU_DOCKER_STOP_TIMEOUT"
return $?