fix: wait for config load
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import type { AxiosRequestConfig } from 'axios'
|
||||
import { argv } from 'yargs'
|
||||
import { isDev } from './utils/index.util'
|
||||
|
||||
console.log(argv)
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ export class ConfigsService {
|
||||
|
||||
protected async configInit() {
|
||||
const configs = await this.optionModel.find().lean()
|
||||
configs.map((field) => {
|
||||
configs.forEach((field) => {
|
||||
const name = field.name as keyof IConfig
|
||||
const value = field.value
|
||||
this.config[name] = value
|
||||
|
||||
@@ -197,7 +197,10 @@ export class MarkdownController {
|
||||
return `/${(document as PageModel).slug}`
|
||||
}
|
||||
})()
|
||||
const url = new URL(relativePath, this.configs.get('url').webUrl)
|
||||
const {
|
||||
url: { webUrl },
|
||||
} = await this.configs.waitForConfigReady()
|
||||
const url = new URL(relativePath, webUrl)
|
||||
|
||||
const html = minify(
|
||||
`
|
||||
|
||||
@@ -109,6 +109,7 @@ export class CronService {
|
||||
return
|
||||
}
|
||||
const backupOptions = this.configs.get('backupOptions')
|
||||
|
||||
if (
|
||||
!backupOptions.Bucket ||
|
||||
!backupOptions.Region ||
|
||||
@@ -140,7 +141,7 @@ export class CronService {
|
||||
if (!err) {
|
||||
this.logger.log('--> 上传成功')
|
||||
} else {
|
||||
this.logger.error('--> 上传失败了' + err.message)
|
||||
this.logger.error('--> 上传失败了')
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
export function getFolderSize(folderPath: string) {
|
||||
return $`du -shc ${folderPath} | head -n 1 | cut -f1`
|
||||
try {
|
||||
return $`du -shc ${folderPath} | head -n 1 | cut -f1`
|
||||
} catch (e: any) {
|
||||
if (e.exitCode == 141) {
|
||||
return e.stdout.trim()
|
||||
}
|
||||
return 'N/A'
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user