mirror of
https://github.com/samsonjs/vibetunnel.git
synced 2026-04-27 15:17:38 +00:00
Improve Rust server configuration handling
- Use absolute path for static directory to avoid path resolution issues - Quote static path argument to handle paths with spaces - Remove hardcoded default port - now fetched from user defaults via ServerManager - Add port validation to ensure server doesn't start without configured port - Add invalidPort error case for better error handling
This commit is contained in:
parent
67ec9ef118
commit
c0b9cc4b87
2 changed files with 14 additions and 3 deletions
Binary file not shown.
|
|
@ -73,7 +73,7 @@ final class RustServer: ServerProtocol {
|
||||||
|
|
||||||
private(set) var isRunning = false
|
private(set) var isRunning = false
|
||||||
|
|
||||||
var port: String = "4020" {
|
var port: String = "" {
|
||||||
didSet {
|
didSet {
|
||||||
// If server is running and port changed, we need to restart
|
// If server is running and port changed, we need to restart
|
||||||
if isRunning && oldValue != port {
|
if isRunning && oldValue != port {
|
||||||
|
|
@ -94,6 +94,13 @@ final class RustServer: ServerProtocol {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
guard !port.isEmpty else {
|
||||||
|
let error = RustServerError.invalidPort
|
||||||
|
logger.error("Port not configured")
|
||||||
|
logSubject.send(ServerLogEntry(level: .error, message: error.localizedDescription, source: .rust))
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
|
||||||
logger.info("Starting Rust tty-fwd server on port \(self.port)")
|
logger.info("Starting Rust tty-fwd server on port \(self.port)")
|
||||||
logSubject.send(ServerLogEntry(level: .info, message: "Initializing Rust tty-fwd server...", source: .rust))
|
logSubject.send(ServerLogEntry(level: .info, message: "Initializing Rust tty-fwd server...", source: .rust))
|
||||||
|
|
||||||
|
|
@ -138,10 +145,11 @@ final class RustServer: ServerProtocol {
|
||||||
let webPublicExists = FileManager.default.fileExists(atPath: webPublicPath.path)
|
let webPublicExists = FileManager.default.fileExists(atPath: webPublicPath.path)
|
||||||
logger.info("Web public directory at \(webPublicPath.path) exists: \(webPublicExists)")
|
logger.info("Web public directory at \(webPublicPath.path) exists: \(webPublicExists)")
|
||||||
|
|
||||||
let staticPath = "web/public"
|
// Use absolute path for static directory
|
||||||
|
let staticPath = webPublicPath.path
|
||||||
|
|
||||||
// Build command to run tty-fwd through login shell
|
// Build command to run tty-fwd through login shell
|
||||||
let ttyFwdCommand = "\"\(binaryPath)\" --static-path \(staticPath) --serve \(port)"
|
let ttyFwdCommand = "\"\(binaryPath)\" --static-path \"\(staticPath)\" --serve \(port)"
|
||||||
process.arguments = ["-l", "-c", ttyFwdCommand]
|
process.arguments = ["-l", "-c", ttyFwdCommand]
|
||||||
|
|
||||||
logger.info("Executing command: /bin/zsh -l -c \"\(ttyFwdCommand)\"")
|
logger.info("Executing command: /bin/zsh -l -c \"\(ttyFwdCommand)\"")
|
||||||
|
|
@ -468,6 +476,7 @@ enum RustServerError: LocalizedError {
|
||||||
case binaryNotFound
|
case binaryNotFound
|
||||||
case processFailedToStart
|
case processFailedToStart
|
||||||
case serverNotResponding
|
case serverNotResponding
|
||||||
|
case invalidPort
|
||||||
|
|
||||||
var errorDescription: String? {
|
var errorDescription: String? {
|
||||||
switch self {
|
switch self {
|
||||||
|
|
@ -477,6 +486,8 @@ enum RustServerError: LocalizedError {
|
||||||
return "The server process failed to start"
|
return "The server process failed to start"
|
||||||
case .serverNotResponding:
|
case .serverNotResponding:
|
||||||
return "The server process started but is not responding to health checks"
|
return "The server process started but is not responding to health checks"
|
||||||
|
case .invalidPort:
|
||||||
|
return "Server port is not configured"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue