Giter Club home page Giter Club logo

lx-music-sync-server's Introduction

LX Msuic Sync Server

洛雪音乐数据同步服务端,本项目目前用于收藏列表数据同步,类似原来PC端的数据同步服务,只不过它现在是一个独立版的服务,可以将其部署到服务器上使用。

本项目需要有一些服务器操作经验的人使用,若遇到问题欢迎反馈。

由于服务本身不提供https协议支持,若将服务部署在公网,请务必使用Nginx之类的服务做反向代理(SSL证书需可信且证书链完整),实现客户端到服务器之间的https连接。

环境要求

  • Node.js 16+

使用方法

安装node.js

Cent OS可以运行以下命令安装:

sudo yum install -y gcc-c++ make
curl -sL https://rpm.nodesource.com/setup_16.x | sudo -E bash  -
sudo yum install nodejs -y

基于 Debian、Ubuntu 发行版的系统使用以下命令安装:

sudo apt-get install -y build-essential
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt-get install -y nodejs

安装完毕后输入以下命令正常情况下会显示Node.js的版本号

node -v

安装PM2(非必须)

PM2是一个Node.js服务管理工具,可以在服务崩溃时自动重启,更多使用方式请自行百度

npm i -g pm2

注:若安装失败,则可能需要以管理员权限安装

若没有安装PM2,则后面pm2开头的命令都可以跳过

安装依赖

若安装依赖过程中出现因utf-8-validate包编译失败的错误,请尝试搜索相关错误解决,若实在无法解决,则可以编辑package.json文件删除dependencies下的utf-8-validate后,重新运行npm ci --omit=devnpm ci即可

如果你是在release下载的压缩包,则解压后项目目录执行以下命令安装依赖:

npm ci --omit=dev

如果你是直接下载的源码,则在本目录中运行以下命令

npm ci
npm run build

配置config.js

按照文件中的说明配置好本目录下的config.js文件

配置ecosystem.config.js中的env_production

可以在这里配置PM2的启动配置,具体根据你的需求配置

启动服务器

npm run prd

若你没有安装PM2,则可以用npm start启动

查看启动日志

pm2 logs

若无报错相关的日志,则说明服务启动成功

设置服务开机启动

注意: 该命令对Windows系统无效,Windows需用批处理的方式设置

pm2 save
pm2 startup

到这里服务已搭建完成,但是为了你的数据安全,我们强烈建议使用Nginx之类的服务为同步服务添加 TLS 保护!

配置Nginx

说明

代理需要配置两条规则:

  1. 代理链接 URL 根路径下所有子路径的 WebSocket 请求到 LX Sync 服务
  2. 代理链接 URL 根路径下所有子路径的 HTTP 请求到 LX Sync 服务

配置

编辑Nginx配置文件,在server下添加代理规则,如果你当前server块下只打算配置 LX Sync 服务,那么可以使用以下配置:

map $http_upgrade $connection_upgrade{
    default upgrade;
    '' close;
}
server {
    # ...
    location / {
        proxy_set_header X-Real-IP $remote_addr;  # 该头部与config.js文件的 proxy.header 对应
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host  $http_host;
        proxy_pass http://127.0.0.1:9527;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
    }
}

如果你当前server块下存在其他服务,那么可以配置路径前缀转发:

map $http_upgrade $connection_upgrade{
    default upgrade;
    '' close;
}
server {
    # ...
    location /xxx/ {
        proxy_set_header X-Real-IP $remote_addr;  # 该头部与config.js文件的 proxy.header 对应
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host  $http_host;
        proxy_pass http://127.0.0.1:9527;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
    }
}

注:上面的xxx是你想要代理的路径前缀(可以多级)

注意$remote_addr的转发名字与config.js中的proxy.header对应并同时启用proxy.enabled(或与环境变量的PROXY_HEADER对应),这用于校验相同IP多次使用错误连接码连接时的封禁

升级新版本

若更新日志无特别说明,注意保留你修改过config.jsecosystem.config.jsDockerfile 之类的配置文件,以及datalogs目录即可,其他的都可以删除后再将新版本的文件复制进去,以下是更新日志无特别说明的更新流程:

使用在release下载的压缩包运行的服务:

  1. 删除项目目录下的 servernode_modules 目录以及 index.jspackage.jsonpackage-lock.json 文件
  2. 将新版本的server目录 index.jspackage.jsonpackage-lock.json 文件复制进去
  3. 执行npm ci --omit=dev
  4. 重启服务,执行 pm2 restart 服务名称或ID 重启服务(可以先执行pm2 list查看服务id或名称)

