mirror of
https://github.com/tickstep/aliyunpan.git
synced 2025-01-23 14:32:14 +08:00
optimize sync to reduce CPU resource for docker
This commit is contained in:
parent
8632c268f0
commit
e8ca54cf4b
@ -45,6 +45,7 @@ COPY ./out/binary_files/sync_drive /home/app/config/sync_drive
|
||||
HEALTHCHECK --start-period=5s --interval=10s --timeout=5s --retries=3 CMD /bin/sh /home/app/health_check.sh
|
||||
|
||||
# 环境变量
|
||||
ENV ALIYUNPAN_DOCKER=1
|
||||
ENV ALIYUNPAN_CONFIG_DIR=/home/app/config
|
||||
|
||||
ENV ALIYUNPAN_REFRESH_TOKEN=""
|
||||
|
@ -44,6 +44,7 @@ HEALTHCHECK --start-period=5s --interval=10s --timeout=5s --retries=3 CMD /bin/s
|
||||
EXPOSE 23077
|
||||
|
||||
# 环境变量
|
||||
ENV ALIYUNPAN_DOCKER=1
|
||||
ENV ALIYUNPAN_CONFIG_DIR=/home/app/config
|
||||
ENV ALIYUNPAN_AUTH_USER=admin
|
||||
ENV ALIYUNPAN_AUTH_PASSWORD=admin
|
||||
|
@ -260,11 +260,23 @@ func RunSync(defaultTask *syncdrive.SyncTask, fileDownloadParallel, fileUploadPa
|
||||
fmt.Println("启动任务失败:", e)
|
||||
return
|
||||
}
|
||||
|
||||
_, ok := os.LookupEnv("ALIYUNPAN_DOCKER")
|
||||
if ok {
|
||||
// in docker container
|
||||
// 使用休眠以节省CPU资源
|
||||
for {
|
||||
time.Sleep(60 * time.Second)
|
||||
}
|
||||
} else {
|
||||
// in cmd mode
|
||||
c := ""
|
||||
fmt.Print("本命令不会退出,如需要结束同步备份进程请输入y,然后按Enter键进行停止:")
|
||||
for strings.ToLower(c) != "y" {
|
||||
fmt.Scan(&c)
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println("正在停止同步备份任务,请稍等...")
|
||||
syncMgr.Stop()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user