找不到稳定的 DPlayer 弹幕后端
,所以自建。README 推荐 Docker
部署,但 docker-compose
官方未提供 arm 二进制文件,需要安装诸多依赖后通过 pip 编译,整个过程历时 30 分钟,失去了 Docker 的优势之一,快速部署。然而这都不重要,关键是运行后系统负载上升到 0.2,要知道之前还跑着其他数个服务,平均负载一直是 0,所以决定本地安装。
演示效果
Danmaku is loading
[x]
Player version
Player FPS
Video type
Video url
Video resolution
Video duration
Danmaku id
Danmaku api
Danmaku amount
外部依赖
其实 node
项目无非三步走,git clone
,npm install
,node index.js
。在此之前查看下 config.js
和 docker-compose.yml
, 发现项目使用了 redis
和 mongodb
,于是装。
- apt -y install curl git nodejs redis-server
- # 以下代码仅针对 Ubuntu bionic arm64
- function gen_url() {
- echo "https://repo.mongodb.org/apt/ubuntu/dists/bionic/mongodb-org/4.2/multiverse/binary-arm64/${1}"
- }
-
- part_names=(-mongos_ -server_ -shell_ -tools_ _)
- for part_name in ${part_names[@]};
- do
- deb="mongodb-org${part_name}4.2.3_arm64.deb"
- curl -kLO "$(gen_url $deb)"
- dpkg -i $deb
- rm -f $deb
- done
内部依赖
- export DPLAYER_SAVE_PATH=/usr/local/etc/dplayer
- mkdir -p $DPLAYER_SAVE_PATH
- git clone https://github.com/MoePlayer/DPlayer-node.git $DPLAYER_SAVE_PATH
- cd $DPLAYER_SAVE_PATH
- npm install
- npm audit fix
开机自启
- cat >/etc/systemd/system/dplayer.service <<EOF
- [Unit]
- Description=Dplayer Service
- After=network-online.target
- Wants=network-online.target
-
- [Service]
- Type=simple
- PIDFile=/run/dplayer.pid
- WorkingDirectory=$DPLAYER_SAVE_PATH
- ExecStart=$(which node) $DPLAYER_SAVE_PATH/index.js
- Restart=on-failure
-
- [Install]
- WantedBy=multi-user.target
- EOF
-
- systemctl daemon-reload
- services=(redis mongod dplayer)
- for service in ${services[@]};
- do
- systemctl start $service
- systemctl enable $service
- done
Web Server 反代
- location /danmaku/ {
- proxy_redirect off;
- proxy_http_version 1.1;
- proxy_pass http://localhost:1207/;
- proxy_set_header Upgrade $http_upgrade;
- proxy_set_header Connection "upgrade";
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_set_header Host $host;
- }
现在就可以通过 https://domain.com/danmaku/
使用了。
数据备份
- # 导出
- mongoexport -d danmaku -c dans -o /home/danmaku_backup.json
-
- # 导入
- mongoimport -d danmaku -c dans --file /home/danmaku_backup.json
参考资料
如有问题请在下方留言,文章转载请注明出处,详细交流请加下方群组!请大佬不要屏蔽文中广告,因为它将帮我分担服务器开支,如果能帮忙点击我将万分感谢。
强调几点:(该留言由系统自动生成!)
1. 请不要刷广告,本站没有流量!
2. 我不回复虚假邮箱,因为回复了你也看不到!
3. 存在必须回复的隐藏内容时,可以直接使用表情框里的阿鲁表情!