mirror of
https://github.com/koush/scrypted.git
synced 2026-02-10 01:02:18 +00:00
server: force gc to address memory leaks
This commit is contained in:
@@ -55,9 +55,9 @@
|
||||
},
|
||||
"scripts": {
|
||||
"preserve": "npm run build",
|
||||
"serve": "node dist/scrypted-main.js",
|
||||
"serve-no-build": "node dist/scrypted-main.js",
|
||||
"ts-serve": "ts-node src/scrypted-main.ts",
|
||||
"serve": "node --expose-gc dist/scrypted-main.js",
|
||||
"serve-no-build": "node --expose-gc dist/scrypted-main.js",
|
||||
"ts-serve": "ts-node --expose-gc src/scrypted-main.ts",
|
||||
"prebuild": "tsc --build --clean",
|
||||
"build": "tsc --outDir dist",
|
||||
"postbuild": "node test/check-build-output.js"
|
||||
|
||||
@@ -421,7 +421,8 @@ export function startPluginClusterWorker() {
|
||||
type: 'stats',
|
||||
cpu: cpuUsage,
|
||||
memoryUsage: process.memoryUsage(),
|
||||
})
|
||||
});
|
||||
global?.gc();
|
||||
}, 10000);
|
||||
|
||||
const consolePort = createConsoleServer(events);
|
||||
|
||||
@@ -444,18 +444,24 @@ export class ScryptedRuntime {
|
||||
this.invalidatePluginDevice(pluginDevice._id);
|
||||
}
|
||||
|
||||
const execArgv = ['--expose-gc'];
|
||||
if (process.argv[0].endsWith('ts-node'))
|
||||
execArgv.push('-r', 'ts-node/register');
|
||||
|
||||
if (pluginDebug) {
|
||||
console.log('plugin inspect port', pluginDebug.inspectPort)
|
||||
execArgv.push('--inspect');
|
||||
|
||||
cluster.setupMaster({
|
||||
silent: true,
|
||||
inspectPort: pluginDebug.inspectPort,
|
||||
execArgv: process.argv[0].endsWith('ts-node') ? ['--inspect', '-r', 'ts-node/register'] : ['--inspect'],
|
||||
execArgv,
|
||||
});
|
||||
}
|
||||
else {
|
||||
cluster.setupMaster({
|
||||
silent: true,
|
||||
execArgv: process.argv[0].endsWith('ts-node') ? ['-r', 'ts-node/register'] : [],
|
||||
execArgv,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user