mirror of
https://github.com/pockethost/pockethost.git
synced 2025-06-01 03:36:41 +00:00
chore: adjust debugging output
This commit is contained in:
parent
8a6c6c5df9
commit
b962b4b54b
@ -19,7 +19,7 @@ import { AsyncReturnType } from 'type-fest'
|
|||||||
|
|
||||||
export type InstanceLogger = AsyncReturnType<typeof mkApi>
|
export type InstanceLogger = AsyncReturnType<typeof mkApi>
|
||||||
const mkApi = async (logDbPath: string) => {
|
const mkApi = async (logDbPath: string) => {
|
||||||
const { dbg } = logger().create(logDbPath)
|
const { dbg } = logger().create(`InstanceLogger ${logDbPath}`)
|
||||||
|
|
||||||
const { getDatabase } = sqliteService()
|
const { getDatabase } = sqliteService()
|
||||||
const db = await getDatabase(logDbPath)
|
const db = await getDatabase(logDbPath)
|
||||||
|
@ -4,7 +4,7 @@ import {
|
|||||||
DAEMON_PB_PORT_BASE,
|
DAEMON_PB_PORT_BASE,
|
||||||
PUBLIC_APP_DB,
|
PUBLIC_APP_DB,
|
||||||
PUBLIC_APP_DOMAIN,
|
PUBLIC_APP_DOMAIN,
|
||||||
PUBLIC_APP_PROTOCOL
|
PUBLIC_APP_PROTOCOL,
|
||||||
} from '$constants'
|
} from '$constants'
|
||||||
import { clientService, proxyService, rpcService } from '$services'
|
import { clientService, proxyService, rpcService } from '$services'
|
||||||
import { mkInternalUrl, now } from '$util'
|
import { mkInternalUrl, now } from '$util'
|
||||||
@ -22,7 +22,7 @@ import {
|
|||||||
safeCatch,
|
safeCatch,
|
||||||
SaveSecretsPayload,
|
SaveSecretsPayload,
|
||||||
SaveSecretsPayloadSchema,
|
SaveSecretsPayloadSchema,
|
||||||
SaveSecretsResult
|
SaveSecretsResult,
|
||||||
} from '@pockethost/common'
|
} from '@pockethost/common'
|
||||||
import { forEachRight, map } from '@s-libs/micro-dash'
|
import { forEachRight, map } from '@s-libs/micro-dash'
|
||||||
import Bottleneck from 'bottleneck'
|
import Bottleneck from 'bottleneck'
|
||||||
@ -91,7 +91,9 @@ export const instanceService = mkSingleton(
|
|||||||
const getInstance = (subdomain: string) =>
|
const getInstance = (subdomain: string) =>
|
||||||
instanceLimiter
|
instanceLimiter
|
||||||
.schedule(async () => {
|
.schedule(async () => {
|
||||||
const { dbg, warn, error } = logger().create(subdomain)
|
const { dbg, warn, error } = logger().create(
|
||||||
|
`InstanceService ${subdomain}`
|
||||||
|
)
|
||||||
dbg(`Getting instance`)
|
dbg(`Getting instance`)
|
||||||
{
|
{
|
||||||
const instance = instances[subdomain]
|
const instance = instances[subdomain]
|
||||||
@ -100,11 +102,7 @@ export const instanceService = mkSingleton(
|
|||||||
return instance
|
return instance
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const clientLimiter = new Bottleneck({ maxConcurrent: 1 })
|
const clientLimiter = new Bottleneck({ maxConcurrent: 1 })
|
||||||
|
|
||||||
dbg(`Checking for permission`)
|
|
||||||
|
|
||||||
const [instance, owner] = await clientLimiter.schedule(() =>
|
const [instance, owner] = await clientLimiter.schedule(() =>
|
||||||
client.getInstanceBySubdomain(subdomain)
|
client.getInstanceBySubdomain(subdomain)
|
||||||
)
|
)
|
||||||
@ -113,17 +111,19 @@ export const instanceService = mkSingleton(
|
|||||||
`Instance ${subdomain} not found. Please check the instance URL and try again, or create one at ${PUBLIC_APP_PROTOCOL}://${PUBLIC_APP_DOMAIN}.`
|
`Instance ${subdomain} not found. Please check the instance URL and try again, or create one at ${PUBLIC_APP_PROTOCOL}://${PUBLIC_APP_DOMAIN}.`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
dbg(`Instance found`)
|
||||||
|
|
||||||
|
dbg(`Checking for verified account`)
|
||||||
if (!owner?.verified) {
|
if (!owner?.verified) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Log in at ${PUBLIC_APP_PROTOCOL}://${PUBLIC_APP_DOMAIN} to verify your account.`
|
`Log in at ${PUBLIC_APP_PROTOCOL}://${PUBLIC_APP_DOMAIN} to verify your account.`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dbg(`Obtaining port`)
|
||||||
await clientLimiter.schedule(() =>
|
await clientLimiter.schedule(() =>
|
||||||
client.updateInstanceStatus(instance.id, InstanceStatus.Port)
|
client.updateInstanceStatus(instance.id, InstanceStatus.Port)
|
||||||
)
|
)
|
||||||
dbg(`Instance found`)
|
|
||||||
const exclude = map(instances, (i) => i.port)
|
const exclude = map(instances, (i) => i.port)
|
||||||
const newPort = await getPort({
|
const newPort = await getPort({
|
||||||
port: DAEMON_PB_PORT_BASE,
|
port: DAEMON_PB_PORT_BASE,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user