-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
593 additions
and
84 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
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,51 @@ | ||
name: 构建 admin 备份 db job 镜像 | ||
|
||
on: | ||
push: | ||
branches: [master] | ||
paths: | ||
- "golang/gw/service/admin/**" | ||
- "golang/gw/core/db/**" | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: arduino/setup-protoc@v3 | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: "1.21.5" | ||
- name: 安装 protoc-gen-go/grpc/grpc-gateway/openapiv2 插件 | ||
run: | | ||
go install google.golang.org/protobuf/cmd/[email protected] | ||
go install google.golang.org/grpc/cmd/[email protected] | ||
go install github.com/grpc-ecosystem/grpc-gateway/v2/[email protected] | ||
go install github.com/grpc-ecosystem/grpc-gateway/v2/[email protected] | ||
- name: 生成桩文件 | ||
run: | | ||
export PATH="$PATH:$(go env GOPATH)/bin" | ||
cd golang/gw | ||
./build.sh proto | ||
- name: 构建二进制 | ||
run: | | ||
cd golang/gw/ | ||
go build -o gw service/admin/main.go | ||
- name: 构建镜像推送到 aliyun | ||
run: | | ||
docker version | ||
docker login --username=${{ secrets.DOCKER_USERNAME }} --password=${{ secrets.DOCKER_PASSWORD }} registry.cn-hangzhou.aliyuncs.com | ||
cd golang/gw | ||
chmod +x ./gw | ||
docker build . --file docker/jobs/Dockerfile --tag registry.cn-hangzhou.aliyuncs.com/alomerry/mix-admin:latest | ||
docker push registry.cn-hangzhou.aliyuncs.com/alomerry/mix-admin:latest | ||
# https://github.com/marketplace/actions/http-request-action | ||
- name: trigger rollout restart | ||
uses: fjogeleit/http-request-action@v1 | ||
with: | ||
url: ${{secrets.MIX_GW_RESTART_URL}} | ||
method: "POST" | ||
customHeaders: '{"Content-Type": "application/json"}' | ||
data: '{"namespace": "alomerry", "deployment": "mix-module-admin-deployment"}' |
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,56 @@ | ||
package algo | ||
|
||
import ( | ||
"sync" | ||
"time" | ||
) | ||
|
||
type TickQueue[T comparable] struct { | ||
idx map[T]int | ||
lock sync.RWMutex | ||
ticker *time.Ticker | ||
cnt int | ||
f func(T) | ||
} | ||
|
||
func NewTickQueue[T comparable](duration time.Duration, f func(T)) *TickQueue[T] { | ||
return &TickQueue[T]{ | ||
idx: map[T]int{}, | ||
lock: sync.RWMutex{}, | ||
ticker: time.NewTicker(duration), | ||
f: f, | ||
} | ||
} | ||
|
||
func (t *TickQueue[T]) Enqueue(id T) { | ||
t.lock.Lock() | ||
defer t.lock.Unlock() | ||
t.cnt++ | ||
_, exists := t.idx[id] | ||
if exists { | ||
t.idx[id]++ | ||
return | ||
} | ||
t.idx[id] = 1 | ||
} | ||
|
||
func (t *TickQueue[T]) Run() { | ||
for { | ||
<-t.ticker.C | ||
|
||
t.lock.Lock() | ||
|
||
if t.cnt == 0 { | ||
t.lock.Unlock() | ||
break | ||
} | ||
for k, v := range t.idx { | ||
if v > 0 { | ||
go t.f(k) | ||
t.idx[k] = 0 | ||
} | ||
} | ||
t.lock.Unlock() | ||
} | ||
} | ||
|
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,9 @@ | ||
FROM phusion/baseimage:jammy-1.0.2 | ||
# 安装 // mysqldump -u root -h alomerry.com -P 13306 -p waline_blog > waline_blog.sql | ||
|
||
WORKDIR /app/gw | ||
|
||
RUN apt-get update; \ | ||
apt-get install mysql-client; \ | ||
echo 'exec /app/gw/gw' > /etc/service/gw/run; | ||
COPY gw /app/gw/ |
File renamed without changes.
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
Oops, something went wrong.