tuna / tunasync

Mirror job management tool.
GNU General Public License v3.0
1.61k stars 273 forks source link

请问如何手动更新镜像状态 #178

Closed AethoceSora closed 1 year ago

AethoceSora commented 1 year ago

由于某些镜像没有rsync源,我手动通过wget下载,并放置在指定目录。 请问如何手动更新镜像状态,以便在web页展示该镜像的基本信息(更新时间、大小)?

ZenithalHourlyRate commented 1 year ago

您可以放置一个 dummy 脚本提供给 tunasync,并将其 interval 设置为较大值。在每次手动更新后手动触发 tunasynctl start -w worker target 即可

ZenithalHourlyRate commented 1 year ago

对于大小信息,可以参考

https://github.com/tuna/tunasync-scripts/blob/48e45fa12ee13a802efee46a810dc8f99f2ed67d/rosdistro.sh#L51

https://github.com/tuna/tunasync/blob/02327a117f5ca41ecda2d4cbaaaabaa2c97b968f/docs/zh_CN/workers.conf#L37

tunasync 会在日志中自动查找类似模式并设置大小

您也可以通过 tunasynctl set-size 设置大小

AethoceSora commented 1 year ago

十分感谢,这个方案非常实用。

AethoceSora commented 1 year ago

我编写了如下的假脚本,然而worker提示exec format error,无法成功同步。

#set -e
echo "Sync done"
echo "Total size is" $(numfmt --to=iec 1228240142)

请问编写worker可识别的脚本需要遵循什么样的format?

ZenithalHourlyRate commented 1 year ago

请问编写worker可识别的脚本需要遵循什么样的format?

您好,您需要在脚本中加入 shebang 以使操作系统认识到如何运行该脚本。您可以编写如下脚本

#!/usr/bin/env bash
#set -e
echo "Sync done"
echo "Total size is" $(numfmt --to=iec 1228240142)

chmod +x 该脚本

AethoceSora commented 1 year ago

仍然出了一些问题...

worker --debug:

[22-11-15 22:38:03][NOTICE][worker.go:191] Received command: restart (rosetta)
[22-11-15 22:38:03][NOTICE][job.go:128] start syncing: rosetta
[22-11-15 22:38:03][DEBUG][job.go:136] hooks: pre-job
[22-11-15 22:38:03][DEBUG][loglimit_hook.go:34] executing log limitter for rosetta
[22-11-15 22:38:03][DEBUG][worker.go:448] reporting on manager url: http://localhost:12345/workers/QLU_Mirrors/jobs/rosetta
[22-11-15 22:38:03][DEBUG][runner.go:90] Executing command /home/qlu_mirrors/scripts/rosetta_fake.sh at /mnt/vos-6izqwyw8/mirrors/rosetta
[22-11-15 22:38:03][DEBUG][runner.go:127] Command start: [/home/qlu_mirrors/scripts/rosetta_fake.sh]
[22-11-15 22:38:03][DEBUG][cmd_provider.go:145] set isRunning to true: rosetta
[22-11-15 22:38:03][DEBUG][base_provider.go:168] calling Wait: rosetta
[22-11-15 22:38:03][DEBUG][job.go:169] provider started
[22-11-15 22:38:03][DEBUG][base_provider.go:165] set isRunning to false: rosetta
[22-11-15 22:38:03][DEBUG][job.go:180] syncing done
[22-11-15 22:38:03][WARNIN][job.go:213] failed syncing rosetta: exit status 127
[22-11-15 22:38:03][DEBUG][job.go:215] post-fail hooks
ZenithalHourlyRate commented 1 year ago

failed syncing rosetta: exit status 127

手动执行该脚本结果如何?

在 tunasync 日志目录下(例如 /var/log/tunasync/rosetta )中是否能找到脚本运行的日志?

AethoceSora commented 1 year ago

我愚蠢的CRLF换行引发了这个问题。现在dummy脚本运行良好,worker的执行符合预期。再次感谢!