使用源码编译运行的服务:

  1. 重新下载源码或使用git将代码更新到最新版本
  2. 执行 npm cinpm run build
  3. 重启你的服务

使用docker:将代码更新到最新后,再打包镜像即可

从快照文件恢复数据

  1. 停止同步服务
  2. 修改data/users/<用户名>/list/snapshotInfo.json里面的latest为你那个备份文件key名(即snapshot文件夹下去掉snapshot_前缀后的名字)
  3. 删除snapshotInfo.json文件内clients内的所有设备信息,删除后的内容类似:{...其他内容,"clients":{}}
  4. 启用同步服务,连接后勾选“完全覆盖”,选择“远程覆盖本地”

附录

可用的环境变量

变量名称 说明
PORT 绑定的端口号,默认9527
BIND_IP 绑定的IP地址,默认127.0.0.1,使用0.0.0.0将接受所有IPv4请求,使用::将接受所有IP请求
PROXY_HEADER 代理转发的请求头 原始IP,如果设置,则自动启用
CONFIG_PATH 配置文件路径,默认使用项目目录下的config.js
LOG_PATH 服务日志保存路径,默认保存在服务目录下的logs文件夹内
DATA_PATH 同步数据保存路径,默认保存在服务目录下的data文件夹内
MAX_SNAPSHOT_NUM 公共最大备份快照数
SERVER_NAME 同步服务名称
LIST_ADD_MUSIC_LOCATION_TYPE 公共添加歌曲到我的列表时的方式可用值为 topbottom
LX_USER_ LX_USER_开头的环境变量将被识别为用户配置,可用的配置语法为:
1. LX_USER_user1='xxx'
2. LX_USER_user1='{"password":"xxx"}'
其中LX_USER_会被去掉,剩下的user1为用户名,xxx为用户密码(链接码),
配置方式1为简写模式,只指定用户名及密码(链接码),其他配置使用公共配置,
配置方式2为JSON字符串格式,配置内容参考config.js,由于该方式在变量名指定了用户名,所以JSON里的用户名是可选的

PM2常用命令

  • 查看服务列表:pm2 list
  • 服务控制台的输出日志:pm2 logs
  • 重启服务:pm2 restart 服务名称/编号
  • 停止服务:pm2 stop 服务名称/编号

Docker

可以使用以下方式构建docker镜像(Dockerfile用的是源码构建):

docker build -t lx-music-sync-server .

或者使用已发布到 Docker Hub 的镜像:https://hub.docker.com/r/lyswhut/lx-music-sync-server

也可以看issue中的解决方案:#4

lx-music-sync-server's People

Contributors

lyj0309 avatar lyswhut avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

lx-music-sync-server's Issues

linux 下 npm i 安装失败

