From d21d38ddaf0515bcc978095f58beece3f105732c Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 29 Apr 2022 23:24:30 +0800 Subject: [PATCH] 1 --- scripts/publish_pm2_golang/boundle.sh | 28 +++++++++++++++++++ .../publish_pm2_golang/ecosystem.config.js | 13 +++++++++ scripts/publish_pm2_golang/reload.sh | 3 ++ scripts/publish_pm2_golang/restart.sh | 16 +++++++++++ 4 files changed, 60 insertions(+) create mode 100644 scripts/publish_pm2_golang/boundle.sh create mode 100644 scripts/publish_pm2_golang/ecosystem.config.js create mode 100755 scripts/publish_pm2_golang/reload.sh create mode 100755 scripts/publish_pm2_golang/restart.sh diff --git a/scripts/publish_pm2_golang/boundle.sh b/scripts/publish_pm2_golang/boundle.sh new file mode 100644 index 0000000..368c4f1 --- /dev/null +++ b/scripts/publish_pm2_golang/boundle.sh @@ -0,0 +1,28 @@ +source ./common.sh + +work_dir=`pwd` +dir_name=`basename $PWD` + +if [ -f "custom_init.sh" ]; then + source ./custom_init.sh +fi + +reg='\.*D[1-9]$' +if [[ $dir_name =~ $reg ]] +then + touch bin/is_test_env + cd ${SOURCE_DIR} + git pull + git checkout release + cd $work_dir +fi + +cd ${SOURCE_PATH} +echo ${COMPILE_CMD}|sh +cp ../bin/${SRC_EXE_NAME} ../../../../bin/${PROJECT_NAME} +cd $work_dir + +tag_name=`git status |grep '# On branch '|sed 's/# On branch //g'` +package_name=${dir_name}.tar.gz + +tar --exclude=*.git -chzf target/${package_name} bin common.sh reload.sh restart.sh config ecosystem.config.js ${EXT_PKG_FILES} diff --git a/scripts/publish_pm2_golang/ecosystem.config.js b/scripts/publish_pm2_golang/ecosystem.config.js new file mode 100644 index 0000000..6935845 --- /dev/null +++ b/scripts/publish_pm2_golang/ecosystem.config.js @@ -0,0 +1,13 @@ +const appName = process.argv[5]; +const n = process.argv[6]; +const i = process.argv[7]; +const execName = process.argv[8]; + +module.exports = { + apps: [{ + name: appName, + args: `-n ${n} -i ${i}`, + script: './' + execName, + cwd: 'bin' + }] +}; diff --git a/scripts/publish_pm2_golang/reload.sh b/scripts/publish_pm2_golang/reload.sh new file mode 100755 index 0000000..74269d3 --- /dev/null +++ b/scripts/publish_pm2_golang/reload.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +echo 'success' diff --git a/scripts/publish_pm2_golang/restart.sh b/scripts/publish_pm2_golang/restart.sh new file mode 100755 index 0000000..7d71d76 --- /dev/null +++ b/scripts/publish_pm2_golang/restart.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +source ./common.sh + +ps -ef|grep ${PROJECT_NAME} > bin/ps.log + +instances=(${1//,/ }) +n=$2 + +for i in ${instances[@]} +do + pm2 delete ecosystem.config.js --only ${PROJECT_NAME}_n${n}_i${i} $n $i ${PROJECT_NAME} + pm2 start ecosystem.config.js --only ${PROJECT_NAME}_n${n}_i${i} $n $i ${PROJECT_NAME} +done + +echo 'success'