完成协议开发

This commit is contained in:
Cheney 2024-08-19 18:11:48 +08:00
parent 00de726082
commit 8176e9c034

View File

@ -4,7 +4,6 @@ const ukey = require("./FakeUKey")
const cors = require('cors'); const cors = require('cors');
const { killPortProcess } = require('kill-port-process'); const { killPortProcess } = require('kill-port-process');
const app = express(); const app = express();
// const port = 3000; // const port = 3000;
const port = 8090; const port = 8090;
@ -47,18 +46,19 @@ app.post('/do', (req, res) => {
(async () => { (async () => {
// long running process running on a given port(s), e.g. a http-server
// takes a number, number[], string or string[]
// single port
await killPortProcess(8090);
try { app.listen(port, "127.0.0.1", () => {
await killPortProcess(port);
} catch (e) {
}
app.listen(port, () => {
console.log(`Server is running on port ${port}`); console.log(`Server is running on port ${port}`);
}).on('error', (err) => {
if (err.code === 'ECONNREFUSED') {
console.log('端口监听失败。');
}
}); });
})(); })();