修改配置项

This commit is contained in:
2026-04-11 15:53:39 +08:00
parent 07fdcb7950
commit 9d6eecec00
3 changed files with 26 additions and 25 deletions

View File

@@ -13,28 +13,30 @@ export class RenderStreaming {
public static run(argv: string[]): RenderStreaming {
const program = new Command();
const readOptions = (): Options => {
if (Array.isArray(argv)) {
program
.usage('[options] <apps...>')
.option('-p, --port <n>', 'Port to start the server on.', process.env.PORT || `80`)
.option('-s, --secure', 'Enable HTTPS (you need server.key and server.cert).', process.env.SECURE || false)
.option('-k, --keyfile <path>', 'https key file.', process.env.KEYFILE || 'server.key')
.option('-c, --certfile <path>', 'https cert file.', process.env.CERTFILE || 'server.cert')
.option('-t, --type <type>', 'Type of signaling protocol, Choose websocket or http.', process.env.TYPE || 'websocket')
.option('-m, --mode <type>', 'Choose Communication mode public or private.', process.env.MODE || 'public')
.option('-l, --logging <type>', 'Choose http logging type combined, dev, short, tiny or none.', process.env.LOGGING || 'dev')
.parse(argv);
const option = program.opts();
return {
port: option.port,
secure: option.secure == undefined ? false : option.secure,
keyfile: option.keyfile,
certfile: option.certfile,
type: option.type == undefined ? 'websocket' : option.type,
mode: option.mode,
logging: option.logging,
};
}
// 确保argv是数组
const args = Array.isArray(argv) ? argv : process.argv;
program
.usage('[options] <apps...>')
.option('-p, --port <n>', 'Port to start the server on.', process.env.PORT || `80`)
.option('-s, --secure', 'Enable HTTPS (you need server.key and server.cert).', process.env.SECURE || true)
.option('-k, --keyfile <path>', 'https key file.', process.env.KEYFILE || 'server.key')
.option('-c, --certfile <path>', 'https cert file.', process.env.CERTFILE || 'server.cert')
.option('-t, --type <type>', 'Type of signaling protocol, Choose websocket or http.', process.env.TYPE || 'websocket')
.option('-m, --mode <type>', 'Choose Communication mode public or private.', process.env.MODE || 'public')
.option('-l, --logging <type>', 'Choose http logging type combined, dev, short, tiny or none.', process.env.LOGGING || 'dev')
.parse(args);
const option = program.opts();
return {
port: option.port,
secure: option.secure == undefined ? false : option.secure,
keyfile: option.keyfile,
certfile: option.certfile,
type: option.type == undefined ? 'websocket' : option.type,
mode: option.mode,
logging: option.logging,
};
};
const options = readOptions();
return new RenderStreaming(options);