npm ERR! code 1
npm ERR! path /root/lx-music-sync-server/node_modules/utf-8-validate
npm ERR! command failed
npm ERR! command sh -c node-gyp-build
npm ERR! make: Entering directory /root/lx-music-sync-server/node_modules/utf-8 -validate/build' npm ERR! CXX(target) Release/obj.target/validation/src/validation.o npm ERR! make: Leaving directory /root/lx-music-sync-server/node_modules/utf-8- validate/build'
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | linux | x64
npm ERR! gyp info find Python using Python version 3.6.8 found at "/usr/bin/pyth on3"
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/root/.nvm/versions/node/v16.16.0/lib/node_modul es/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/root/lx-music-sync-server/node_modules/utf-8-va lidate/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/root/.nvm/versions/node/v16.16.0/lib/node_modul es/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/root/.cache/node-gyp/16.16.0/include/node/commo n.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/root/.cache/node-gyp/16.16.0',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/root/.nvm/versions/node/v16.16.0 /lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/root/.cache/node-gyp/16.16.0/<( target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/root/lx-music-sync-server/nod e_modules/utf-8-validate',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! g++: error: unrecognized command line option ‘-std=gnu++14’
npm ERR! make: *** [Release/obj.target/validation/src/validation.o] Error 1
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: make failed with exit code: 2
npm ERR! gyp ERR! stack at ChildProcess.onExit (/root/.nvm/versions/node/v16 .16.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:527:28)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (node:interna l/child_process:291:12)
npm ERR! gyp ERR! System Linux 3.10.0-1160.45.1.el7.x86_64
npm ERR! gyp ERR! command "/root/.nvm/versions/node/v16.16.0/bin/node" "/root/.n vm/versions/node/v16.16.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gy p.js" "rebuild"
npm ERR! gyp ERR! cwd /root/lx-music-sync-server/node_modules/utf-8-validate
npm ERR! gyp ERR! node -v v16.16.0
npm ERR! gyp ERR! node-gyp -v v9.0.0
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2023-09-09T14_54_26_660Z-debug-0.log
[root@VM-16-16-centos lx-music-sync-server]# npm i
npm ERR! code 1
npm ERR! path /root/lx-music-sync-server/node_modules/utf-8-validate
npm ERR! command failed
npm ERR! command sh -c node-gyp-build
npm ERR! make: Entering directory /root/lx-music-sync-server/node_modules/utf-8-validate/build' npm ERR! CXX(target) Release/obj.target/validation/src/validation.o npm ERR! make: Leaving directory /root/lx-music-sync-server/node_modules/utf-8-validate/build'
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | linux | x64
npm ERR! gyp info find Python using Python version 3.6.8 found at "/usr/bin/python3"
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/root/.nvm/versions/node/v16.16.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/root/lx-music-sync-server/node_modules/utf-8-validate/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/root/.nvm/versions/node/v16.16.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/root/.cache/node-gyp/16.16.0/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/root/.cache/node-gyp/16.16.0',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/root/.nvm/versions/node/v16.16.0/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/root/.cache/node-gyp/16.16.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/root/lx-music-sync-server/node_modules/utf-8-validate',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! g++: error: unrecognized command line option ‘-std=gnu++14’
npm ERR! make: *** [Release/obj.target/validation/src/validation.o] Error 1
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: make failed with exit code: 2
npm ERR! gyp ERR! stack at ChildProcess.onExit (/root/.nvm/versions/node/v16.16.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:527:28)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! System Linux 3.10.0-1160.45.1.el7.x86_64
npm ERR! gyp ERR! command "/root/.nvm/versions/node/v16.16.0/bin/node" "/root/.nvm/versions/node/v16.16.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /root/lx-music-sync-server/node_modules/utf-8-validate
npm ERR! gyp ERR! node -v v16.16.0
npm ERR! gyp ERR! node-gyp -v v9.0.0
npm ERR! gyp ERR! not ok

执行“npm run build”报错

系统:ArchLinux
架构:X86_64
目录为/opt/lx-music-sync-server/
使用root用户执行“npm run build”报错如下

> [email protected] build
> rimraf server && tsc --project tsconfig.json && tsc-alias -p tsconfig.json

error TS5058: The specified path does not exist: 'tsconfig.json'.

执行“find -name tsconfig.json”查找文件tsconfig.json,结果如下
./node_modules/@tsconfig/node12/tsconfig.json
./node_modules/@tsconfig/node14/tsconfig.json
./node_modules/@tsconfig/node16/tsconfig.json
./node_modules/@tsconfig/node10/tsconfig.json
./node_modules/fastq/test/tsconfig.json
./node_modules/ts-node/node_modules/@tsconfig/node16/tsconfig.json
./node_modules/ts-node/node10/tsconfig.json
./node_modules/ts-node/node12/tsconfig.json
./node_modules/ts-node/node14/tsconfig.json
./node_modules/ts-node/node16/tsconfig.json

建议同步服务使用坚果云API

隔壁“阅读"APP提供了类似了支持。由于配置文件很小。免费坚果云是足够的。个人的VPS也许不能长期保证可用性。

用户密码为纯数字(例如12345678)的时候会报错退出

服务器版本为release下载的1.2.2
客户端为mac 2.2.0

> [email protected] start
> node ./index.js

PORT: 9527
BIND_IP: 0.0.0.0
LX_USER_user1: 12345678
Load config: /server/config.js
[2023-03-26T19:47:33.263] [INFO] startup - starting sync server in production
[2023-03-26T19:47:33.270] [INFO] startup - Listening on 0.0.0.0 port 9527
node:internal/errors:478
    ErrorCaptureStackTrace(err);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined
    at new NodeError (node:internal/errors:387:5)
    at Function.from (node:buffer:328:9)
    at authCode (/server/server/server/auth.js:51:58)
    at Server.<anonymous> (/server/server/server/server.js:153:42)
    at Server.emit (node:events:513:28)
    at parserOnIncoming (node:_http_server:998:12)
    at HTTPParser.parserOnHeadersComplete (node:_http_common:128:17) {
  code: 'ERR_INVALID_ARG_TYPE'
}

