Skip to content

Commit

Permalink
Fix shutdown issue and tidy up
Browse files Browse the repository at this point in the history
  • Loading branch information
louislam committed Oct 12, 2023
1 parent a3a81f8 commit aa67615
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
6 changes: 1 addition & 5 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ if (!semver.satisfies(nodeVersion, requiredNodeVersions)) {

const args = require("args-parser")(process.argv);
const { sleep, log, getRandomInt, genSecret, isDev } = require("../src/util");
const config = require("./config");

log.info("server", "Welcome to Uptime Kuma");
log.debug("server", "Arguments");
Expand Down Expand Up @@ -71,6 +70,7 @@ const notp = require("notp");
const base32 = require("thirty-two");

const { UptimeKumaServer } = require("./uptime-kuma-server");

const server = UptimeKumaServer.getInstance(args);
const io = module.exports.io = server.io;
const app = server.app;
Expand Down Expand Up @@ -135,10 +135,6 @@ const twoFAVerifyOptions = {
const testMode = !!args["test"] || false;
const e2eTestMode = !!args["e2e"] || false;

if (config.demoMode) {
log.info("server", "==== Demo Mode ====");
}

// Must be after io instantiation
const { sendNotificationList, sendHeartbeatList, sendInfo, sendProxyList, sendDockerHostList, sendAPIKeyList } = require("./client");
const { statusPageSocketHandler } = require("./socket-handlers/status-page-socket-handler");
Expand Down
13 changes: 9 additions & 4 deletions server/util-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ const {
},
} = require("node-radius-utils");
const dayjs = require("dayjs");
const readline = require("readline");
const rl = readline.createInterface({ input: process.stdin,
output: process.stdout });

// SASLOptions used in JSDoc
// eslint-disable-next-line no-unused-vars
Expand Down Expand Up @@ -1079,7 +1076,15 @@ module.exports.shake256 = (data, len) => {
.digest("hex");
};

module.exports.prompt = (query) => new Promise((resolve) => rl.question(query, resolve));
/**
* Non await sleep
* Source: https://stackoverflow.com/questions/59099454/is-there-a-way-to-call-sleep-without-await-keyword
* @param {number} n Milliseconds to wait
* @returns {void}
*/
module.exports.wait = (n) => {
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, n);
};

// For unit test, export functions
if (process.env.TEST_BACKEND) {
Expand Down

0 comments on commit aa67615

Please sign in to comment.