mirror of
https://github.com/pockethost/pockethost.git
synced 2025-10-14 00:59:25 +00:00
refactor: instance login
This commit is contained in:
parent
0a09500439
commit
3c9783485d
@ -1,5 +1,12 @@
|
|||||||
import { binFor } from '@pockethost/common'
|
import { binFor } from '@pockethost/common'
|
||||||
import { DAEMON_PB_PORT_BASE, PUBLIC_PB_SUBDOMAIN } from './constants'
|
import {
|
||||||
|
DAEMON_PB_PASSWORD,
|
||||||
|
DAEMON_PB_PORT_BASE,
|
||||||
|
DAEMON_PB_USERNAME,
|
||||||
|
PUBLIC_PB_DOMAIN,
|
||||||
|
PUBLIC_PB_PROTOCOL,
|
||||||
|
PUBLIC_PB_SUBDOMAIN,
|
||||||
|
} from './constants'
|
||||||
import { createPbClient } from './db/PbClient'
|
import { createPbClient } from './db/PbClient'
|
||||||
import { createBackupService } from './services/BackupService'
|
import { createBackupService } from './services/BackupService'
|
||||||
import { createInstanceService } from './services/InstanceService'
|
import { createInstanceService } from './services/InstanceService'
|
||||||
@ -27,6 +34,18 @@ global.EventSource = require('eventsource')
|
|||||||
*/
|
*/
|
||||||
const client = createPbClient(coreInternalUrl)
|
const client = createPbClient(coreInternalUrl)
|
||||||
const instanceService = await createInstanceService(client)
|
const instanceService = await createInstanceService(client)
|
||||||
|
try {
|
||||||
|
await client.adminAuthViaEmail(DAEMON_PB_USERNAME, DAEMON_PB_PASSWORD)
|
||||||
|
console.log(`Logged in`)
|
||||||
|
} catch (e) {
|
||||||
|
console.error(
|
||||||
|
`***WARNING*** CANNOT AUTHENTICATE TO ${PUBLIC_PB_PROTOCOL}://${PUBLIC_PB_SUBDOMAIN}.${PUBLIC_PB_DOMAIN}/_/`
|
||||||
|
)
|
||||||
|
console.error(
|
||||||
|
`***WARNING*** LOG IN MANUALLY, ADJUST .env, AND RESTART DOCKER`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
const proxyService = await createProxyService(instanceService)
|
const proxyService = await createProxyService(instanceService)
|
||||||
const jobService = await createJobService(client)
|
const jobService = await createJobService(client)
|
||||||
const backupService = await createBackupService(client, jobService)
|
const backupService = await createBackupService(client, jobService)
|
||||||
|
@ -11,17 +11,12 @@ import getPort from 'get-port'
|
|||||||
import { AsyncReturnType } from 'type-fest'
|
import { AsyncReturnType } from 'type-fest'
|
||||||
import {
|
import {
|
||||||
DAEMON_PB_IDLE_TTL,
|
DAEMON_PB_IDLE_TTL,
|
||||||
DAEMON_PB_PASSWORD,
|
|
||||||
DAEMON_PB_PORT_BASE,
|
DAEMON_PB_PORT_BASE,
|
||||||
DAEMON_PB_USERNAME,
|
|
||||||
PUBLIC_APP_DOMAIN,
|
PUBLIC_APP_DOMAIN,
|
||||||
PUBLIC_APP_PROTOCOL,
|
PUBLIC_APP_PROTOCOL,
|
||||||
PUBLIC_PB_DOMAIN,
|
|
||||||
PUBLIC_PB_PROTOCOL,
|
|
||||||
PUBLIC_PB_SUBDOMAIN,
|
|
||||||
} from '../constants'
|
} from '../constants'
|
||||||
import { PocketbaseClientApi } from '../db/PbClient'
|
import { PocketbaseClientApi } from '../db/PbClient'
|
||||||
import { dbg, error } from '../util/dbg'
|
import { dbg } from '../util/dbg'
|
||||||
import { mkInternalUrl } from '../util/internal'
|
import { mkInternalUrl } from '../util/internal'
|
||||||
import { now } from '../util/now'
|
import { now } from '../util/now'
|
||||||
import { safeCatch } from '../util/safeAsync'
|
import { safeCatch } from '../util/safeAsync'
|
||||||
@ -39,15 +34,6 @@ export type InstanceServiceApi = AsyncReturnType<typeof createInstanceService>
|
|||||||
export const createInstanceService = async (client: PocketbaseClientApi) => {
|
export const createInstanceService = async (client: PocketbaseClientApi) => {
|
||||||
const instances: { [_: string]: InstanceApi } = {}
|
const instances: { [_: string]: InstanceApi } = {}
|
||||||
|
|
||||||
try {
|
|
||||||
await client.adminAuthViaEmail(DAEMON_PB_USERNAME, DAEMON_PB_PASSWORD)
|
|
||||||
} catch (e) {
|
|
||||||
error(
|
|
||||||
`***WARNING*** CANNOT AUTHENTICATE TO ${PUBLIC_PB_PROTOCOL}://${PUBLIC_PB_SUBDOMAIN}.${PUBLIC_PB_DOMAIN}/_/`
|
|
||||||
)
|
|
||||||
error(`***WARNING*** LOG IN MANUALLY, ADJUST .env, AND RESTART DOCKER`)
|
|
||||||
}
|
|
||||||
|
|
||||||
const limiter = new Bottleneck({ maxConcurrent: 1 })
|
const limiter = new Bottleneck({ maxConcurrent: 1 })
|
||||||
|
|
||||||
const getInstance = (subdomain: string) =>
|
const getInstance = (subdomain: string) =>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user