在huggingface部署reader(webdav同步) - 开发调优 / 开发调优, Lv1 - LINUX DO

同步来源:树洞剪藏 源站剪藏 ID:529 原文地址:https://linux.do/t/topic/491171/24
在huggingface部署reader(webdav同步) - 开发调优 / 开发调优, Lv1 - LINUX DO
跳到主要内容
LINUXDO ReadBoost待命中 设置
31
话题
我的帖子
关于
即将到来的活动
文档
更多
外部链接
Status
Connect
Webmail
Channel
Telegram
类别
开发调优
资源荟萃
文档共建
跳蚤市场
前沿快讯
网络记忆
福利羊毛
搞七捻三
运营反馈
深海幽域
所有类别
标签
抽奖
公告
精华神帖
快问快答
人工智能
所有标签
消息
收件箱
频道
常规频道
直接消息
聊天
Default
真诚 、 友善 、 团结 、 专业 ,共建你我引以为荣之社区。 《常见问题解答》
❤️ 再忍不住,也不要做这种事啊 ❤️
在 huggingface 部署 reader(webdav 同步)
开发调优 开发调优, Lv1
纯水 , HuggingFace
443
浏览量
130
赞
4
链接
22
用户
2
2
3月 14 日
24 / 24
3月 19 日
5 天
前排围观支持一下 感谢分享大佬厉害啊 有点厉害支持~~
Xiang xjfkkk 种子用户
1 10 天 #1
让我们感谢 @Coker 大佬太强了
实现了 huggingface 的 webdav 同步,重启数据也不会丢失了
项目地址:
github.com
GitHub - hectorqin/reader: 阅读 3 服务器版,桌面端,iOS 可用。后端 Kotlin + Spring Boot + Vert.x...
阅读 3 服务器版,桌面端,iOS 可用。后端 Kotlin + Spring Boot + Vert.x + Coroutine ;前端 Vue.js + Element。麻烦点点 star,关注一下公众号【假装大佬】❗️
- 创建 Dockerfile
FROM hectorqin/reader:latest
RUN apk update &&
apk add --no-cache python3 python3-dev py3-pip curl libxml2-dev libxslt-dev gcc musl-dev &&
rm -rf /var/cache/apk/*
RUN mkdir -p /logs /storage /file-uploads /data
RUN chmod a+w /logs /storage /file-uploads /data
ENV VIRTUAL_ENV=/opt/venv RUN python3 -m venv $VIRTUAL_ENV ENV PATH= " $VIRTUAL_ENV /bin: $PATH "
RUN pip install --upgrade pip
RUN pip install --no-cache-dir requests webdavclient3
COPY sync_data.sh /sync_data.sh
RUN chmod +x /sync_data.sh
CMD [ "/bin/sh" , "/sync_data.sh" ]
在 README.md 末尾添加
app_port: 8080
- 创建 sync_data.sh 文件
#!/bin/sh
检查环境变量
if [ -z "$WEBDAV_URL" ] || [ -z "$WEBDAV_USERNAME" ] || [ -z "$WEBDAV_PASSWORD" ]; then echo "Starting without backup functionality - missing WEBDAV_URL, WEBDAV_USERNAME, or WEBDAV_PASSWORD" exec java -jar /app/bin/reader.jar exit 0 fi
设置备份路径
WEBDAV_BACKUP_PATH=${WEBDAV_BACKUP_PATH:-""} FULL_WEBDAV_URL="${WEBDAV_URL}" if [ -n "$WEBDAV_BACKUP_PATH" ]; then FULL_WEBDAV_URL="${WEBDAV_URL}/${WEBDAV_BACKUP_PATH}" fi
下载最新备份并恢复
restore_backup() { python3 -c " import sys import os import tarfile import requests from webdav3.client import Client options = { 'webdav_hostname': '$FULL_WEBDAV_URL', 'webdav_login': '$WEBDAV_USERNAME', 'webdav_password': '$WEBDAV_PASSWORD' } client = Client(options) backups = [file for file in client.list() if file.endswith('.tar.gz') and file.startswith('reader_backup_')] if not backups: print('No backup files found') sys.exit() latest_backup = sorted(backups)[-1] with requests.get(f'$FULL_WEBDAV_URL/{latest_backup}', auth=('$WEBDAV_USERNAME', '$WEBDAV_PASSWORD'), stream=True) as r: if r.status_code == 200: with open(f'/tmp/{latest_backup}', 'wb') as f: for chunk in r.iter_content(chunk_size=8192): f.write(chunk)
if os.path.exists(f'/tmp/{latest_backup}'): with tarfile.open(f'/tmp/{latest_backup}', 'r:gz') as tar: tar.extractall('/storage') print(f'Successfully restored backup from {latest_backup}') else: print('Failed to download backup file') else: print(f'Failed to download backup: {r.status_code}') " }
首次启动时下载最新备份
echo "Downloading latest backup from WebDAV..." restore_backup
同步函数
sync_data() { while true; do echo "Starting sync process at $(date)"
if [ -d /storage ]; then timestamp=$(date +%Y%m%d_%H%M%S) backup_file="reader_backup_${timestamp}.tar.gz"
压缩数据目录
tar -czf "/tmp/${backup_file}" -C /storage .
上传新备份到WebDAV
curl -u "$WEBDAV_USERNAME:$WEBDAV_PASSWORD" -T "/tmp/${backup_file}" "$FULL_WEBDAV_URL/${backup_file}" if [ $? -eq 0 ]; then echo "Successfully uploaded ${backup_file} to WebDAV" else echo "Failed to upload ${backup_file} to WebDAV" fi
清理旧备份文件
python3 -c " import sys from webdav3.client import Client options = { 'webdav_hostname': '$FULL_WEBDAV_URL', 'webdav_login': '$WEBDAV_USERNAME', 'webdav_password': '$WEBDAV_PASSWORD' } client = Client(options) backups = [file for file in client.list() if file.endswith('.tar.gz') and file.startswith('reader_backup_')] backups.sort() if len(backups) > 2: to_delete = len(backups) - 2 for file in backups[:to_delete]: client.clean(file) print(f'Successfully deleted {file}.') else: print('Only {} backups found, no need to clean.'.format(len(backups))) " 2>&1
rm -f "/tmp/${backup_file}" else echo "/storage directory does not exist, waiting for next sync..." fi
SYNC_INTERVAL=${SYNC_INTERVAL:-600} sleep $SYNC_INTERVAL done }
后台启动同步进程
sync_data &
启动应用程序主进程
exec java -jar /app/bin/reader.jar
默认保留 2 个备份文件,600s 同步一次
- 注册 webdav 并开启传输权限
InfiniCLOUD
Top|InfiniCLOUD
Large capacity online storage. Fast and comfortable use of Japanese servers. Create an account and get 10 GB free
image 2181×674 32.9 KB
- 填入相关变量
WEBDAV_URL # https://jike.teracloud.jp/dav WEBDAV_BACKUP_PATH # 备份文件夹名(备份文件夹,需要自行在网盘中创建,如reader) WEBDAV_USERNAME # 用户名 WEBDAV_PASSWORD # 连接密码,第3步获取到的 SYNC_INTERVAL # 同步时间,默认600
项目变量推荐
SPRING_PROFILES_ACTIVE =prod READER_APP_USERLIMIT = 50 #用户上限,默认50 READER_APP_USERBOOKLIMIT = 200 #用户书籍上限,默认200 READER_APP_CACHECHAPTERCONTENT = true #开启缓存章节内容 V2.0
下面都是多用户模式配置
READER_APP_SECURE = true #开启登录鉴权,开启后将支持多用户模式 READER_APP_SECUREKEY =adminpwd #管理员密码 建议修改 READER_APP_INVITECODE =registercode #注册邀请码 建议修改,如不需要可注释或删除(建议添加,防止他人注册)
- 在 cloudflare 进行反代 (非必须)
export default { async fetch ( request, env ) { const url = new URL (request. url ); url. host = '你的地址' ; return fetch ( new Request (url, request)) } }
heart
tieba_087
+1
54
回复
huggingface部署教程合集 抱脸部署Halo教程
443
浏览量
130
赞
4
链接
22
用户
2
2
归人过客 GRGK0604 蛇来运转
10 天 #2
支持ヾ (≧O≦)〃嗷~
13
回复
Efan efan3536 一元复始
10 天 #3
太强了佬!
heart
tieba_087
14
回复
Reno 🐦🔥 浴火重生
10 天 #4
赞美 @Coker 佬!
2 个回复
heart
tieba_087
16
回复
Xiang xjfkkk 种子用户 Reno 10 天 #5
这次备份数据限制了
heart
tieba_087
17
回复
Coker 指导顾问
10 天 #6
巨佬太强了
heart
tieba_087
10
回复
Coker 指导顾问
Reno 10 天 #7
太强了 reno 佬
tieba_087
heart
3
回复
小殿下 XDX-pp 文化宣导员
10 天 #8
又有新玩具了
回复
我是涅哥 niege
10 天 #9
serv00 大佬现在专攻 hf 了啊
回复
HowieX
10 天 #10
太好了!我明天部署
回复
snaily 大预言家
10 天 #11
赞美巨佬们,太强了
tieba_087
1
回复
上次访问
C baipiaodang
10 天 #12
这也太强啦
回复
warming Wive
10 天 #13
学不完,完全学不完
回复
wenyan Kwenyan 一元复始
1 10 天 #14
管理者账户是什么 reader 吗
我使用注册码注册账户登录了,后续使用管理密码进行管理.
回复
lemonCc 一元复始
1 10 天 #15
支持佬,已经部署上了
回复
大帅哥 handsome 种子用户
10 天 #16
太强了!我立刻部署!
回复
youtobe youto 文化宣导员
10 天 #17
太强啦!
回复
ks kingd Regular
10 天 #18
hugging 领域大神
回复
AITO borland99
10 天 #19
hugging 领域大神
@xjfkkk @Coker @snaily @Reno
tieba_087
2
回复
叶泯希 yeminxi
10 天 #20
太强了 佬
回复
看今朝 gsnqazwsx 文化宣导员
10 天 #21
佬也太强了
回复
Barrie Gallagher 海纳百川
9 天 #22
太强了佬
回复
七转八起 oyz
9 天 #23
image 843×602 47.5 KB 交作业
回复
仙人掌🌵青橘 Citus 一元复始
5 天 #24
太强了佬,感谢
回复
此话题将在最后一个回复的1 个月后关闭。
分享
加入书签
举报
回复
已取消置顶
跟踪
由于您 阅读过此话题 ,您将看到新回复的数量。
❤️ 再忍不住,也不要做这种事啊 ❤️
推荐
相关
新话题和未读话题
话题列表,带有按钮的列标题可以排序。
话题
回复
浏览量
活动
Qwen OCR:人人都能无限免费享用的高精度OCR的时代!支持抱抱脸空间和Docker镜像部署 30 免打扰
开发调优, Lv1
人工智能 , 软件开发 , HuggingFace
251
01/12 09:20
1 天
【搭建教程】一步一步教你自建Hysteria2节点 87 免打扰
开发调优, Lv1
VPS
217
07/25 15:18
2月 4 日
【每日更新】Deepl Pro 点赞留邮箱上车! 504 免打扰
开发调优, Lv1
DeepL
1.2k
10/20 00:00
2月 1 日
佬们,公司服务器被挂WebShell了,该怎么处理好?
免打扰
开发调优, Lv1
快问快答 , 网络安全
19
09:52
2 分钟
请问是否有直连机场的推荐?
免打扰
开发调优, Lv1
快问快答 , 纯水
13
01:17
3 分钟
有 129 个未读 话题 和 245 个新 话题,
或浏览 开发调优, Lv1 中的其他话题
引用
复制引用
开始阅读 启用自动点赞
StripeM-Inner '> ">