From 3e8a9ac74aaf23e3a40afce1b0aee5af4410d06d Mon Sep 17 00:00:00 2001 From: chaos-zhu Date: Sun, 13 Oct 2024 23:04:37 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E5=AE=A2=E6=88=B7=E7=AB=AF?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E6=94=AF=E6=8C=81=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E7=AB=AF=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 8 ++++++-- client/app/config/index.js | 2 +- client/app/server.js | 7 ++++--- client/easynode-client-install.sh | 12 +++++++++--- client/easynode-client.service | 3 ++- web/src/components/top-bar.vue | 2 +- 6 files changed, 23 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index dfde0df..c7b5d97 100644 --- a/README.md +++ b/README.md @@ -59,14 +59,18 @@ pm2 start index.js --name easynode-server ## 监控服务安装 -- 监控服务用于实时向服务端推送**系统、公网IP、CPU、内存、硬盘、网卡**等基础信息,不安装不影响使用面板,但是无法实时同步cpu占用、实时网速、硬盘容量等有用信息。 +- 监控服务用于实时向服务端推送**系统、公网IP、CPU、内存、硬盘、网卡**等基础信息,不安装不影响使用面板,但是无法实时同步cpu占用、实时网速、硬盘容量等实用信息。 -- 占用端口:**22022** +- 默认端口:**22022** > 安装 ```shell +# 使用默认端口22022安装 curl -o- https://ghp.ci/https://raw.githubusercontent.com/chaos-zhu/easynode/main/client/easynode-client-install.sh | bash + +# 使用自定义端口安装, 例如54321 +curl -o- https://ghp.ci/https://raw.githubusercontent.com/chaos-zhu/easynode/main/client/easynode-client-install.sh | bash -s -- 54321 ``` > 卸载 diff --git a/client/app/config/index.js b/client/app/config/index.js index 258eb4a..bfb8cd8 100644 --- a/client/app/config/index.js +++ b/client/app/config/index.js @@ -1,3 +1,3 @@ module.exports = { - httpPort: 22022 + defaultPort: 22022 } diff --git a/client/app/server.js b/client/app/server.js index c783603..93adab2 100644 --- a/client/app/server.js +++ b/client/app/server.js @@ -1,14 +1,15 @@ const http = require('http') const Koa = require('koa') -const { httpPort } = require('./config') +const { defaultPort } = require('./config') const wsOsInfo = require('./socket/monitor') const httpServer = () => { const app = new Koa() const server = http.createServer(app.callback()) serverHandler(app, server) - server.listen(httpPort, () => { - console.log(`Server(http) is running on port:${ httpPort }`) + const port = process.env.CLIENT_PORT || defaultPort + server.listen(port, () => { + console.log(`Server(http) is running on port:${ port }`) }) } diff --git a/client/easynode-client-install.sh b/client/easynode-client-install.sh index 4a89303..095f2d2 100644 --- a/client/easynode-client-install.sh +++ b/client/easynode-client-install.sh @@ -5,13 +5,18 @@ if [ "$(id -u)" != "0" ] ; then exit 1 fi +clientPort=${clientPort:-22022} SERVER_NAME=easynode-client FILE_PATH=/root/local/easynode-client SERVICE_PATH=/etc/systemd/system -CLIENT_VERSION=client-2024-08-17 # 目前监控客户端版本发布需手动更改为最新版本号 +CLIENT_VERSION=client-2024-10-13 # 目前监控客户端版本发布需手动更改为最新版本号 SERVER_PROXY="https://ghp.ci/" -echo "***********************开始安装EasyNode监控客户端端,当前版本号: ${CLIENT_VERSION}***********************" +if [ ! -z "$1" ]; then + clientPort=$1 +fi + +echo "***********************开始安装EasyNode监控客户端端,当前版本号: ${CLIENT_VERSION}, 端口: ${clientPort}***********************" systemctl status ${SERVER_NAME} > /dev/null 2>&1 if [ $? != 4 ] @@ -80,6 +85,8 @@ echo "***********************下载成功***********************" chmod +x ${FILE_PATH}/${SERVER_NAME} chmod 777 ${FILE_PATH}/${SERVER_NAME}.service +sed -i "s/clientPort=22022/clientPort=${clientPort}/g" ${FILE_PATH}/${SERVER_NAME}.service + # echo "***********************移动service&reload***********************" mv ${FILE_PATH}/${SERVER_NAME}.service ${SERVICE_PATH} @@ -89,7 +96,6 @@ systemctl daemon-reload echo "***********************启动服务***********************" systemctl start ${SERVER_NAME} - # echo "***********************设置开机启动***********************" systemctl enable ${SERVER_NAME} diff --git a/client/easynode-client.service b/client/easynode-client.service index 868192a..e06a4a4 100644 --- a/client/easynode-client.service +++ b/client/easynode-client.service @@ -1,9 +1,10 @@ [Unit] -Description=easynode client server port_22022 +Description=easynode client server port_${clientPort} [Service] ExecStart=/root/local/easynode-client/easynode-client WorkingDirectory=/root/local/easynode-client +Environment="clientPort=${clientPort}" Restart=always RestartSec=5 diff --git a/web/src/components/top-bar.vue b/web/src/components/top-bar.vue index cc102ee..846ab2d 100644 --- a/web/src/components/top-bar.vue +++ b/web/src/components/top-bar.vue @@ -46,7 +46,7 @@

更新日志:https://github.com/chaos-zhu/easynode/blob/main/CHANGELOG.md

开源仓库: https://github.com/chaos-zhu/easynode

作者: chaoszhu

- +

tg更新通知:https://t.me/easynode_notify

打赏: EasyNode开源且无任何收费,如果您认为此项目帮到了您, 您可以请我喝杯阔乐(记得留个备注)~