允许运行时指定端口
parent
2d84465b47
commit
6f76c07671
|
@ -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}`);
|
||||
});
|
||||
|
||||
|
|
|
@ -7,5 +7,5 @@ wait
|
|||
|
||||
# 运行前端页面
|
||||
cd /music-downloader/html
|
||||
echo "run html, localhost:5780"
|
||||
http-server -p 5780
|
||||
echo "run web, localhost:${WEB_PORT}"
|
||||
http-server -p ${WEB_PORT}
|
|
@ -7,5 +7,5 @@ npm install
|
|||
wait
|
||||
|
||||
# 运行服务器端
|
||||
echo "run server, localhost:5750"
|
||||
node /music-downloader/app/main.js
|
||||
echo "run server, localhost:${SERVER_PORT}"
|
||||
node /music-downloader/app/main.js ${SERVER_PORT}
|
Loading…
Reference in New Issue