[PR #539] [MERGED] feat: embed backend server in Electron desktop app #335

Closed
opened 2026-05-06 12:38:12 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/Termix-SSH/Termix/pull/539
Author: @ZacharyZcR
Created: 1/28/2026
Status: Merged
Merged: 2/20/2026
Merged by: @LukeGus

Base: dev-1.11.2Head: feat/electron-embedded-server


📝 Commits (3)

  • 14c64f7 feat: embed backend server in Electron desktop app
  • 9c5048e fix: improve electron embedded server reliability
  • 45d520c feat: system tray minimize and runtime server switching

📊 Changes

5 files changed (+314 additions, -117 deletions)

View changed files

📝 electron-builder.json (+6 -1)
📝 electron/main.cjs (+249 -116)
📝 src/backend/database/database.ts (+31 -0)
📝 src/backend/starter.ts (+11 -0)
📝 src/ui/desktop/navigation/LeftSidebar.tsx (+17 -0)

📄 Description

Summary

  • Fork an embedded backend process on Electron app startup, enabling a zero-deployment desktop experience
  • Store backend data in userData/server-data; unpack native modules (better-sqlite3, ssh2) and dist from asar for the forked process
  • Add frontend static file serving and SPA fallback in Express backend for iframe auth flow
  • Use IPC message for graceful shutdown (SIGTERM doesn't work on Windows)
  • Wait for backend ready signal before creating the main window (15s timeout fallback)
  • Extract shared httpFetch utility to eliminate duplicate fetch polyfill

Files Changed

  • electron/main.cjs — Backend lifecycle management (start/stop/ready wait), shared httpFetch, IPC shutdown
  • electron-builder.json — Add better-sqlite3, ssh2, dist to asarUnpack
  • src/backend/database/database.ts — Add frontend static file serving and SPA fallback for embedded mode
  • src/backend/starter.ts — Add IPC shutdown message handler

Test Plan

  • Fresh install and launch Electron — verify backend auto-starts and listens on port
  • Register a new user on first run — verify login flow works
  • Close the app — verify backend process is cleaned up (no orphan processes)
  • Verify remote server connection functionality is unaffected
  • Test on Windows — verify graceful shutdown via IPC works correctly

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Termix-SSH/Termix/pull/539 **Author:** [@ZacharyZcR](https://github.com/ZacharyZcR) **Created:** 1/28/2026 **Status:** ✅ Merged **Merged:** 2/20/2026 **Merged by:** [@LukeGus](https://github.com/LukeGus) **Base:** `dev-1.11.2` ← **Head:** `feat/electron-embedded-server` --- ### 📝 Commits (3) - [`14c64f7`](https://github.com/Termix-SSH/Termix/commit/14c64f763c82dcb2f5df5ec396d98336a60c4f2b) feat: embed backend server in Electron desktop app - [`9c5048e`](https://github.com/Termix-SSH/Termix/commit/9c5048edc9ef559b8b8dda0d0fb9397c061bd6df) fix: improve electron embedded server reliability - [`45d520c`](https://github.com/Termix-SSH/Termix/commit/45d520cdaa17f867be5fd7bea18bfce064872da4) feat: system tray minimize and runtime server switching ### 📊 Changes **5 files changed** (+314 additions, -117 deletions) <details> <summary>View changed files</summary> 📝 `electron-builder.json` (+6 -1) 📝 `electron/main.cjs` (+249 -116) 📝 `src/backend/database/database.ts` (+31 -0) 📝 `src/backend/starter.ts` (+11 -0) 📝 `src/ui/desktop/navigation/LeftSidebar.tsx` (+17 -0) </details> ### 📄 Description ## Summary - Fork an embedded backend process on Electron app startup, enabling a zero-deployment desktop experience - Store backend data in `userData/server-data`; unpack native modules (better-sqlite3, ssh2) and dist from asar for the forked process - Add frontend static file serving and SPA fallback in Express backend for iframe auth flow - Use IPC message for graceful shutdown (SIGTERM doesn't work on Windows) - Wait for backend ready signal before creating the main window (15s timeout fallback) - Extract shared `httpFetch` utility to eliminate duplicate fetch polyfill ## Files Changed - `electron/main.cjs` — Backend lifecycle management (start/stop/ready wait), shared httpFetch, IPC shutdown - `electron-builder.json` — Add better-sqlite3, ssh2, dist to asarUnpack - `src/backend/database/database.ts` — Add frontend static file serving and SPA fallback for embedded mode - `src/backend/starter.ts` — Add IPC shutdown message handler ## Test Plan - [ ] Fresh install and launch Electron — verify backend auto-starts and listens on port - [ ] Register a new user on first run — verify login flow works - [ ] Close the app — verify backend process is cleaned up (no orphan processes) - [ ] Verify remote server connection functionality is unaffected - [ ] Test on Windows — verify graceful shutdown via IPC works correctly --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 12:38:12 +02:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/Termix#335
No description provided.