mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2024-11-15 02:50:10 +01:00
dc4ad6b5a9
* wip bg workers for live document sync * Add ability to re-embed specific documents across many workspaces via background queue bgworkser is gated behind expieremental system setting flag that needs to be explictly enabled UI for watching/unwatching docments that are embedded. TODO: UI to easily manage all bg tasks and see run results TODO: UI to enable this feature and background endpoints to manage it * create frontend views and paths Move elements to correct experimental scope * update migration to delete runs on removal of watched document * Add watch support to YouTube transcripts (#1716) * Add watch support to YouTube transcripts refactor how sync is done for supported types * Watch specific files in Confluence space (#1718) Add failure-prune check for runs * create tmp workflow modifications for beta image * create tmp workflow modifications for beta image * create tmp workflow modifications for beta image * dual build update copy of alert modals * update job interval * Add support for live-sync of Github files * update copy for document sync feature * hide Experimental features from UI * update docs links * [FEAT] Implement new settings menu for experimental features (#1735) * implement new settings menu for experimental features * remove unused context save bar --------- Co-authored-by: timothycarambat <rambat1010@gmail.com> * dont run job on boot * unset workflow changes * Add persistent encryption service Relay key to collector so persistent encryption can be used Encrypt any private data in chunkSources used for replay during resync jobs * update jsDOC * Linting and organization * update modal copy for feature --------- Co-authored-by: Sean Hatfield <seanhatfield5@gmail.com>
76 lines
2.2 KiB
JavaScript
76 lines
2.2 KiB
JavaScript
const { Telemetry } = require("../../models/telemetry");
|
|
const { BackgroundService } = require("../BackgroundWorkers");
|
|
const { EncryptionManager } = require("../EncryptionManager");
|
|
const { CommunicationKey } = require("../comKey");
|
|
const setupTelemetry = require("../telemetry");
|
|
|
|
function bootSSL(app, port = 3001) {
|
|
try {
|
|
console.log(
|
|
`\x1b[33m[SSL BOOT ENABLED]\x1b[0m Loading the certificate and key for HTTPS mode...`
|
|
);
|
|
const fs = require("fs");
|
|
const https = require("https");
|
|
const privateKey = fs.readFileSync(process.env.HTTPS_KEY_PATH);
|
|
const certificate = fs.readFileSync(process.env.HTTPS_CERT_PATH);
|
|
const credentials = { key: privateKey, cert: certificate };
|
|
const server = https.createServer(credentials, app);
|
|
|
|
server
|
|
.listen(port, async () => {
|
|
await setupTelemetry();
|
|
new CommunicationKey(true);
|
|
new EncryptionManager();
|
|
new BackgroundService().boot();
|
|
console.log(`Primary server in HTTPS mode listening on port ${port}`);
|
|
})
|
|
.on("error", catchSigTerms);
|
|
|
|
require("express-ws")(app, server); // Apply same certificate + server for WSS connections
|
|
return { app, server };
|
|
} catch (e) {
|
|
console.error(
|
|
`\x1b[31m[SSL BOOT FAILED]\x1b[0m ${e.message} - falling back to HTTP boot.`,
|
|
{
|
|
ENABLE_HTTPS: process.env.ENABLE_HTTPS,
|
|
HTTPS_KEY_PATH: process.env.HTTPS_KEY_PATH,
|
|
HTTPS_CERT_PATH: process.env.HTTPS_CERT_PATH,
|
|
stacktrace: e.stack,
|
|
}
|
|
);
|
|
return bootHTTP(app, port);
|
|
}
|
|
}
|
|
|
|
function bootHTTP(app, port = 3001) {
|
|
if (!app) throw new Error('No "app" defined - crashing!');
|
|
|
|
app
|
|
.listen(port, async () => {
|
|
await setupTelemetry();
|
|
new CommunicationKey(true);
|
|
new EncryptionManager();
|
|
new BackgroundService().boot();
|
|
console.log(`Primary server in HTTP mode listening on port ${port}`);
|
|
})
|
|
.on("error", catchSigTerms);
|
|
|
|
return { app, server: null };
|
|
}
|
|
|
|
function catchSigTerms() {
|
|
process.once("SIGUSR2", function () {
|
|
Telemetry.flush();
|
|
process.kill(process.pid, "SIGUSR2");
|
|
});
|
|
process.on("SIGINT", function () {
|
|
Telemetry.flush();
|
|
process.kill(process.pid, "SIGINT");
|
|
});
|
|
}
|
|
|
|
module.exports = {
|
|
bootHTTP,
|
|
bootSSL,
|
|
};
|