Skip to content
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

Merged
merged 7 commits into from
Feb 2, 2025
Merged

Conversation

bjia56
Copy link
Collaborator

@bjia56 bjia56 commented Feb 2, 2025

Enable terminalservice to fork across cluster nodes. This allows TTY plugins to tell terminalservice which node to launch its PTY.

const fork = sdk.fork<{
connectTTYStream: typeof connectTTYStream,
}>({ clusterWorkerId });
const result = await fork.result;
Copy link
Owner

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

connectTTYStream: typeof connectTTYStream,
}>({ clusterWorkerId });
const result = await fork.result;
return result.connectTTYStream(input, options);
Copy link
Owner

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.

}

export async function newTerminalService(): Promise<TerminalService> {
return new TerminalService(null, true);
Copy link
Owner

@koush koush Feb 2, 2025

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

Copy link
Collaborator Author

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

Copy link
Collaborator Author

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

Copy link
Collaborator Author

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);
Copy link
Owner

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

@koush koush merged commit 590f955 into koush:main Feb 2, 2025
@bjia56 bjia56 deleted the termsvc-fork branch February 2, 2025 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants