Update server mangement#1
Open
Pikacnu wants to merge 9 commits into
Open
Conversation
Owner
Pikacnu
commented
May 7, 2026
- add resource and log inspect of server
- redesign server management page
- Implemented WebSocket handlers for server log subscriptions in websocket.ts. - Added SERVERLOG message type to type.ts for handling server log messages. - Created ResourceMonitor class to track resource usage of Minecraft server pods. - Developed API endpoints for fetching server logs and resource data. - Introduced ManagementFilesPanel and ManagementFiles components for file management UI. - Added ManagementOverview and ManagementSettings components for server management interface. - Created ManagementSidebar for navigation between different management sections. - Established context for server management files to handle file operations and state. - Defined directory types and structures for file management. - Implemented server log handling logic in serverlogs.ts to manage log streaming.
Comment on lines
40
to
59
| public connect() { | ||
| this.rconClient.on('end', () => { | ||
| this.isEnded = true; | ||
| this.isConnected = false; | ||
| this.retryCount++; | ||
| setTimeout( | ||
| () => { | ||
| this.connect().catch((e) => | ||
| console.error('Failed to reconnect RCON:', (e as Error).message), | ||
| ); | ||
| }, | ||
| 1000 ** Math.min(2 ** this.retryCount, 30), | ||
| ); // Exponential backoff with max delay of 30 seconds | ||
| }); | ||
| this.rconClient.on('connect', () => { | ||
| this.isConnected = true; | ||
| this.isEnded = false; | ||
| this.retryCount = 0; | ||
| }); | ||
| return this.rconClient.connect(); |
Comment on lines
+593
to
+607
| public static async readServerLogs( | ||
| serverName: string, | ||
| lines: number = 100, | ||
| ): Promise<string> { | ||
| const server = Manager.getServerInfoByName(serverName); | ||
| if (!server) { | ||
| throw new Error(`Server ${serverName} not found.`); | ||
| } | ||
| const logsResponse = await coreV1Api.readNamespacedPodLogWithHttpInfo({ | ||
| namespace: Namespace, | ||
| name: this.generateName(server, 'deployment'), | ||
| tailLines: lines, | ||
| }); | ||
| const logs = await logsResponse.body.text(); | ||
| return logs; |
Comment on lines
+610
to
+627
| public static async getFollowedServerLogs( | ||
| serverName: string, | ||
| ): Promise<PassThrough> { | ||
| const server = Manager.getServerInfoByName(serverName); | ||
| if (!server) { | ||
| throw new Error(`Server ${serverName} not found.`); | ||
| } | ||
| const logStream = new PassThrough(); | ||
| k8sLogger.log( | ||
| Namespace, | ||
| server.nameTemplate.replace('@PlaceHolder@', 'deployment'), | ||
| 'minecraft-server', | ||
| logStream, | ||
| { | ||
| follow: true, | ||
| pretty: true, | ||
| }, | ||
| ); |
Comment on lines
+566
to
+590
| public static async executeServerPod( | ||
| serverName: string, | ||
| command: string, | ||
| ): Promise<string> { | ||
| const server = Manager.getServerInfoByName(serverName); | ||
| if (!server) { | ||
| throw new Error(`Server ${serverName} not found.`); | ||
| } | ||
| const executeResponse = | ||
| await coreV1Api.connectPostNamespacedPodExecWithHttpInfo({ | ||
| namespace: Namespace, | ||
| name: server.nameTemplate.replace('@PlaceHolder@', 'pod'), | ||
| command, | ||
| stderr: true, | ||
| stdin: true, | ||
| stdout: true, | ||
| }); | ||
| if (executeResponse.httpStatusCode !== 101) { | ||
| throw new Error( | ||
| `Failed to execute command on server ${serverName}. HTTP status code: ${executeResponse.httpStatusCode}`, | ||
| ); | ||
| } | ||
|
|
||
| const executeResultText = await executeResponse.body.text(); | ||
| return executeResultText; |
Comment on lines
+14
to
+20
| try { | ||
| const resourceData = | ||
| ResourceMonitor.getInstance().getPodDataByName(serverName); | ||
| return Response.json( | ||
| { status: 'ok', data: resourceData ?? null }, | ||
| { status: 200 }, | ||
| ); |
| export async function GET(request: Request): Promise<Response> { | ||
| const url = new URL(request.url); | ||
| const serverName = url.searchParams.get('serverName') || ''; | ||
| const lines = Number(url.searchParams.get('lines') || '120'); |
| } | ||
|
|
||
| const response = await fetch( | ||
| `/api/file-system?name=${serverId}&type=structure`, |
Comment on lines
+380
to
+399
| const value = useMemo<ServerManagementFilesContextType>( | ||
| () => ({ | ||
| fileStructure: optimisticFileStructure, | ||
| selectedFiles, | ||
| setSelectedFiles, | ||
| fetchFileStructure, | ||
| handleFileChange, | ||
| handleFileRead, | ||
| handleCreate, | ||
| handleDelete, | ||
| handleRename, | ||
| handleUpload, | ||
| handleDownload, | ||
| onCompress, | ||
| onUncompress, | ||
| onFileSelect, | ||
| showConfirmDialog, | ||
| }), | ||
| [optimisticFileStructure, selectedFiles, showConfirmDialog, serverId], | ||
| ); |
| <div className='grid min-h-0 grow grid-rows-[minmax(0,1fr)_auto] gap-2'> | ||
| <pre | ||
| ref={terminalRef} | ||
| className='min-h-0 w-full overflow-y-auto rounded-lg bg-black p-2 font-mono text-sm text-white whitespace-pre-wrap wrap-break-word' |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Owner
Author
|
@copilot apply changes based on the comments in this thread |
Agent-Logs-Url: https://github.com/Pikacnu/minecraft-server-manager/sessions/c9117d4d-6d57-4848-9f7c-f42f9d994cec Co-authored-by: Pikacnu <92923578+Pikacnu@users.noreply.github.com>
Applied the actionable fixes from that review thread in commit UI screenshot (RCON terminal update): unable to capture in this sandbox because the browser screenshot tool is currently locked ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.