mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
add support for config migration
This commit is contained in:
14 files changed
+206
-151
No files matched your search
@@ -10,8 +10,7 @@ import { load } from '../options';
|
||||
import { MongoService } from '../service/db';
|
||||
import { ConfigService } from '../settings';
|
||||
import {
|
||||
addon, builtinModel, handler, lib, locale, model,
|
||||
script, service, setting,
|
||||
addon, builtinModel, locale, model, service,
|
||||
} from './common';
|
||||
|
||||
const argv = cac().parse();
|
||||
@@ -42,9 +41,9 @@ export async function apply(ctx: Context) {
|
||||
});
|
||||
await ctx.plugin(require('../service/hmr').default, { watch: argv.options.watch });
|
||||
await Promise.all([
|
||||
ctx.loader.reloadPlugin(require.resolve('../service/storage'), 'file', 'hydrooj/service/storage'),
|
||||
ctx.loader.reloadPlugin(require.resolve('../service/worker'), 'worker', 'hydrooj/service/worker'),
|
||||
ctx.loader.reloadPlugin(require.resolve('../service/server'), 'server', 'hydrooj/service/server'),
|
||||
ctx.loader.reloadPlugin(require.resolve('../service/storage'), 'file'),
|
||||
ctx.loader.reloadPlugin(require.resolve('../service/worker'), 'worker'),
|
||||
ctx.loader.reloadPlugin(require.resolve('../service/server'), 'server'),
|
||||
]);
|
||||
ctx = await new Promise((resolve) => {
|
||||
ctx.inject(['server'], (c) => {
|
||||
@@ -53,9 +52,7 @@ export async function apply(ctx: Context) {
|
||||
});
|
||||
await require('../service/api').apply(ctx);
|
||||
require('../lib/index');
|
||||
await lib(pending, fail, ctx);
|
||||
|
||||
await setting(pending, fail, require('../model/setting'));
|
||||
ctx.plugin(require('../service/monitor'));
|
||||
ctx.plugin(require('../service/check'));
|
||||
await service(pending, fail, ctx);
|
||||
@@ -65,16 +62,14 @@ export async function apply(ctx: Context) {
|
||||
const handlerDir = path.resolve(__dirname, '..', 'handler');
|
||||
const handlers = await fs.readdir(handlerDir);
|
||||
for (const h of handlers.filter((i) => i.endsWith('.ts'))) {
|
||||
ctx.loader.reloadPlugin(path.resolve(handlerDir, h), '', `hydrooj/handler/${h.split('.')[0]}`);
|
||||
ctx.loader.reloadPlugin(path.resolve(handlerDir, h), '');
|
||||
}
|
||||
ctx.plugin(require('../service/migration').default);
|
||||
await handler(pending, fail, ctx);
|
||||
await addon(pending, fail, ctx);
|
||||
const scriptDir = path.resolve(__dirname, '..', 'script');
|
||||
for (const h of await fs.readdir(scriptDir)) {
|
||||
ctx.loader.reloadPlugin(path.resolve(scriptDir, h), '', `hydrooj/script/${h.split('.')[0]}`);
|
||||
ctx.loader.reloadPlugin(path.resolve(scriptDir, h), '');
|
||||
}
|
||||
await script(pending, fail, ctx);
|
||||
await ctx.parallel('app/started');
|
||||
if (process.env.NODE_APP_INSTANCE === '0') {
|
||||
await new Promise((resolve, reject) => {
|
||||
@@ -90,7 +85,7 @@ export async function apply(ctx: Context) {
|
||||
});
|
||||
});
|
||||
}
|
||||
for (const f of global.addons) {
|
||||
for (const f of Object.values(global.addons)) {
|
||||
const dir = path.join(f, 'public');
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
if (await fs.pathExists(dir)) await fs.copy(dir, path.join(os.homedir(), '.hydro/static'));
|
||||
|
||||
Reference in new issue
Block a user