Skip to content

Commit 66efda7

Browse files
committed
Prevent setupDirectories/writeResolvConf from crashing gateway/SSH start
Wrap both calls in try-catch in GatewayService.kt and SshForegroundService.kt so the gateway/SSH process still starts even if directory setup fails. GatewayService now logs warnings if setup fails for debugging. Co-Authored-By: Mithun Gowda B <mithungowda.b7411@gmail.com>
1 parent 4ab8d1f commit 66efda7

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

flutter_app/android/app/src/main/kotlin/com/nxg/openclawproot/GatewayService.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,16 @@ class GatewayService : Service() {
8484
// in case Android cleared them after an app update (#40).
8585
// This must run before proot — it needs bind-mount targets.
8686
val bootstrapManager = BootstrapManager(applicationContext, filesDir, nativeLibDir)
87-
bootstrapManager.setupDirectories()
88-
bootstrapManager.writeResolvConf()
87+
try {
88+
bootstrapManager.setupDirectories()
89+
} catch (e: Exception) {
90+
emitLog("[WARN] setupDirectories failed: ${e.message}")
91+
}
92+
try {
93+
bootstrapManager.writeResolvConf()
94+
} catch (e: Exception) {
95+
emitLog("[WARN] writeResolvConf failed: ${e.message}")
96+
}
8997

9098
gatewayProcess = pm.startProotProcess("openclaw gateway --verbose")
9199
updateNotificationRunning()

flutter_app/android/app/src/main/kotlin/com/nxg/openclawproot/SshForegroundService.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ class SshForegroundService : Service() {
105105

106106
// Ensure directories exist
107107
val bootstrapManager = BootstrapManager(applicationContext, filesDir, nativeLibDir)
108-
bootstrapManager.setupDirectories()
109-
bootstrapManager.writeResolvConf()
108+
try { bootstrapManager.setupDirectories() } catch (_: Exception) {}
109+
try { bootstrapManager.writeResolvConf() } catch (_: Exception) {}
110110

111111
// Generate host keys if missing, configure sshd, then run in
112112
// foreground mode (-D) so the proot process stays alive.

0 commit comments

Comments
 (0)