mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Add server plugin loader
This commit is contained in:
16
server.js
16
server.js
@ -93,9 +93,9 @@ const cliArguments = yargs(hideBin(process.argv))
|
||||
}).parseSync();
|
||||
|
||||
// change all relative paths
|
||||
const directory = process['pkg'] ? path.dirname(process.execPath) : __dirname;
|
||||
const serverDirectory = process['pkg'] ? path.dirname(process.execPath) : __dirname;
|
||||
console.log(process['pkg'] ? 'Running from binary' : 'Running from source');
|
||||
process.chdir(directory);
|
||||
process.chdir(serverDirectory);
|
||||
|
||||
const app = express();
|
||||
app.use(compression());
|
||||
@ -621,6 +621,8 @@ const setupTasks = async function () {
|
||||
exitProcess();
|
||||
});
|
||||
|
||||
await loadPlugins();
|
||||
|
||||
console.log('Launching...');
|
||||
|
||||
if (autorun) open(autorunUrl.toString());
|
||||
@ -632,6 +634,16 @@ const setupTasks = async function () {
|
||||
}
|
||||
};
|
||||
|
||||
async function loadPlugins() {
|
||||
try {
|
||||
const pluginDirectory = path.join(serverDirectory, 'plugins');
|
||||
const loader = require('./src/plugin-loader');
|
||||
await loader.loadPlugins(app, pluginDirectory);
|
||||
} catch {
|
||||
console.log('Plugin loading failed.');
|
||||
}
|
||||
}
|
||||
|
||||
if (listen && !getConfigValue('whitelistMode', true) && !getConfigValue('basicAuthMode', false)) {
|
||||
if (getConfigValue('securityOverride', false)) {
|
||||
console.warn(color.red('Security has been overridden. If it\'s not a trusted network, change the settings.'));
|
||||
|
Reference in New Issue
Block a user