是否需要更新

同步成功了,后续更新是否需要部署的服务同步升级?

连接码在哪设置

配置好服务启动后,连接服务器需要连接码,没有在配置中看到连接码

当前设备的ip已被服务端封禁

有时候设备重启后,打开软件就会提示输入链接码。输入完之后就提示当前设备的ip已被服务端封禁 !
这个是什么原因造成验证上的失败呢?
image

docker部署server同步能正常,但有报错。

docker logs上面每次同步都会有一条提升文件无法找到
handleMergeListDataFromSnapshot [2023-09-12T08:57:47.620] [WARN] sync - [Error: ENOENT: no such file or directory, open '/server/data/users/admin_21232f/dislike/snapshot/snapshot_d41d8cd98f00b204e9800998ecf8427e'] { errno: -2, code: 'ENOENT', syscall: 'open', path: '/server/data/users/admin_21232f/dislike/snapshot/snapshot_d41d8cd98f00b204e9800998ecf8427e' } getRemoteListData handleSyncList remoteListData, localListData localListData 0 remoteListData 0 [2023-09-12T08:57:47.736] [INFO] sync - status [ 'admin Dev', 'admin Xiaomi M2102J2SC' ] handleListAction admin list_music_add
请问这个跟目录权限有关联吗?docker run 的时候是否需要添加pid?
这是我的运行命令
docker run -d \ --name="lx-music" \ -p 19527:9527 \ -e BIND_IP="0.0.0.0" \ -e LX_USER_admin="password" \ -v /home/docker/lxmusic/config:/server/config \ -v /home/docker/lxmusic/data:/server/data \ -e CONFIG_PATH="/server/config" \ -e DATA_PATH="/server/data" \ --restart always \ lyswhut/lx-music-sync-server
映射的目录权限都是777的。

Dockerfile在arm64v8平台下打包报错

root@lax-pi:/self/code/github/lx-music-sync-server# docker build -t 10.1.0.7:5000/leiax00/lx-music-sync-server-arm:1.3.1 .
[+] Building 46.4s (8/12)                                                                                                                                                                      
 => [internal] load .dockerignore                                                                                                                                                         5.8s
 => => transferring context: 63B                                                                                                                                                          0.0s
 => [internal] load build definition from Dockerfile                                                                                                                                      6.5s
 => => transferring dockerfile: 793B                                                                                                                                                      0.1s
 => [internal] load metadata for docker.io/library/node:16-alpine                                                                                                                         3.5s
 => [internal] load build context                                                                                                                                                         0.3s
 => => transferring context: 3.96kB                                                                                                                                                       0.0s
 => [builder 1/5] FROM docker.io/library/node:16-alpine@sha256:6c381d5dc2a11dcdb693f0301e8587e43f440c90cdb8933eaaaabb905d44cdb9                                                           0.0s
 => CACHED [builder 2/5] WORKDIR /server                                                                                                                                                  0.1s
 => CACHED [builder 3/5] COPY . .                                                                                                                                                         0.0s
 => ERROR [builder 4/5] RUN npm install                                                                                                                                                  34.3s
------                                                                                                                                                                                         
 > [builder 4/5] RUN npm install:                                                                                                                                                              
