Author SHA1 Message Date
loveuer 9146c87cad feat: 0.1.3
/ clean (push) Successful in 0s
/ build ushare (push) Successful in 39s
1. 完善 dockerfile 和 entrypoint
2025-05-12 15:54:52 +08:00
loveuer b1b3ac5b6b feat: 0.1.2
1. login page && auth required
  2. file dir cleanup
2025-05-12 15:54:52 +08:00
loveuer a2635698e0 init: 0.1.1
feat: login page && auth required
todo: 断点上传
2025-05-12 15:54:49 +08:00
loveuer b3ff70167f init: 0.1.0
feat: 基本功能有了
  1. 分片上传
  2. code 回显
  3. 下载
todo: 断点上传
2025-05-12 15:54:49 +08:00
loveuer 7ec8cd5c0e init: 0.0.8
feat: 实现了分片上传
todo:
  1. 上传完成后 code 回显
  2. 清理不用的临时 code file
  3. 断点续传
  4. 多 chunk 并发上传
2025-05-12 15:54:43 +08:00
loveuer fb96934abe init: 0.0.4 2025-05-12 15:54:40 +08:00
5 changed files with 70 additions and 15 deletions
+2 -1
View File
@@ -1,2 +1,3 @@
node_modules frontend/node_modules
dist dist
frontend/dist
+24 -12
View File
@@ -5,7 +5,7 @@ on:
- 'v*' - 'v*'
jobs: jobs:
build and run u-api: build ushare:
runs-on: tencent-sg runs-on: tencent-sg
steps: steps:
- name: prepare enviroment - name: prepare enviroment
@@ -17,9 +17,6 @@ jobs:
- name: print operator - name: print operator
run: whoami run: whoami
- name: print work dir and files
run: pwd & ls -alsh .
- name: print tag name - name: print tag name
run: echo "Tag name = ${{ gitea.ref_name }}" run: echo "Tag name = ${{ gitea.ref_name }}"
@@ -29,14 +26,29 @@ jobs:
${{ secrets.DOCKER_CONFIG }} ${{ secrets.DOCKER_CONFIG }}
EOF EOF
- name: build by kaniko in docker - name: print work dir and files
run: | run: pwd & ls -alsh .
docker run --rm -v $(pwd):/workspace \
-v $(pwd)/.docker.config.json:/kaniko/.docker/config.json:ro \ - name: build image by docker build
gcr.io/kaniko-project/executor:latest \ run: docker build -t gitea.loveuer.com/loveuer/build/ushare:${{ gitea.ref_name }} .
'-f /workspace/Dockerfile' \
'-d "gitea.loveuer.com/loveuer/build/ushare:${{ gitea.ref_name }}"' \ - name: login repository
'--single-snapshot' run: echo ${{ secrets.DOCKER_REPOSITORY_PASSWORD }} | docker login --username loveuer --password-stdin gitea.loveuer.com/loveuer
- name: push image to repository
run: docker push gitea.loveuer.com/loveuer/build/ushare:${{ gitea.ref_name }}
# - name: build by kaniko in docker
# run: |
# docker run --rm -v $(pwd):/workspace \
# -v $(pwd)/.docker.config.json:/kaniko/.docker/config.json:ro \
# alpine:latest \
# ls -alsh /workspace
# gcr.io/kaniko-project/executor:latest \
# --dockerfile=/workspace/Dockerfile \
# --context=/workspace \
# --destination=gitea.loveuer.com/loveuer/build/u-api:${{ gitea.ref_name }} \
# --single-snapshot
clean: clean:
if: always() if: always()
+4 -1
View File
@@ -27,9 +27,12 @@ COPY --from=backend-builder /app/ushare /usr/local/bin/ushare
# 配置 Nginx # 配置 Nginx
RUN rm /etc/nginx/conf.d/default.conf RUN rm /etc/nginx/conf.d/default.conf
COPY deployment/nginx.conf /etc/nginx/conf.d COPY deployment/nginx.conf /etc/nginx/conf.d
COPY deployment/entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
# 开放端口 # 开放端口
EXPOSE 80 EXPOSE 80
# 启动服务 # 启动服务
CMD sh -c "ushare & nginx -g 'daemon off;'" ENTRYPOINT ["entrypoint.sh"]
+35
View File
@@ -0,0 +1,35 @@
#!/bin/sh
set -e
# 启动后端服务(带参数后台运行)
echo "启动后端服务,参数: $@"
ushare "$@" &
BACKEND_PID=$!
# 定义优雅关闭函数
graceful_shutdown() {
echo "接收到终止信号,开始优雅关闭..."
# 先关闭 Nginx
echo "关闭 Nginx..."
nginx -s quit 2>/dev/null || kill -TERM $NGINX_PID 2>/dev/null
# 关闭后端服务
echo "关闭后端服务 PID $BACKEND_PID..."
kill -TERM $BACKEND_PID 2>/dev/null
# 等待进程终止
wait $BACKEND_PID $NGINX_PID 2>/dev/null
exit 0
}
# 捕获系统信号
trap 'graceful_shutdown' SIGTERM SIGINT
# 启动 Nginx(前台运行)
echo "启动 Nginx..."
nginx -g "daemon off;" &
NGINX_PID=$!
# 等待所有后台进程
wait $BACKEND_PID $NGINX_PID
+4
View File
@@ -104,6 +104,10 @@ func (m *meta) Start(ctx context.Context) {
ticker := time.NewTicker(time.Minute) ticker := time.NewTicker(time.Minute)
m.ctx = ctx m.ctx = ctx
if err := os.MkdirAll(opt.Cfg.DataPath, 0644); err != nil {
log.Fatal("controller.MetaManager.Start: mkdir datapath failed, path = %s, err = %s", opt.Cfg.DataPath, err.Error())
}
// 清理 2 分钟内没有继续上传的 part // 清理 2 分钟内没有继续上传的 part
go func() { go func() {
for { for {