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