-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add command to handle deploy killing
- Loading branch information
1 parent
57bcea0
commit 1d1d5ce
Showing
3 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env bash | ||
set -eo pipefail | ||
[[ $DOKKU_TRACE ]] && set -x | ||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" | ||
source "$PLUGIN_AVAILABLE_PATH/ps/functions" | ||
|
||
ps_kill_deploy_cmd() { | ||
declare desc="kill app deploy" | ||
declare cmd="ps:kill-deploy" | ||
[[ "$1" == "$cmd" ]] && shift 1 | ||
declare APP="$1" | ||
verify_app_name "$APP" | ||
|
||
local APP_DEPLOY_LOCK_FILE PROCESS_ID PROCESS_GROUP_ID | ||
APP_DEPLOY_LOCK_FILE="$DOKKU_ROOT/$APP/.deploy.lock" | ||
if [[ ! -f "$APP_DEPLOY_LOCK_FILE" ]]; then | ||
dokku_log_info1 "No matching app deploy found" | ||
return | ||
fi | ||
|
||
PROCESS_ID="$(cat "$APP_DEPLOY_LOCK_FILE")" | ||
if [[ -z "$PROCESS_ID" ]]; then | ||
dokku_log_info1 "No matching app deploy found" | ||
return | ||
fi | ||
|
||
PROCESS_GROUP_ID="$(ps -o pgid= "$PROCESS_ID" || true)" | ||
if [[ -z "$PROCESS_ID" ]]; then | ||
dokku_log_info1 "No matching app deploy found" | ||
return | ||
fi | ||
|
||
dokku_log_info1 "Killing app deploy" | ||
kill -quit -- "-${PROCESS_GROUP_ID}" && rm -f "$DOKKU_ROOT/$APP/.deploy.lock" | ||
} | ||
|
||
ps_kill_deploy_cmd "$@" |