Merge branch 'master' of github.com:pockethost/pockethost

This commit is contained in:
Ben Allfree 2024-01-24 13:36:45 -08:00
commit b500f0d639
6 changed files with 18 additions and 15 deletions

View File

@ -172,14 +172,14 @@ const checks: Check[] = [
priority: 10, priority: 10,
emoji: `:park:`, emoji: `:park:`,
isHealthy: false, isHealthy: false,
url: `https://proxy.pockethost.io/api/health`, url: `https://proxy.pockethost.io/_api/health`,
}, },
{ {
name: `edge daemon`, name: `edge daemon`,
priority: 8, priority: 8,
emoji: `:imp:`, emoji: `:imp:`,
isHealthy: false, isHealthy: false,
url: `http://localhost:${DAEMON_PORT()}/api/health`, url: `http://localhost:${DAEMON_PORT()}/_api/health`,
}, },
{ {
name: `mothership`, name: `mothership`,

View File

@ -44,7 +44,7 @@ forEach(hostnameRoutes, (target, host) => {
app.use(createVhostProxyMiddleware(host, target, IS_DEV())) 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.json({ status: 'ok' })
res.end() res.end()
}) })

View File

@ -102,6 +102,8 @@ export const SETTINGS = {
SYSLOGD_PORT: mkNumber(6514), SYSLOGD_PORT: mkNumber(6514),
DISCORD_HEALTH_CHANNEL_URL: mkString(''), DISCORD_HEALTH_CHANNEL_URL: mkString(''),
DOCKER_CONTAINER_HOST: mkString(`host.docker.internal`),
} }
;(() => { ;(() => {
let passed = true let passed = true
@ -230,6 +232,8 @@ export const SYSLOGD_PORT = () => settings().SYSLOGD_PORT
export const DISCORD_HEALTH_CHANNEL_URL = () => export const DISCORD_HEALTH_CHANNEL_URL = () =>
settings().DISCORD_HEALTH_CHANNEL_URL settings().DISCORD_HEALTH_CHANNEL_URL
export const DOCKER_CONTAINER_HOST = () => settings().DOCKER_CONTAINER_HOST
/** Helpers */ /** Helpers */
export const MOTHERSHIP_DATA_ROOT = () => INSTANCE_DATA_ROOT(MOTHERSHIP_NAME()) export const MOTHERSHIP_DATA_ROOT = () => INSTANCE_DATA_ROOT(MOTHERSHIP_NAME())

View File

@ -301,19 +301,17 @@ export const instanceService = mkSingleton(
return cp return cp
} catch (e) { } catch (e) {
warn(`Error spawning: ${e}`) warn(`Error spawning: ${e}`)
userInstanceLogger.error(`Error spawning: ${e}`)
if (UPGRADE_MODE()) { if (UPGRADE_MODE()) {
throw new Error( // Noop
`PocketHost is rebooting. Try again in a few seconds.`,
)
} else { } else {
await updateInstance(instance.id, { await updateInstance(instance.id, {
maintenance: true, maintenance: true,
}) })
userInstanceLogger.error( }
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`, `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`)
}
} }
})() })()
const { pid: _pid, exitCode } = childProcess const { pid: _pid, exitCode } = childProcess

View File

@ -1,16 +1,17 @@
import { import {
APEX_DOMAIN, APEX_DOMAIN,
SYSLOGD_PORT, DOCKER_CONTAINER_HOST,
mkContainerHomePath, mkContainerHomePath,
mkInstanceDataPath, mkInstanceDataPath,
SYSLOGD_PORT,
} from '$constants' } from '$constants'
import { PortService } from '$services' import { PortService } from '$services'
import { import {
LoggerService,
SingletonBaseConfig,
createCleanupManager, createCleanupManager,
createTimerManager, createTimerManager,
LoggerService,
mkSingleton, mkSingleton,
SingletonBaseConfig,
} from '$shared' } from '$shared'
import { assert, asyncExitHook, mkInternalUrl, tryFetch } from '$util' import { assert, asyncExitHook, mkInternalUrl, tryFetch } from '$util'
import { map } from '@s-libs/micro-dash' import { map } from '@s-libs/micro-dash'
@ -148,7 +149,7 @@ export const createPocketbaseService = async (
LogConfig: { LogConfig: {
Type: 'syslog', Type: 'syslog',
Config: { Config: {
'syslog-address': `udp://localhost:${SYSLOGD_PORT()}`, 'syslog-address': `udp://${DOCKER_CONTAINER_HOST()}:${SYSLOGD_PORT()}`,
tag: instanceId, tag: instanceId,
}, },
}, },

View File

@ -44,7 +44,7 @@ export const proxyService = mkSingleton(async (config: ProxyServiceConfig) => {
server.use(cors()) server.use(cors())
server.get('/api/health', (req, res, next) => { server.get('/_api/health', (req, res, next) => {
res.json({ status: 'ok' }) res.json({ status: 'ok' })
res.end res.end
}) })