#0 30.69 npm notice                                                                                                                                                                            
#0 30.69 npm notice New major version of npm available! 8.19.4 -> 9.8.1                                                                                                                        
#0 30.69 npm notice Changelog: <https://github.com/npm/cli/releases/tag/v9.8.1>                                                                                                                
#0 30.69 npm notice Run `npm install -g [email protected]` to update!                                                                                                                                  
#0 30.69 npm notice 
#0 30.70 npm ERR! code 1
#0 30.70 npm ERR! path /server/node_modules/bufferutil
#0 30.71 npm ERR! command failed
#0 30.71 npm ERR! command sh -c -- node-gyp-build
#0 30.71 npm ERR! gyp info it worked if it ends with ok
#0 30.71 npm ERR! gyp info using [email protected]
#0 30.71 npm ERR! gyp info using [email protected] | linux | arm64
#0 30.71 npm ERR! gyp ERR! find Python 
#0 30.71 npm ERR! gyp ERR! find Python Python is not set from command line or npm configuration
#0 30.71 npm ERR! gyp ERR! find Python Python is not set from environment variable PYTHON
#0 30.71 npm ERR! gyp ERR! find Python checking if "python3" can be used
#0 30.71 npm ERR! gyp ERR! find Python - "python3" is not in PATH or produced an error
#0 30.71 npm ERR! gyp ERR! find Python checking if "python" can be used
#0 30.71 npm ERR! gyp ERR! find Python - "python" is not in PATH or produced an error
#0 30.71 npm ERR! gyp ERR! find Python 
#0 30.71 npm ERR! gyp ERR! find Python **********************************************************
#0 30.71 npm ERR! gyp ERR! find Python You need to install the latest version of Python.
#0 30.71 npm ERR! gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
#0 30.71 npm ERR! gyp ERR! find Python you can try one of the following options:
#0 30.71 npm ERR! gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
#0 30.71 npm ERR! gyp ERR! find Python   (accepted by both node-gyp and npm)
#0 30.71 npm ERR! gyp ERR! find Python - Set the environment variable PYTHON
#0 30.71 npm ERR! gyp ERR! find Python - Set the npm configuration variable python:
#0 30.71 npm ERR! gyp ERR! find Python   npm config set python "/path/to/pythonexecutable"
#0 30.71 npm ERR! gyp ERR! find Python For more information consult the documentation at:
#0 30.71 npm ERR! gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
#0 30.71 npm ERR! gyp ERR! find Python **********************************************************
#0 30.71 npm ERR! gyp ERR! find Python 
#0 30.71 npm ERR! gyp ERR! configure error 
#0 30.71 npm ERR! gyp ERR! stack Error: Could not find any Python installation to use
#0 30.71 npm ERR! gyp ERR! stack     at PythonFinder.fail (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:330:47)
#0 30.71 npm ERR! gyp ERR! stack     at PythonFinder.runChecks (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:159:21)
#0 30.71 npm ERR! gyp ERR! stack     at PythonFinder.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:202:16)
#0 30.71 npm ERR! gyp ERR! stack     at PythonFinder.execFileCallback (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:294:16)
#0 30.71 npm ERR! gyp ERR! stack     at exithandler (node:child_process:410:5)
#0 30.71 npm ERR! gyp ERR! stack     at ChildProcess.errorhandler (node:child_process:422:5)
#0 30.71 npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
#0 30.71 npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
#0 30.71 npm ERR! gyp ERR! stack     at onErrorNT (node:internal/child_process:485:16)
#0 30.71 npm ERR! gyp ERR! stack     at processTicksAndRejections (node:internal/process/task_queues:83:21)
#0 30.71 npm ERR! gyp ERR! System Linux 5.15.0-1033-raspi
#0 30.71 npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
#0 30.71 npm ERR! gyp ERR! cwd /server/node_modules/bufferutil
#0 30.71 npm ERR! gyp ERR! node -v v16.20.1
#0 30.71 npm ERR! gyp ERR! node-gyp -v v9.1.0
#0 30.71 npm ERR! gyp ERR! not ok
#0 30.72 
#0 30.72 npm ERR! A complete log of this run can be found in:
#0 30.72 npm ERR!     /root/.npm/_logs/2023-07-21T07_43_25_118Z-debug-0.log
------
Dockerfile:5
--------------------
   3 |     COPY . .
   4 |     # RUN npm install
   5 | >>> RUN npm install
   6 |     RUN npm run build
   7 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c npm install" did not complete successfully: exit code: 1

建议

  • 能不能出一个把本地下载的歌的源文件同步到数据同步服务内,然后客户端连上数据同步服务后就可以直接听或者下载数据同步服务内的歌,我现在在windows里下载了很多歌曲,并且在我的nas里用docker启动了一个镜像,但是在windows和手机端同时使用一个同步服务的前提下,手机上有很多还是无法播放,

2.4.1客户端在最新版服务端登陆后401

通git拉取代码后执行
docker build -t lx-music-sync-server,启动时只加了端口map。并修改了config.ts文件增加了用户名和密码
在2.4.1的客户端开启同步后提示输入对应密码,输入完后出现401错误。
可以确定密码是对的

连接码

