diff --git a/src/cli/edge-health.ts b/src/cli/edge-health.ts index 7e4f7183..3a80249e 100644 --- a/src/cli/edge-health.ts +++ b/src/cli/edge-health.ts @@ -172,14 +172,14 @@ const checks: Check[] = [ priority: 10, emoji: `:park:`, isHealthy: false, - url: `https://proxy.pockethost.io/api/health`, + url: `https://proxy.pockethost.io/_api/health`, }, { name: `edge daemon`, priority: 8, emoji: `:imp:`, isHealthy: false, - url: `http://localhost:${DAEMON_PORT()}/api/health`, + url: `http://localhost:${DAEMON_PORT()}/_api/health`, }, { name: `mothership`, diff --git a/src/cli/proxy/server.ts b/src/cli/proxy/server.ts index e0151174..7684c985 100644 --- a/src/cli/proxy/server.ts +++ b/src/cli/proxy/server.ts @@ -44,7 +44,7 @@ forEach(hostnameRoutes, (target, host) => { app.use(createVhostProxyMiddleware(host, target, IS_DEV())) }) -app.get(`/api/health`, (req, res, next) => { +app.get(`/_api/health`, (req, res, next) => { res.json({ status: 'ok' }) res.end() }) diff --git a/src/constants.ts b/src/constants.ts index 193cdf2f..eb44485c 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -102,6 +102,8 @@ export const SETTINGS = { SYSLOGD_PORT: mkNumber(6514), DISCORD_HEALTH_CHANNEL_URL: mkString(''), + + DOCKER_CONTAINER_HOST: mkString(`host.docker.internal`), } ;(() => { let passed = true @@ -230,6 +232,8 @@ export const SYSLOGD_PORT = () => settings().SYSLOGD_PORT export const DISCORD_HEALTH_CHANNEL_URL = () => settings().DISCORD_HEALTH_CHANNEL_URL +export const DOCKER_CONTAINER_HOST = () => settings().DOCKER_CONTAINER_HOST + /** Helpers */ export const MOTHERSHIP_DATA_ROOT = () => INSTANCE_DATA_ROOT(MOTHERSHIP_NAME()) diff --git a/src/services/InstanceService/index.ts b/src/services/InstanceService/index.ts index ed4330a5..4247e6ef 100644 --- a/src/services/InstanceService/index.ts +++ b/src/services/InstanceService/index.ts @@ -301,19 +301,17 @@ export const instanceService = mkSingleton( return cp } catch (e) { warn(`Error spawning: ${e}`) + userInstanceLogger.error(`Error spawning: ${e}`) if (UPGRADE_MODE()) { - throw new Error( - `PocketHost is rebooting. Try again in a few seconds.`, - ) + // Noop } else { await updateInstance(instance.id, { maintenance: true, }) - userInstanceLogger.error( - `Could not launch container. Instance has been placed in maintenance mode. Please review your instance logs at https://app.pockethost.io/app/instances/${instance.id} or contact support at https://pockethost.io/support`, - ) - throw new Error(`Maintenance mode`) } + throw new Error( + `Could not launch container. Instance has been placed in maintenance mode. Please review your instance logs at https://app.pockethost.io/app/instances/${instance.id} or contact support at https://pockethost.io/support`, + ) } })() const { pid: _pid, exitCode } = childProcess diff --git a/src/services/PocketBaseService/index.ts b/src/services/PocketBaseService/index.ts index 31513d9c..41ed2e1c 100644 --- a/src/services/PocketBaseService/index.ts +++ b/src/services/PocketBaseService/index.ts @@ -1,16 +1,17 @@ import { APEX_DOMAIN, - SYSLOGD_PORT, + DOCKER_CONTAINER_HOST, mkContainerHomePath, mkInstanceDataPath, + SYSLOGD_PORT, } from '$constants' import { PortService } from '$services' import { - LoggerService, - SingletonBaseConfig, createCleanupManager, createTimerManager, + LoggerService, mkSingleton, + SingletonBaseConfig, } from '$shared' import { assert, asyncExitHook, mkInternalUrl, tryFetch } from '$util' import { map } from '@s-libs/micro-dash' @@ -148,7 +149,7 @@ export const createPocketbaseService = async ( LogConfig: { Type: 'syslog', Config: { - 'syslog-address': `udp://localhost:${SYSLOGD_PORT()}`, + 'syslog-address': `udp://${DOCKER_CONTAINER_HOST()}:${SYSLOGD_PORT()}`, tag: instanceId, }, }, diff --git a/src/services/ProxyService.ts b/src/services/ProxyService.ts index 6ce964cc..6dd1492e 100644 --- a/src/services/ProxyService.ts +++ b/src/services/ProxyService.ts @@ -44,7 +44,7 @@ export const proxyService = mkSingleton(async (config: ProxyServiceConfig) => { server.use(cors()) - server.get('/api/health', (req, res, next) => { + server.get('/_api/health', (req, res, next) => { res.json({ status: 'ok' }) res.end })