在服务器上离线下载并在线播放 Cloud Torrent

1、Cloud Torrent 传统方式安装

Cloud Torrent 是用 Go 语言编写的程序,无需安装运行环境就可以直接使用。如果想用 Docker 运行或从源代码构建(需安装 Go 环境),在 GitHub 项目页有相关介绍。

这里介绍二进制文件使用方法,适用 CentOS、Debian、Ubuntu 这些主流 Linux 发行版。

安装步骤:

  1. 获取 Cloud Torrent,运行后会自动检测系统环境下载对应的二进制文件。
curl https://i.jpillora.com/cloud-torrent! | bash

安装后会显示程序路径,默认路径为 /usr/local/bin/cloud-torrent。

  1. 之后即可运行程序。
/usr/local/bin/cloud-torrent --host 0.0.0.0 --port 8000 --auth "123:123" --config-path /root/cloud-torrent.json --title "Cloud Torrent" --log >> /var/log/cloud-torrent.log

解释一下上面命令参数:监听本机 IP 使用 8080 端口,登录用户名 user 密码 password,指定程序配置文件(安装时已自动生成),设置网页标题,启用请求记录,将使用日志记录到指定文件。

根据自己需要修改选项参数,比如密码是必须要改的。完整选项可运行 cloud-torrent --help 查看。

运行后用浏览器访问你的服务器 IP 即可使用,网址格式为 http://X.X.X.X:8080/。

如果不能访问,可能防火墙没有放行端口,需要设置一下(以 CentOS 为例)。

firewall-cmd --zone=public --add-port=8080/tcp --permanent
firewall-cmd --reload
  1. 手动运行有些麻烦,断开 SSH 会话会自动关闭。下面设置将程序放在后台运行并设置开机启动。
vi /usr/lib/systemd/system/cloud-torrent.service
# 创建服务文件,将下面内容粘贴保存。

[Unit]
Description=cloud-torrent

[Service]
# 下载目录默认为工作目录下的 /downloads 目录
WorkingDirectory=/
ExecStart=/usr/local/bin/cloud-torrent --host 0.0.0.0 --port 8000 --auth "123:123"  # 加上可能报错不能启动--config-path /root/cloud-torrent.json --title "Cloud Torrent" --log >> /var/log/cloud-torrent.log
ExecStop=eval $(ps -ef | grep cloud-torrent | grep -v grep | awk '{print "kill "$2}')
Restart=always
RestartSec=3

[Install]
WantedBy=multi-user.target

之后就可以用下面命令管理程序了。

  • 设置开机自启:systemctl enable cloud-torrent
  • 取消开机自启:systemctl disable cloud-torrent
  • 手动启动程序:systemctl start cloud-torrent
  • 手动停止程序:systemctl stop cloud-torrent
  • 查看运行状态:systemctl status cloud-torrent

2、Docker 安装 Cloud Torrent

$ docker run -d -p 3000:3000 -v /downloads:/downloads jpillora/cloud-torrent
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值