feat: add Termux/proot environment compatibility (#457)
- Add init system detection (systemd/launchd/windows-service/other) - Automatically use "gateway run" mode for environments without service managers (WSL/Docker/Termux/proot) - Add safeNetworkInterfaces() wrapper to handle uv_interface_addresses permission errors in proot - Prevents ERR_SYSTEM_ERROR (errno 13) when os.networkInterfaces() fails in restricted environments Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -39,6 +39,18 @@ process.on('unhandledRejection', (reason) => {
|
||||
let server: any = null
|
||||
let chatRunServer: any = null
|
||||
|
||||
/**
|
||||
* 安全获取网络接口信息(兼容 Termux/proot 环境)
|
||||
* 在 proot 环境中 os.networkInterfaces() 会抛出权限错误(errno 13)
|
||||
*/
|
||||
function safeNetworkInterfaces() {
|
||||
try {
|
||||
return os.networkInterfaces()
|
||||
} catch {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
export async function bootstrap() {
|
||||
console.log(`hermes-web-ui v${APP_VERSION} starting...`)
|
||||
await mkdir(config.uploadDir, { recursive: true })
|
||||
@@ -123,7 +135,7 @@ export async function bootstrap() {
|
||||
})
|
||||
|
||||
server.on('listening', () => {
|
||||
const interfaces = os.networkInterfaces()
|
||||
const interfaces = safeNetworkInterfaces()
|
||||
const localIp = Object.values(interfaces).flat().find(i => i?.family === 'IPv4' && !i?.internal)?.address || 'localhost'
|
||||
console.log(`Server: http://localhost:${config.port} (LAN: http://${localIp}:${config.port})`)
|
||||
console.log(`Upstream: ${config.upstream}`)
|
||||
|
||||
Reference in New Issue
Block a user