From aa2bf08255f752576f0453a1aa08bb36ef8baa29 Mon Sep 17 00:00:00 2001 From: throwaway Date: Tue, 4 Aug 2026 23:05:11 -0700 Subject: [PATCH] read values from env --- server/hello-world.js | 2 +- server/lib/fplay.js | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/server/hello-world.js b/server/hello-world.js index 2aa8cf3..6442a6e 100644 --- a/server/hello-world.js +++ b/server/hello-world.js @@ -2,7 +2,7 @@ const fplay = require("./lib/fplay.js"); var port = 3030; var timeout = 30000; -var password = "cnc"; +var password = process.env.FOURPLAY_PASSWORD || "cnc"; fplay.event.on("server_ready", function(){ diff --git a/server/lib/fplay.js b/server/lib/fplay.js index d4bd5ff..401abf8 100644 --- a/server/lib/fplay.js +++ b/server/lib/fplay.js @@ -1,11 +1,13 @@ const http = require("http"); const { WebSocketServer } = require("ws"); +const {FOURPLAY_PORT = 3000, FOURPLAY_COMMAND_TIMEOUT = 5000, FOURPLAY_PASSWORD = "cnc"} = process.env; + var fplay = {}; -fplay.PORT = 3030; -fplay.COMMAND_TIMEOUT = 5000; -fplay.PASSWORD = "cnc"; +fplay.PORT = FOURPLAY_PORT; +fplay.COMMAND_TIMEOUT = FOURPLAY_COMMAND_TIMEOUT; +fplay.PASSWORD = FOURPLAY_PASSWORD; const { EventEmitter } = require("events"); fplay.event = new EventEmitter(); @@ -558,4 +560,8 @@ fplay.init = function(port = 3030, password = "cnc", command_timeout = 5000){ }); } +process.on('SIGINT', function() { + process.exit(); +}); + module.exports = fplay;