Skip to content

Commit

Permalink
postbeta
Browse files Browse the repository at this point in the history
  • Loading branch information
koush committed Apr 10, 2024
1 parent fb37f9f commit 16d3890
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@scrypted/server",
"version": "0.98.0",
"version": "0.98.1",
"description": "",
"dependencies": {
"@mapbox/node-pre-gyp": "^1.0.11",
Expand Down
4 changes: 0 additions & 4 deletions server/src/plugin/plugin-host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,6 @@ export class PluginHost {
logger.log('e', `${this.pluginName} close`);
disconnect();
});
this.worker.on('disconnect', () => {
logger.log('e', `${this.pluginName} disconnected`);
disconnect();
});
this.worker.on('exit', async (code, signal) => {
logger.log('e', `${this.pluginName} exited ${code} ${signal}`);
disconnect();
Expand Down
5 changes: 2 additions & 3 deletions server/src/plugin/runtime/child-process-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ export abstract class ChildProcessWorker extends EventEmitter implements Runtime
}

setupWorker() {
this.worker.on('close', () => this.emit('close'));
this.worker.on('disconnect', () => this.emit('disconnect'));
this.worker.on('close', (code: number | null, signal: NodeJS.Signals | null) => this.emit('close', code, signal));
this.worker.on('disconnect', () => this.emit('error', new Error('disconnect')));
this.worker.on('exit', (code, signal) => this.emit('exit', code, signal));
this.worker.on('close', () => this.emit('close'));
this.worker.on('error', e => this.emit('error', e));
}

Expand Down
7 changes: 5 additions & 2 deletions server/src/plugin/runtime/runtime-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ export interface RuntimeWorker {
kill(): void;

on(event: 'rpc', listener: (message: any, sendHandle: net.Socket) => void): this;

on(event: 'error', listener: (err: Error) => void): this;
on(event: 'close', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
on(event: 'disconnect', listener: () => void): this;
on(event: 'exit', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
on(event: 'close', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;

once(event: 'error', listener: (err: Error) => void): this;
once(event: 'exit', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
once(event: 'close', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;

send(message: RpcMessage, reject?: (e: Error) => void, serializationContext?: any): void;

Expand Down
7 changes: 5 additions & 2 deletions server/src/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ export class ScryptedRuntime extends PluginHttp<HttpPluginData> {
}

setupPluginHostAutoRestart(pluginHost: PluginHost) {
pluginHost.worker.once('exit', () => {
const restart = () => {
if (pluginHost.killed)
return;
pluginHost.kill();
Expand All @@ -653,7 +653,10 @@ export class ScryptedRuntime extends PluginHttp<HttpPluginData> {
console.error('error restarting plugin', plugin._id, e);
}
}, timeout);
});
};
pluginHost.worker.once('error', restart);
pluginHost.worker.once('exit', restart);
pluginHost.worker.once('close', restart);
}

loadPlugin(plugin: Plugin, pluginDebug?: PluginDebug) {
Expand Down

0 comments on commit 16d3890

Please sign in to comment.