From 6f76c07671dc2bd0ef8aa822e664d6cfe205350f Mon Sep 17 00:00:00 2001 From: amuliang <982632988@qq.com> Date: Sat, 5 Aug 2023 17:41:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=81=E8=AE=B8=E8=BF=90=E8=A1=8C=E6=97=B6?= =?UTF-8?q?=E6=8C=87=E5=AE=9A=E7=AB=AF=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/main.js | 9 +++++++-- start/html.sh | 4 ++-- start/server.sh | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/main.js b/app/main.js index bb9b51e..e7f4670 100644 --- a/app/main.js +++ b/app/main.js @@ -83,6 +83,11 @@ _server.get("/api/store", async (req, res, query) => { // *********************************************************************** // 运行服务 +const args = process.argv.splice(2); +let port = 5750; +if(args.length > 0 && !isNaN(args[0])) { + port = parseInt(args[0]); +} const server = http.createServer(async (req, res) => { let method = req.method; let reqUrl = req.url; @@ -112,7 +117,7 @@ const server = http.createServer(async (req, res) => { res.end(JSON.stringify(result)); }); -server.listen(5750, () => { - console.log("server running at prot 5750"); +server.listen(port, () => { + console.log(`server running at prot ${port}`); }); diff --git a/start/html.sh b/start/html.sh index ec9a47b..50bfdcc 100644 --- a/start/html.sh +++ b/start/html.sh @@ -7,5 +7,5 @@ wait # 运行前端页面 cd /music-downloader/html -echo "run html, localhost:5780" -http-server -p 5780 \ No newline at end of file +echo "run web, localhost:${WEB_PORT}" +http-server -p ${WEB_PORT} \ No newline at end of file diff --git a/start/server.sh b/start/server.sh index c41921a..afe550b 100644 --- a/start/server.sh +++ b/start/server.sh @@ -7,5 +7,5 @@ npm install wait # 运行服务器端 -echo "run server, localhost:5750" -node /music-downloader/app/main.js \ No newline at end of file +echo "run server, localhost:${SERVER_PORT}" +node /music-downloader/app/main.js ${SERVER_PORT} \ No newline at end of file