aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRblSb <msrblsb@gmail.com>2023-01-09 14:15:48 +0300
committerRblSb <msrblsb@gmail.com>2023-01-09 14:15:48 +0300
commit7eafa305e529ddc08d3c656e223529a3129cdf65 (patch)
treede743df9daa3713d5bdd9cde7518f24cfbce67c8 /src
parentbb582f949ecfcd38af7fc2d6c10c6e7efe167f59 (diff)
Add --port argument
for fast multichannel setups
Diffstat (limited to 'src')
-rw-r--r--src/server/Main.hx8
-rw-r--r--src/server/Utils.hx23
2 files changed, 30 insertions, 1 deletions
diff --git a/src/server/Main.hx b/src/server/Main.hx
index 282c09a..a525f65 100644
--- a/src/server/Main.hx
+++ b/src/server/Main.hx
@@ -63,7 +63,8 @@ class Main {
function new(opts:MainOptions) {
isNoState = !opts.loadState;
- verbose = Sys.args().has("--verbose");
+ final args = Utils.parseArgs(Sys.args(), false);
+ verbose = args.exists("verbose");
statePath = '$rootDir/user/state.json';
logsDir = '$rootDir/user/logs';
// process.on("exit", exit);
@@ -97,6 +98,11 @@ class Main {
port = config.port;
final envPort = (process.env : Dynamic).PORT;
if (envPort != null) port = envPort;
+ final argPort = args["port"];
+ if (argPort != null) {
+ final newPort = Std.parseInt(argPort);
+ if (newPort != null) port = newPort;
+ }
var attempts = isNoState ? 500 : 5;
function preparePort():Void {
diff --git a/src/server/Utils.hx b/src/server/Utils.hx
index a2f4382..43160e6 100644
--- a/src/server/Utils.hx
+++ b/src/server/Utils.hx
@@ -6,7 +6,30 @@ import js.node.Os;
import js.node.url.URL;
import sys.FileSystem;
+using StringTools;
+
class Utils {
+ public static function parseArgs(args:Array<String>, caseSensitive = true):Map<String,
+ String> {
+ final map:Map<String, String> = [];
+ for (arg in args) {
+ if (arg.length == 0) continue;
+ if (arg.fastCodeAt(0) == "-".code) {
+ arg = arg.substr(arg.fastCodeAt(1) == "-".code ? 2 : 1);
+ }
+ final delimiterPos = arg.indexOf("=");
+ if (delimiterPos < 1) {
+ final key = caseSensitive ? arg : arg.toLowerCase();
+ map[key] = "";
+ continue;
+ }
+ var key = arg.substr(0, delimiterPos);
+ if (!caseSensitive) key = key.toLowerCase();
+ map[key] = arg.substr(delimiterPos + 1);
+ }
+ return map;
+ }
+
public static function ensureDir(path:String):Void {
if (!FileSystem.exists(path)) FileSystem.createDirectory(path);
}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage