mirror of
https://github.com/whyour/qinglong.git
synced 2026-07-01 04:40:38 +08:00
修复模块注入
This commit is contained in:
+6
-3
@@ -91,7 +91,8 @@ class Application {
|
||||
}
|
||||
|
||||
private async initializeDatabase() {
|
||||
await require('./loaders/db').default();
|
||||
const dbLoader = await import('./loaders/db');
|
||||
await dbLoader.default();
|
||||
}
|
||||
|
||||
private setupMiddlewares() {
|
||||
@@ -181,14 +182,16 @@ class Application {
|
||||
const { HttpServerService } = await import('./services/http');
|
||||
this.httpServerService = Container.get(HttpServerService);
|
||||
|
||||
await require('./loaders/app').default({ app: this.app });
|
||||
const appLoader = await import('./loaders/app');
|
||||
await appLoader.default({ app: this.app });
|
||||
|
||||
const server = await this.httpServerService.initialize(
|
||||
this.app,
|
||||
config.port,
|
||||
);
|
||||
|
||||
await require('./loaders/server').default({ server });
|
||||
const serverLoader = await import('./loaders/server');
|
||||
await (serverLoader.default as any)({ server });
|
||||
this.setupWorkerShutdown('http');
|
||||
}
|
||||
|
||||
|
||||
@@ -36,10 +36,12 @@ async function linkCommand() {
|
||||
const source = path.join(config.rootPath, 'shell', link.src);
|
||||
const target = path.join(commandDir, link.dest);
|
||||
const tmpTarget = path.join(commandDir, link.tmp);
|
||||
const stats = await fs.lstat(tmpTarget);
|
||||
if (stats) {
|
||||
await fs.unlink(tmpTarget);
|
||||
}
|
||||
try {
|
||||
const stats = await fs.lstat(tmpTarget);
|
||||
if (stats) {
|
||||
await fs.unlink(tmpTarget);
|
||||
}
|
||||
} catch (error) { }
|
||||
await fs.symlink(source, tmpTarget);
|
||||
await fs.rename(tmpTarget, target);
|
||||
}
|
||||
|
||||
@@ -89,7 +89,8 @@ export default async () => {
|
||||
setTimeout(async () => {
|
||||
await dependenceService.installDependenceOneByOne(docs);
|
||||
|
||||
require('./bootAfter').default();
|
||||
const bootAfterLoader = await import('./bootAfter');
|
||||
bootAfterLoader.default();
|
||||
}, 5000);
|
||||
};
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ const addCron = (
|
||||
}
|
||||
|
||||
Logger.info(
|
||||
'[schedule][创建定时任务], 任务ID: %s, 名称: %s, cron: %s, 执行命令: %s',
|
||||
'[schedule][创建定时任务] 任务ID: %s, 名称: %s, cron: %s, 执行命令: %s',
|
||||
id,
|
||||
name,
|
||||
schedule,
|
||||
@@ -26,7 +26,7 @@ const addCron = (
|
||||
if (extra_schedules?.length) {
|
||||
extra_schedules.forEach((x) => {
|
||||
Logger.info(
|
||||
'[schedule][创建定时任务], 任务ID: %s, 名称: %s, cron: %s, 执行命令: %s',
|
||||
'[schedule][创建定时任务] 任务ID: %s, 名称: %s, cron: %s, 执行命令: %s',
|
||||
id,
|
||||
name,
|
||||
x.schedule,
|
||||
|
||||
@@ -10,7 +10,7 @@ const delCron = (
|
||||
for (const id of call.request.ids) {
|
||||
if (scheduleStacks.has(id)) {
|
||||
Logger.info(
|
||||
'[schedule][取消定时任务], 任务ID: %s',
|
||||
'[schedule][取消定时任务] 任务ID: %s',
|
||||
id,
|
||||
);
|
||||
scheduleStacks.get(id)?.forEach(x => x.cancel());
|
||||
|
||||
@@ -593,7 +593,7 @@ export default class CronService {
|
||||
files.map(async (x) => ({
|
||||
filename: x,
|
||||
directory: relativeDir.replace(config.logPath, ''),
|
||||
time: (await fs.lstat(`${dir}/${x}`)).mtime.getTime(),
|
||||
time: (await fs.lstat(`${dir}/${x}`)).birthtimeMs,
|
||||
})),
|
||||
)
|
||||
).sort((a, b) => b.time - a.time);
|
||||
|
||||
@@ -139,7 +139,7 @@ export default class ScheduleService {
|
||||
) {
|
||||
const _id = this.formatId(id);
|
||||
this.logger.info(
|
||||
'[panel][创建cron任务], 任务ID: %s, cron: %s, 任务名: %s, 执行命令: %s',
|
||||
'[panel][创建cron任务] 任务ID: %s, cron: %s, 任务名: %s, 执行命令: %s',
|
||||
_id,
|
||||
schedule,
|
||||
name,
|
||||
@@ -172,7 +172,7 @@ export default class ScheduleService {
|
||||
|
||||
async cancelCronTask({ id = 0, name }: ScheduleTaskType) {
|
||||
const _id = this.formatId(id);
|
||||
this.logger.info('[panel][取消定时任务], 任务名: %s', name);
|
||||
this.logger.info('[panel][取消定时任务] 任务名: %s', name);
|
||||
if (this.scheduleStacks.has(_id)) {
|
||||
this.scheduleStacks.get(_id)?.cancel();
|
||||
this.scheduleStacks.delete(_id);
|
||||
@@ -187,7 +187,7 @@ export default class ScheduleService {
|
||||
) {
|
||||
const _id = this.formatId(id);
|
||||
this.logger.info(
|
||||
'[panel][创建interval任务], 任务ID: %s, 任务名: %s, 执行命令: %s',
|
||||
'[panel][创建interval任务] 任务ID: %s, 任务名: %s, 执行命令: %s',
|
||||
_id,
|
||||
name,
|
||||
command,
|
||||
@@ -232,7 +232,7 @@ export default class ScheduleService {
|
||||
async cancelIntervalTask({ id = 0, name }: ScheduleTaskType) {
|
||||
const _id = this.formatId(id);
|
||||
this.logger.info(
|
||||
'[panel][取消interval任务], 任务ID: %s, 任务名: %s',
|
||||
'[panel][取消interval任务] 任务ID: %s, 任务名: %s',
|
||||
_id,
|
||||
name,
|
||||
);
|
||||
|
||||
@@ -26,12 +26,13 @@ export default class SshKeyService {
|
||||
if (_exist) {
|
||||
config = await fs.readFile(this.sshConfigFilePath, { encoding: 'utf-8' });
|
||||
} else {
|
||||
await writeFileWithLock(this.sshConfigFilePath, '');
|
||||
await writeFileWithLock(this.sshConfigFilePath, '', { mode: '600' });
|
||||
}
|
||||
if (!config.includes(this.sshConfigHeader)) {
|
||||
await writeFileWithLock(
|
||||
this.sshConfigFilePath,
|
||||
`${this.sshConfigHeader}\n\n${config}`,
|
||||
{ mode: '600' },
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -45,7 +46,6 @@ export default class SshKeyService {
|
||||
path.join(this.sshPath, alias),
|
||||
`${key}${os.EOL}`,
|
||||
{
|
||||
encoding: 'utf8',
|
||||
mode: '400',
|
||||
},
|
||||
);
|
||||
@@ -81,6 +81,10 @@ export default class SshKeyService {
|
||||
await writeFileWithLock(
|
||||
`${path.join(this.sshPath, `${alias}.config`)}`,
|
||||
config,
|
||||
{
|
||||
encoding: 'utf8',
|
||||
mode: '600',
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -384,7 +384,7 @@ export default class SubscriptionService {
|
||||
files.map(async (x) => ({
|
||||
filename: x,
|
||||
directory: relativeDir.replace(config.logPath, ''),
|
||||
time: (await fs.lstat(`${dir}/${x}`)).mtime.getTime(),
|
||||
time: (await fs.lstat(`${dir}/${x}`)).birthtimeMs,
|
||||
})),
|
||||
)
|
||||
).sort((a, b) => b.time - a.time);
|
||||
|
||||
Reference in New Issue
Block a user