diff options
| author | RblSb <msrblsb@gmail.com> | 2020-03-06 06:32:01 +0300 |
|---|---|---|
| committer | RblSb <msrblsb@gmail.com> | 2020-03-06 06:32:01 +0300 |
| commit | 0ca7420ad952c0332ab36e37596b0fa53e710325 (patch) | |
| tree | 7e64bbd60ff781df2d5c429f900ec18b75e44703 /src/server/Main.hx | |
| parent | 39767a4b71de751c2b4ee672c3985f52a62e039b (diff) | |
Move server port to config
Diffstat (limited to 'src/server/Main.hx')
| -rw-r--r-- | src/server/Main.hx | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/server/Main.hx b/src/server/Main.hx index 033e2a0..5cac674 100644 --- a/src/server/Main.hx +++ b/src/server/Main.hx @@ -1,11 +1,9 @@ package server; import haxe.crypto.Sha256; -import js.lib.Date; import sys.FileSystem; import sys.io.File; import haxe.Timer; -import Client.ClientData; import haxe.Json; import js.Node.process; import js.Node.__dirname; @@ -13,6 +11,8 @@ import js.npm.ws.Server as WSServer; import js.npm.ws.WebSocket; import js.node.http.IncomingMessage; import js.node.Http; +import js.lib.Date; +import Client.ClientData; import Types.Config; import Types.Permission; import Types.UserList; @@ -43,9 +43,7 @@ class Main { static function main():Void new Main(); - public function new(port = 4200, ?wsPort:Int) { - final envPort = (process.env : Dynamic).PORT; - if (envPort != null) port = envPort; + function new() { statePath = '$rootDir/user/state.json'; // process.on("exit", exit); process.on("SIGINT", exit); // ctrl+c @@ -72,7 +70,9 @@ class Main { config.salt = generateConfigSalt(); localIp = Utils.getLocalIp(); globalIp = localIp; - this.port = port; + port = config.port; + final envPort = (process.env : Dynamic).PORT; + if (envPort != null) port = envPort; Utils.getGlobalIp(ip -> { globalIp = ip; @@ -88,7 +88,7 @@ class Main { HttpServer.serveFiles(req, res); }); server.listen(port); - wss = new WSServer({server: server, port: wsPort}); + wss = new WSServer({server: server}); wss.on("connection", onConnect); } |
