mirror of
https://github.com/pockethost/pockethost.git
synced 2025-03-30 15:08:30 +00:00
chore(pockethost): refactor gobot service
This commit is contained in:
parent
a210022387
commit
4a5a063268
@ -1,5 +1,5 @@
|
||||
import copyfiles from 'copyfiles'
|
||||
import { GobotOptions, gobot } from 'gobot'
|
||||
import { GobotOptions } from 'gobot'
|
||||
import { rimraf } from 'rimraf'
|
||||
import {
|
||||
DEBUG,
|
||||
@ -14,6 +14,7 @@ import {
|
||||
mkContainerHomePath,
|
||||
} from '../../../../../core'
|
||||
import { PortService } from '../../../../services'
|
||||
import { GobotService } from '../../../../services/GobotService'
|
||||
|
||||
export type MothershipConfig = { isolate: boolean }
|
||||
|
||||
@ -85,6 +86,7 @@ export async function mothership(cfg: MothershipConfig) {
|
||||
}
|
||||
dbg(`args`, args)
|
||||
dbg(`options`, options)
|
||||
const { gobot } = GobotService()
|
||||
const bot = await gobot(`pocketbase`, options)
|
||||
bot.run(args, { env })
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import {
|
||||
SETTINGS,
|
||||
loadPlugins,
|
||||
} from '../../core'
|
||||
import { GobotService } from '../services/GobotService'
|
||||
import { EdgeCommand } from './commands/EdgeCommand'
|
||||
import { FirewallCommand } from './commands/FirewallCommand'
|
||||
import { HealthCommand } from './commands/HealthCommand'
|
||||
@ -26,6 +27,7 @@ export type GlobalOptions = {
|
||||
DefaultSettingsService(SETTINGS)
|
||||
|
||||
LoggerService({ level: DEBUG() ? LogLevelName.Debug : LogLevelName.Info })
|
||||
GobotService({})
|
||||
|
||||
//@ts-ignore
|
||||
global.EventSource = EventSource
|
||||
|
10
packages/pockethost/src/services/GobotService.ts
Normal file
10
packages/pockethost/src/services/GobotService.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import { GobotOptions, gobot } from 'gobot'
|
||||
import { mkSingleton } from '../common'
|
||||
import { PH_GOBOT_ROOT } from '../constants'
|
||||
|
||||
export const GobotService = mkSingleton(() => {
|
||||
return {
|
||||
gobot: (name: string, options?: Partial<GobotOptions>) =>
|
||||
gobot(name, { ...options, cachePath: PH_GOBOT_ROOT(`cache`, name) }),
|
||||
}
|
||||
})
|
@ -1,7 +1,6 @@
|
||||
import { map } from '@s-libs/micro-dash'
|
||||
import Docker, { Container, ContainerCreateOptions } from 'dockerode'
|
||||
import { existsSync } from 'fs'
|
||||
import { gobot } from 'gobot'
|
||||
import MemoryStream from 'memorystream'
|
||||
import { gte } from 'semver'
|
||||
import { EventEmitter } from 'stream'
|
||||
@ -21,6 +20,7 @@ import {
|
||||
mkSingleton,
|
||||
tryFetch,
|
||||
} from '../../../core'
|
||||
import { GobotService } from '../GobotService'
|
||||
import { PortService } from '../PortService'
|
||||
|
||||
export type Env = { [_: string]: string }
|
||||
@ -55,6 +55,7 @@ export const createPocketbaseService = async (
|
||||
const _serviceLogger = LoggerService().create('PocketbaseService')
|
||||
const { dbg, error, warn, abort } = _serviceLogger
|
||||
|
||||
const { gobot } = GobotService()
|
||||
const bot = await gobot(`pocketbase`, { os: 'linux' })
|
||||
const maxVersion = (await bot.versions())[0]
|
||||
if (!maxVersion) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user