使用这个同步,连接时提示输入“连接码”,这个连接码在哪里看到?

输入连接码后报错401

Unexpected server response: 401

nginx 设置错误的问题吗,应该怎么设置呀,按照文档设置了也不行。

无法监听外网地址

我尝试修改了config.js和ecosystem.config.js这两个文件的IP,但始终监听的是127.0.0.1这个本地的9527端口。

用户密码长度缺陷问题

由于该项目的原始代码来自PC端的同步服务,本项目的用户密码等于PC端同步服务的连接码,当初设计PC端连接码时预计只有6位纯数字,所以没有考虑复杂连接码的情况,就随便弄了个简单的校验方式:

let key = ''.padStart(16, Buffer.from(userInfo.password, 'utf8').toString('hex'))

即:将连接码(密码)以UTF-8编码读取并转hex后取前16位(如果长度不够将重复填充到16位)作为密码。
所以导致现在出现的一个问题是设置的用户密码只有前16个hex有效,16位之后的字符将被丢弃,导致当设置的密码超过一定长度后,连接时不用输入完整的密码都可以连接成功。
一般情况下一个数字、英文字符占2个hex,一个中文字符占6个hex,
这意味着如果你的密码是数字、英文字符的话,只有前8位有效,中文字符只有前三个字有效

由于这涉及各端的修改,所以计划在下个大版本再修复它

用宝塔面板添加node项目启动失败

用宝塔面板添加node项目启动失败,提示

[email protected] build > tsc --project tsconfig.json && tsc-alias -p tsconfig.json error TS5058: The specified path does not exist: 'tsconfig.json'. > [email protected] build > tsc --project tsconfig.json && tsc-alias -p tsconfig.json error TS5058: The specified path does not exist: 'tsconfig.json'.

如何查看服务的连接码?

通过docker部署,已成功启动,客户端连接时提示输入连接码(zerotier,跨网段了),请教在docker服务中如何查看连接码?

后续能加入个把本地音乐也同步过去的功能吗?

有些搜不到的音乐,都是单独下载下来然后添加进去的,同步的时候他会把列表同步过去,但是那些本地的似乎就没过去,有些本地缓存的也同步过去了列表,但是后续挂掉的也只剩个空壳了,后续能否加入把这些缓存和本地音乐也同步过去的功能呢?

config.js中如何设置可选环境变量?

np2安装总是失败,所以就直接在config.js照着ecosystem.config.js 中的格式设置了下绑定IP和端口,但是不管怎么设置都没有生效,请问具体该在config.js中设置呢?
image
image

希望能改进反代所需配置

使用docker项目nginx proxy manager进行反代,文档中的nginx配置做不出来,希望能改进一下此项目,不再需要配置NGING也可使用。

关于本项目的一些疑问

  • 这是落雪音乐的api服务吗
  • 如果是的话是否有api文档
  • 是否可以将pm2作为devDependence,从而将本项目使用vercel部署

更新PC端2.4.1和移动端1.1.0后无法同步

今天上午更新新版本,数据同步的地方均显示连接失败

  • 在一台PC更新了2.4.1版本
  • 在移动端更新了1.1.0版本

http://x.x.x.x:port 在PC端和移动端均有显示正确内容

用另一台安装有版本为2.3.0的电脑打开lxmusic,显示数据同步显示已连接

回退版本后,均可以成功连接,进行数据同步

  • 将PC端版本回退到2.3.0
  • 移动端版本回退到1.0.5后,

有可能新版本的同步功能部分的逻辑出了一点问题

打包 docker 镜像过大

我尝试直接使用源码的方式打包成docker镜像,打包之后超过 300M, 使用很不方便。 能否提供一个打包成二进制的命令,支持生成更小的镜像,方便大家在服务器上部署

输入连接码后出现 `expected http 101 response but was '401 unauthorized'`

使用docker compose部署,映射了一些目录

$ cat docker-compose.yml
version: '3.3'
services:
    lx-music:
        ports:
            - '8006:9527'
        volumes:
                - './data/config.js:/server/config.js'
                - './data/syncdata:/server/data'
        image: 'lxmusic'
        networks:
                - mynet
networks:
        mynet:
                external: true

已经输入了config.js中配制的这个用户的密码,但是仍然显示unauthorized如何解决?
已经尝试将./data/syncdata中的内容删除后重新创建容器,还是一样的错误。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.