mirror of
https://github.com/pockethost/pockethost.git
synced 2025-11-23 22:15:49 +00:00
refactor(mothership): improve logging consistency and clarity in instance handlers
This commit is contained in:
parent
ca0e1f14fe
commit
a5fbcb7958
@ -6,31 +6,31 @@ export const HandleInstanceCreate = (c: echo.Context) => {
|
||||
|
||||
const log = mkLog(`POST:instance`)
|
||||
const authRecord = c.get('authRecord') as models.Record | undefined // empty if not authenticated as regular auth record
|
||||
log(`***authRecord`, JSON.stringify(authRecord))
|
||||
log(`authRecord`, JSON.stringify(authRecord))
|
||||
|
||||
if (!authRecord) {
|
||||
throw new Error(`Expected authRecord here`)
|
||||
}
|
||||
|
||||
log(`***TOP OF POST`)
|
||||
log(`TOP OF POST`)
|
||||
let data = new DynamicModel({
|
||||
subdomain: '',
|
||||
version: versions[0],
|
||||
region: 'sfo-2',
|
||||
}) as { subdomain?: string; version?: string; region?: string }
|
||||
|
||||
log(`***before bind`)
|
||||
log(`before bind`)
|
||||
|
||||
c.bind(data)
|
||||
|
||||
log(`***after bind`)
|
||||
log(`after bind`)
|
||||
|
||||
// This is necessary for destructuring to work correctly
|
||||
data = JSON.parse(JSON.stringify(data))
|
||||
|
||||
const { subdomain, version, region } = data
|
||||
|
||||
log(`***vars`, JSON.stringify({ subdomain, region }))
|
||||
log(`vars`, JSON.stringify({ subdomain, region }))
|
||||
|
||||
if (!subdomain) {
|
||||
throw new BadRequestError(`Subdomain is required when creating an instance.`)
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
import { mkLog } from '$util/Logger'
|
||||
|
||||
/** Migrate version numbers */
|
||||
export const HandleMigrateRegions = (e: core.BootstrapEvent) => {
|
||||
const dao = $app.dao()
|
||||
|
||||
console.log(`***Migrating regions`)
|
||||
const log = mkLog(`HandleMigrateRegions`)
|
||||
log(`Migrating regions`)
|
||||
dao.db().newQuery(`update instances set region='sfo-1' where region=''`).execute()
|
||||
log(`Migrated regions`)
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ export const HandleInstanceBeforeUpdate = (e: core.ModelEvent) => {
|
||||
try {
|
||||
dao.db().newQuery(`select id from instances where cname='${cname}' and id <> '${id}'`).one(result)
|
||||
} catch (e) {
|
||||
// log(`*** cname OK ${cname}`)
|
||||
// log(` cname OK ${cname}`)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
|
||||
@ -3,7 +3,7 @@ import { mkLog } from '$util/Logger'
|
||||
export const HandleMetaUpdateAtBoot = (c: core.BootstrapEvent) => {
|
||||
const log = mkLog('HandleMetaUpdateAtBoot')
|
||||
log(`At top of HandleMetaUpdateAtBoot`)
|
||||
log(`***app URL`, process.env.APP_URL)
|
||||
log(`app URL`, process.env.APP_URL)
|
||||
const form = new SettingsUpsertForm($app)
|
||||
form.meta = {
|
||||
...$app.settings().meta,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user