From 624a3c5cb5a4cffec0f97df377c898398606bb4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Fri, 12 Nov 2021 18:17:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0git=20hook=20publish?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- publish_git_hook.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 publish_git_hook.sh diff --git a/publish_git_hook.sh b/publish_git_hook.sh new file mode 100644 index 0000000..a6e6a52 --- /dev/null +++ b/publish_git_hook.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +if [ "${PROJECT_PATH}" == "" ]; then + echo "PROJECT_PATH IS NOT FOUND" + # shellcheck disable=SC2242 + exit -1 +fi + +if [ "${CONFIG_PATH}" == "" ]; then + echo "CONFIG_PATH IS NOT FOUND" + # shellcheck disable=SC2242 + exit -1 +fi + +if [ "${APP_ID}" == "" ]; then + echo "APP_ID IS NOT FOUND" + # shellcheck disable=SC2242 + exit -1 +fi + +# 切换到项目目录 +# shellcheck disable=SC2164 +# shellcheck disable=SC2009 +cd "${PROJECT_PATH}" && git pull && go build git_hook.go -o "${APP_ID}" && ps aux | grep "${APP_ID}" | grep -v grep | awk '{print $2}' | xargs kill -9 + +# 启动服务 +nohup "${PROJECT_PATH}"/"${APP_ID}" --config_path="${CONFIG_PATH}" & + +echo "${APP_ID}服务启动成功"