UpdateFetch 是一个代理下载文件的工具,更多功能介绍和使用说明,请前往 GitHub 项目主页查看: AhFeil/UpdateFetch: 代理下载文件,方便在特殊网络环境中分享、下载软件 (github.com)
可以前往演示网页体验: http://uf.cufah.cloud/
指标 | 描述 |
---|---|
适用系统 | Debian 系发行版,包括 Ubuntu, Armbian,其他发行版稍改命令一般也可 |
走通流程时间 | 15 分钟 |
原生安装 UpdateFetch
推荐使用普通用户,这里假设用户名为 vfly2
,并在家目录下的 pythonServe
放置工作目录。
前置准备
创建目录 /home/vfly2/pythonServe :
mkdir -p ~/pythonServe/ && cd ~/pythonServe/
拉取仓库:
git clone https://github.com/AhFeil/UpdateFetch.git && cd UpdateFetch
安装环境和依赖( Python versions 3.8+ )
sudo apt update && sudo apt install python3 python3-pip python3-venv -y
运行初始化部署脚本
bash ./setup4host.sh
必须在项目安装目录运行脚本,作用:
- 创建虚拟环境
- 复制示例配置文件和 items.yaml 到 config_and_data_files 下
- 在安装目录生成 systemd 配置文件,可以根据需要修改其中内容,程序默认将以当前用户身份运行
配置
根据注释自定义(用户级)配置文件,默认无须更改
cd ~/pythonServe/UpdateFetch && vim config_and_data_files/config.yaml
这个(程序级)配置文件一般不必修改,可以看看内容
cd ~/pythonServe/UpdateFetch && vim config_and_data_files/pgm_config.yaml
先运行一下,测试完整程序是否能正常运行
.env/bin/uvicorn main:app --host 0.0.0.0 --port 8679
使用 Systemd 守护进程
可以看一下 Systemd 的配置文件,无须修改
cat updatefetch.service
更改权限
chmod 644 updatefetch.service
开机自启并立即运行
sudo systemctl enable --now $PWD/updatefetch.service
查看状态
sudo systemctl status updatefetch.service
如有修改 Systemd 的配置文件,使用下面命令刷新
sudo systemctl daemon-reload
方便用户使用
sudo systemctl stop updatefetch.service
sudo systemctl start updatefetch.service
sudo systemctl disable updatefetch.service # 关闭开机自启
Nginx 反代
编辑 Nginx 配置文件
sudo vim /etc/nginx/sites-available/updatefetch
server {
listen 80;
server_name uf.cufah.cloud; # 更改为你的域名
location / {
proxy_pass http://127.0.0.1:8679;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
启用这个配置文件
sudo ln -s /etc/nginx/sites-available/updatefetch /etc/nginx/sites-enabled/updatefetch
检查配置
sudo nginx -t
重启生效
sudo systemctl reload nginx
迁移
除了两个配置文件和 items.yaml,其他数据都可以在运行时慢慢生成,保存好这 3 个文件即可。
如果要全量迁移,在新机器走完上面的安装流程后,转移 config_and_data_files 目录,就与旧机器一致了
更新
先停止运行
sudo systemctl stop updatefetch && cd ~/pythonServe/updatefetch
在工作目录下,用 Git 拉取最新版本:
git pull
若有必要,更新 requirements 或配置文件等等
然后重启(如果报错,可能添加了依赖库,或者更改了下载项配置格式,前往主页查看修改)
sudo systemctl start updatefetch
sleep 3
sudo systemctl status updatefetch
查看日志
journalctl -u updatefetch -n 100
原文链接: https://yanh.tech/2024/02/deployment-process-of-updatefetch/
版权声明:本博客所有文章除特別声明外,均为 AhFei 原创,采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 技焉洲 (yanh.tech) 。
保持更新 ٩(•̤̀ᵕ•̤́๑)ᵒᵏᵎᵎᵎᵎ 清晰恒益的实用技能,欢迎使用 RSS 订阅,如果能留言互动就更好了。
可在 Telegram 群组 https://t.me/vfly2 交流依文章步骤遇到的问题。