feat: skip scaled processes that are missing in the Procfile
This allows folks to deploy apps that don't have a web process without needing to scale that process down before/after the first deploy. Note that the formations key in the app.json or a manual scale of other processes will be necessary to start anything non-web. Closes #5700
This commit is contained in:
@@ -1810,6 +1810,21 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
|||||||
# TODO
|
# TODO
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### `procfile-exists`
|
||||||
|
|
||||||
|
- Description: Checks if a procfile exists for the specified app
|
||||||
|
- Invoked by: `internally`
|
||||||
|
- Arguments: `$APP`
|
||||||
|
- Example:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
|
|
||||||
|
# TODO
|
||||||
|
```
|
||||||
|
|
||||||
### `proxy-build-config`
|
### `proxy-build-config`
|
||||||
|
|
||||||
- Description: Builds the proxy implementation configuration for a given app
|
- Description: Builds the proxy implementation configuration for a given app
|
||||||
|
|||||||
1
plugins/20_events/procfile-exists
Symbolic link
1
plugins/20_events/procfile-exists
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
hook
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
SUBCOMMANDS = subcommands/inspect subcommands/rebuild subcommands/report subcommands/restart subcommands/restore subcommands/retire subcommands/scale subcommands/set subcommands/start subcommands/stop
|
SUBCOMMANDS = subcommands/inspect subcommands/rebuild subcommands/report subcommands/restart subcommands/restore subcommands/retire subcommands/scale subcommands/set subcommands/start subcommands/stop
|
||||||
TRIGGERS = triggers/app-restart triggers/core-post-deploy triggers/core-post-extract triggers/install triggers/post-app-clone triggers/post-app-clone-setup triggers/post-app-rename triggers/post-app-rename-setup triggers/post-create triggers/post-delete triggers/post-stop triggers/pre-deploy triggers/procfile-get-command triggers/ps-can-scale triggers/ps-current-scale triggers/ps-set-scale triggers/report
|
TRIGGERS = triggers/app-restart triggers/core-post-deploy triggers/core-post-extract triggers/install triggers/post-app-clone triggers/post-app-clone-setup triggers/post-app-rename triggers/post-app-rename-setup triggers/post-create triggers/post-delete triggers/post-stop triggers/pre-deploy triggers/procfile-get-command triggers/procfile-exists triggers/ps-can-scale triggers/ps-current-scale triggers/ps-set-scale triggers/report
|
||||||
BUILD = commands subcommands triggers
|
BUILD = commands subcommands triggers
|
||||||
PLUGIN_NAME = ps
|
PLUGIN_NAME = ps
|
||||||
|
|
||||||
|
|||||||
@@ -64,6 +64,9 @@ func main() {
|
|||||||
processType := flag.Arg(1)
|
processType := flag.Arg(1)
|
||||||
port := common.ToInt(flag.Arg(2), 5000)
|
port := common.ToInt(flag.Arg(2), 5000)
|
||||||
err = ps.TriggerProcfileGetCommand(appName, processType, port)
|
err = ps.TriggerProcfileGetCommand(appName, processType, port)
|
||||||
|
case "procfile-exists":
|
||||||
|
appName := flag.Arg(0)
|
||||||
|
err = ps.TriggerProcfileExists(appName)
|
||||||
case "ps-can-scale":
|
case "ps-can-scale":
|
||||||
appName := flag.Arg(0)
|
appName := flag.Arg(0)
|
||||||
canScale := common.ToBool(flag.Arg(1))
|
canScale := common.ToBool(flag.Arg(1))
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package ps
|
package ps
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
@@ -259,6 +260,15 @@ func TriggerPreDeploy(appName string, imageTag string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TriggerProcfileExists checks if a procfile exists
|
||||||
|
func TriggerProcfileExists(appName string) error {
|
||||||
|
if hasProcfile(appName) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return errors.New("Procfile does not exist")
|
||||||
|
}
|
||||||
|
|
||||||
// TriggerProcfileGetCommand fetches a command from the procfile
|
// TriggerProcfileGetCommand fetches a command from the procfile
|
||||||
func TriggerProcfileGetCommand(appName string, processType string, port int) error {
|
func TriggerProcfileGetCommand(appName string, processType string, port int) error {
|
||||||
if !hasProcfile(appName) {
|
if !hasProcfile(appName) {
|
||||||
|
|||||||
@@ -37,6 +37,11 @@ trigger-scheduler-docker-local-scheduler-deploy() {
|
|||||||
|
|
||||||
DOKKU_START_CMD="$(config_get "$APP" DOKKU_START_CMD || true)"
|
DOKKU_START_CMD="$(config_get "$APP" DOKKU_START_CMD || true)"
|
||||||
|
|
||||||
|
local PROCFILE_EXISTS=false
|
||||||
|
if plugn trigger procfile-exists "$APP" 2>/dev/null; then
|
||||||
|
PROCFILE_EXISTS=true
|
||||||
|
fi
|
||||||
|
|
||||||
local DOKKU_WAIT_TO_RETIRE="$(plugn trigger checks-get-property "$APP" wait-to-retire)"
|
local DOKKU_WAIT_TO_RETIRE="$(plugn trigger checks-get-property "$APP" wait-to-retire)"
|
||||||
export DOKKU_WAIT_TO_RETIRE
|
export DOKKU_WAIT_TO_RETIRE
|
||||||
|
|
||||||
@@ -54,6 +59,12 @@ trigger-scheduler-docker-local-scheduler-deploy() {
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
local PROC_CMD=$(plugn trigger procfile-get-command "$APP" "$PROC_TYPE" "5000" 2>/dev/null || echo '')
|
||||||
|
if [[ "$PROCFILE_EXISTS" == true ]] && [[ "$PROC_CMD" == "" ]]; then
|
||||||
|
dokku_log_warn "Skipping $PROC_TYPE as it is missing from the current Procfile"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "$PROC_TYPE" != "web" ]]; then
|
if [[ "$PROC_TYPE" != "web" ]]; then
|
||||||
echo "$PLUGIN_AVAILABLE_PATH/scheduler-docker-local/bin/scheduler-deploy-process $APP $IMAGE_SOURCE_TYPE $IMAGE $IMAGE_TAG $PROC_TYPE $PROC_COUNT" >>"$TMP_FILE"
|
echo "$PLUGIN_AVAILABLE_PATH/scheduler-docker-local/bin/scheduler-deploy-process $APP $IMAGE_SOURCE_TYPE $IMAGE $IMAGE_TAG $PROC_TYPE $PROC_COUNT" >>"$TMP_FILE"
|
||||||
continue
|
continue
|
||||||
|
|||||||
1
tests/apps/python/worker.Procfile
Normal file
1
tests/apps/python/worker.Procfile
Normal file
@@ -0,0 +1 @@
|
|||||||
|
worker: python3 -u worker.py
|
||||||
@@ -56,6 +56,24 @@ teardown() {
|
|||||||
assert_success
|
assert_success
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "(scheduler-docker-local) no-web" {
|
||||||
|
run create_app
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku ps:set $TEST_APP procfile-path worker.Procfile"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run deploy_app
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
assert_output_contains "Skipping web as it is missing from the current Procfile"
|
||||||
|
}
|
||||||
|
|
||||||
@test "(scheduler-docker-local) init-process" {
|
@test "(scheduler-docker-local) init-process" {
|
||||||
run create_app
|
run create_app
|
||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
|
|||||||
Reference in New Issue
Block a user