cli: set port as paramter
This commit is contained in:
parent
e8f22b16d3
commit
00cc673583
@ -30,9 +30,8 @@ function getIPAdress() {
|
||||
return ret;
|
||||
}
|
||||
|
||||
export default async function dev() {
|
||||
const server = await createServer()
|
||||
|
||||
export default async function dev(serverPort = 7777, resourcePort = 7778) {
|
||||
const server = await createServer(serverPort)
|
||||
|
||||
const cachedContents: Record<string, string> = {}
|
||||
chokidar
|
||||
@ -123,7 +122,7 @@ export default async function dev() {
|
||||
console.log(`IP:${e}`);
|
||||
qrcode.generate(e, { small: true });
|
||||
});
|
||||
createResServer();
|
||||
await createResServer(resourcePort);
|
||||
}
|
||||
|
||||
|
||||
|
@ -25,8 +25,14 @@ commander
|
||||
})
|
||||
commander
|
||||
.command('dev')
|
||||
.action(async function () {
|
||||
await dev()
|
||||
.option('--proxy', 'Link proxy')
|
||||
.action(async function (cmd, args) {
|
||||
const [proxy] = args
|
||||
if (proxy) {
|
||||
console.log("Running in proxy mode", proxy)
|
||||
} else {
|
||||
await dev()
|
||||
}
|
||||
})
|
||||
commander
|
||||
.command('build')
|
||||
@ -58,5 +64,10 @@ commander
|
||||
.action(async function (platform, cmd) {
|
||||
await run(platform);
|
||||
})
|
||||
commander
|
||||
.command('proxy')
|
||||
.action(async function () {
|
||||
await dev()
|
||||
})
|
||||
commander.parse(process.argv)
|
||||
|
||||
|
@ -2,8 +2,7 @@ import fs from "fs"
|
||||
import path from "path"
|
||||
import http from "http";
|
||||
import { IncomingMessage, ServerResponse } from "http";
|
||||
export async function createResServer() {
|
||||
const port = 7778;
|
||||
export async function createResServer(port: number) {
|
||||
const server = http.createServer();
|
||||
server.listen(port);
|
||||
console.log(`resource server is listening on port ${port} !`.green);
|
||||
|
@ -12,12 +12,12 @@ export type MSG = {
|
||||
payload: { [index: string]: string }
|
||||
}
|
||||
|
||||
export async function createServer() {
|
||||
export async function createServer(port: number) {
|
||||
let client: WebSocket | undefined = undefined;
|
||||
let debug: WebSocket | undefined = undefined;
|
||||
let deviceId = 0
|
||||
let debugProcess: ChildProcess | undefined = undefined;
|
||||
const wss = new WebSocket.Server({ port: 7777 })
|
||||
const wss = new WebSocket.Server({ port })
|
||||
.on("connection", (ws, request) => {
|
||||
let thisDeviceId: string
|
||||
console.log('Connected', request.headers.host)
|
||||
|
Reference in New Issue
Block a user