-
-
Notifications
You must be signed in to change notification settings - Fork 270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core: terminalservice fork across cluster #1721
Conversation
plugins/core/src/terminal-service.ts
Outdated
const fork = sdk.fork<{ | ||
connectTTYStream: typeof connectTTYStream, | ||
}>({ clusterWorkerId }); | ||
const result = await fork.result; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this fork needs to be exited somehow
plugins/core/src/terminal-service.ts
Outdated
connectTTYStream: typeof connectTTYStream, | ||
}>({ clusterWorkerId }); | ||
const result = await fork.result; | ||
return result.connectTTYStream(input, options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if fork.result throws, or connectTTYstream throws, I would also call fork.terminate to force immediate cleanup.
plugins/core/src/terminal-service.ts
Outdated
} | ||
|
||
export async function newTerminalService(): Promise<TerminalService> { | ||
return new TerminalService(null, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this may cause weird issues creating another scrtyped device with a native id not belonging to it (undefined/null is the plugin). I'd use the correct native id
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how important this parameter is given the primary device is constructed like this: https://github.com/koush/scrypted/blob/main/plugins/core/src/main.ts#L245
It's probably more of an issue if it needs access to storage, which we don't use in the class today
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you'd like I can also fix the primary device
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^ updated
@@ -242,7 +242,7 @@ class ScryptedCore extends ScryptedDeviceBase implements HttpRequestHandler, Dev | |||
if (nativeId === UsersNativeId) | |||
return this.users ||= new UsersCore(); | |||
if (nativeId === TerminalServiceNativeId) | |||
return this.terminalService ||= new TerminalService(); | |||
return this.terminalService ||= new TerminalService(TerminalServiceNativeId, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh weird what the hell was this a bug
Enable
terminalservice
to fork across cluster nodes. This allows TTY plugins to tellterminalservice
which node to launch its PTY.