Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: honor configured server bind address in PM2 (#10946)
Adam Eivyce5659a4bcef
diff --git a/.env.example b/.env.exampleindex 846d0584e0..dbe6772400 100644--- a/.env.example+++ b/.env.example@@ -53,7 +53,8 @@ PGPASSWORD=portos# PORTOS_API_URL=https://my-machine.ts.net:5555# PORTOS_UI_URL=https://my-machine.ts.net:5555-# Server host binding for Express listen (default: 0.0.0.0)+# Server host binding for Express listen (default: 0.0.0.0). PM2 honors this for+# portos-server only (exported HOST wins over .env); CoS/CDP stay on loopback.# HOST=0.0.0.0# Public-facing hostname baked into OAuth redirect URIs for Google Calendar/Gmaildiff --git a/ecosystem.config.cjs b/ecosystem.config.cjsindex 16e55cd4a3..57fcad64fc 100644--- a/ecosystem.config.cjs+++ b/ecosystem.config.cjs@@ -44,6 +44,8 @@ const PG_USER = process.env.PGUSER || envPgUser || 'portos';const PG_DATABASE = process.env.PGDATABASE || envPgDatabase || 'portos';const PG_PASSWORD = process.env.PGPASSWORD || envPgPassword || 'portos';const PG_HOST = process.env.PGHOST || envPgHost || 'localhost';+// Express bind for portos-server only: nonempty exported HOST → .env → all interfaces (#10946).+const SERVER_HOST = process.env.HOST || envValue('HOST') || '0.0.0.0';// pm2 restarts portos-server when its RSS crosses this — originally a memory-leak// safety valve. The committed default stays modest so the guard still fires on a@@ -208,7 +210,7 @@ module.exports = {UV_THREADPOOL_SIZE: '16',PORT: PORTS.API,PORTOS_HTTP_PORT: resolveHttpMirrorPort({ dotenv }), // exported > .env > PORTS.API_LOCAL (#10950); Loopback HTTP mirror when HTTPS is active- HOST: '0.0.0.0',+ HOST: SERVER_HOST,PGHOST: PG_HOST,PGPORT: PG_PORT,PORTOS_NATIVE_PGPORT: DATABASE_ENDPOINTS.native.port,diff --git a/scripts/ecosystemEnv.test.js b/scripts/ecosystemEnv.test.jsindex 6daa4d156c..e624662c74 100644--- a/scripts/ecosystemEnv.test.js+++ b/scripts/ecosystemEnv.test.js@@ -269,3 +269,35 @@ describe('ecosystem.config.cjs loopback HTTP mirror port (#10950)', () => {expect(mirrorOf(`PORTOS_HTTP_PORT=${bad}\n`, {}).port).toBe(5553);});});++describe('ecosystem.config.cjs server bind HOST (#10946)', () => {+ const hostOf = (envContent, overrides = {}) => {+ const apps = loadConfig(envContent, { HOST: undefined, ...overrides }).apps;+ return Object.fromEntries(apps.map((a) => [a.name, a.env]));+ };++ it('defaults to all interfaces', () => {+ expect(hostOf(null)['portos-server'].HOST).toBe('0.0.0.0');+ });++ it('honors a loopback HOST saved only in .env', () => {+ expect(hostOf('HOST=127.0.0.1\n')['portos-server'].HOST).toBe('127.0.0.1');+ });++ it('lets a nonempty exported HOST win over .env', () => {+ expect(hostOf('HOST=127.0.0.1\n', { HOST: '192.0.2.10' })['portos-server'].HOST).toBe('192.0.2.10');+ });++ it('treats an empty export or empty .env value as unset', () => {+ expect(hostOf(null, { HOST: '' })['portos-server'].HOST).toBe('0.0.0.0');+ expect(hostOf('HOST=\n')['portos-server'].HOST).toBe('0.0.0.0');+ expect(hostOf('HOST=127.0.0.1\n', { HOST: '' })['portos-server'].HOST).toBe('127.0.0.1');+ });++ it('keeps CoS and CDP loopback bindings independent of the override', () => {+ const envs = hostOf('HOST=192.0.2.10\n', { HOST: '192.0.2.11' });+ expect(envs['portos-cos'].HOST).toBe('127.0.0.1');+ expect(envs['portos-browser'].CDP_HOST).toBe('127.0.0.1');+ expect(envs['portos-browser'].HOST).not.toBe('192.0.2.11');+ });+});