1
This commit is contained in:
15
.cnb.yml
15
.cnb.yml
@@ -17,7 +17,6 @@ main:
|
|||||||
# ========== 生成版本号(作为前置步骤) ==========
|
# ========== 生成版本号(作为前置步骤) ==========
|
||||||
- name: set version
|
- name: set version
|
||||||
image: golang:1.23
|
image: golang:1.23
|
||||||
cpus: 1
|
|
||||||
commands:
|
commands:
|
||||||
- VERSION="v$(git rev-parse --short=8 HEAD 2>/dev/null || echo "unknown")"
|
- VERSION="v$(git rev-parse --short=8 HEAD 2>/dev/null || echo "unknown")"
|
||||||
- mkdir -p .build-info
|
- mkdir -p .build-info
|
||||||
@@ -29,7 +28,7 @@ main:
|
|||||||
# ========== 缓存Go依赖 ==========
|
# ========== 缓存Go依赖 ==========
|
||||||
- name: cache go modules
|
- name: cache go modules
|
||||||
image: meltwater/drone-cache:latest
|
image: meltwater/drone-cache:latest
|
||||||
cpus: 1
|
|
||||||
settings:
|
settings:
|
||||||
restore: true
|
restore: true
|
||||||
mount:
|
mount:
|
||||||
@@ -42,7 +41,7 @@ main:
|
|||||||
# ========== 编译Logic和Login服务 ==========
|
# ========== 编译Logic和Login服务 ==========
|
||||||
- name: build
|
- name: build
|
||||||
image: golang:1.25
|
image: golang:1.25
|
||||||
cpus: 1
|
|
||||||
environment:
|
environment:
|
||||||
CGO_ENABLED: 0
|
CGO_ENABLED: 0
|
||||||
GO111MODULE: on
|
GO111MODULE: on
|
||||||
@@ -53,7 +52,7 @@ main:
|
|||||||
# 编译Logic服务
|
# 编译Logic服务
|
||||||
BIN_NAME="logic_${BUILD_VERSION}"
|
BIN_NAME="logic_${BUILD_VERSION}"
|
||||||
go mod download -x
|
go mod download -x
|
||||||
go build -v -p=1 -trimpath -buildvcs=false -ldflags "-s -w -buildid= -extldflags '-static'" -o ./build/${BIN_NAME} ./logic
|
go build -v -trimpath -buildvcs=false -ldflags "-s -w -buildid= -extldflags '-static'" -o ./build/${BIN_NAME} ./logic
|
||||||
chmod +x ./build/${BIN_NAME}
|
chmod +x ./build/${BIN_NAME}
|
||||||
ls -lh ./build/${BIN_NAME}
|
ls -lh ./build/${BIN_NAME}
|
||||||
file ./build/${BIN_NAME}
|
file ./build/${BIN_NAME}
|
||||||
@@ -62,7 +61,7 @@ main:
|
|||||||
cd login
|
cd login
|
||||||
BIN_NAME="login_${BUILD_VERSION}"
|
BIN_NAME="login_${BUILD_VERSION}"
|
||||||
go mod download -x
|
go mod download -x
|
||||||
go build -v -p=1 -trimpath -buildvcs=false -ldflags "-s -w -buildid= -extldflags '-static'" -o ./build/${BIN_NAME} .
|
go build -v -trimpath -buildvcs=false -ldflags "-s -w -buildid= -extldflags '-static'" -o ./build/${BIN_NAME} .
|
||||||
chmod +x ./build/${BIN_NAME}
|
chmod +x ./build/${BIN_NAME}
|
||||||
ls -lh ./build/${BIN_NAME}
|
ls -lh ./build/${BIN_NAME}
|
||||||
mv ./build/${BIN_NAME} ../build/
|
mv ./build/${BIN_NAME} ../build/
|
||||||
@@ -75,7 +74,6 @@ main:
|
|||||||
# ========== 重建缓存 ==========
|
# ========== 重建缓存 ==========
|
||||||
- name: rebuild cache
|
- name: rebuild cache
|
||||||
image: meltwater/drone-cache:latest
|
image: meltwater/drone-cache:latest
|
||||||
cpus: 1
|
|
||||||
settings:
|
settings:
|
||||||
rebuild: true
|
rebuild: true
|
||||||
mount:
|
mount:
|
||||||
@@ -88,7 +86,6 @@ main:
|
|||||||
# ========== SCP推送Login和Logic到指定服务器 ==========
|
# ========== SCP推送Login和Logic到指定服务器 ==========
|
||||||
- name: deploy to login server
|
- name: deploy to login server
|
||||||
image: appleboy/drone-scp:1.6.2
|
image: appleboy/drone-scp:1.6.2
|
||||||
cpus: 1
|
|
||||||
imports: https://cnb.cool/blzing/key/-/blob/main/githubkey.yml
|
imports: https://cnb.cool/blzing/key/-/blob/main/githubkey.yml
|
||||||
settings:
|
settings:
|
||||||
host: ${LOGIN_SERVER_HOST}
|
host: ${LOGIN_SERVER_HOST}
|
||||||
@@ -106,7 +103,6 @@ main:
|
|||||||
# ========== SSH启动Login服务并上传Logic到Public ==========
|
# ========== SSH启动Login服务并上传Logic到Public ==========
|
||||||
- name: start login and move logic
|
- name: start login and move logic
|
||||||
image: appleboy/drone-ssh:1.6.2
|
image: appleboy/drone-ssh:1.6.2
|
||||||
cpus: 1
|
|
||||||
imports: https://cnb.cool/blzing/key/-/blob/main/githubkey.yml
|
imports: https://cnb.cool/blzing/key/-/blob/main/githubkey.yml
|
||||||
settings:
|
settings:
|
||||||
host: ${LOGIN_SERVER_HOST}
|
host: ${LOGIN_SERVER_HOST}
|
||||||
@@ -128,8 +124,9 @@ main:
|
|||||||
session_name="login"
|
session_name="login"
|
||||||
session=$(screen -ls 2>/dev/null | grep -o "[0-9]*\.${session_name}" || true)
|
session=$(screen -ls 2>/dev/null | grep -o "[0-9]*\.${session_name}" || true)
|
||||||
if [[ ! -z "$session" ]]; then
|
if [[ ! -z "$session" ]]; then
|
||||||
|
screen -X -S "$session_name" stuff "^C"
|
||||||
|
expect -c "exec screen -x ${session_name}; wait; exit" 2>/dev/null || true
|
||||||
screen -X -S "$session_name" quit 2>/dev/null || true
|
screen -X -S "$session_name" quit 2>/dev/null || true
|
||||||
sleep 1
|
|
||||||
echo "Info: Stopped login app."
|
echo "Info: Stopped login app."
|
||||||
fi
|
fi
|
||||||
- sleep 1
|
- sleep 1
|
||||||
|
|||||||
Reference in New Issue
Block a user