mirror of
https://github.com/whyour/qinglong.git
synced 2026-07-01 04:40:38 +08:00
修改获取配置文件接口,初始化系统配置
This commit is contained in:
+8
-11
@@ -48,27 +48,24 @@ export default (app: Router) => {
|
||||
);
|
||||
|
||||
route.get(
|
||||
'/:file',
|
||||
'/detail',
|
||||
async (req: Request, res: Response, next: NextFunction) => {
|
||||
const logger: Logger = Container.get('logger');
|
||||
try {
|
||||
let content = '';
|
||||
if (config.blackFileList.includes(req.params.file)) {
|
||||
const _path = req.query.path as string;
|
||||
if (config.blackFileList.includes(_path) || !_path) {
|
||||
res.send({ code: 403, message: '文件无法访问' });
|
||||
}
|
||||
if (req.params.file.startsWith('sample/')) {
|
||||
if (_path.startsWith('sample/')) {
|
||||
const res = await got.get(
|
||||
`https://gitlab.com/whyour/qinglong/-/raw/master/${req.params.file}`,
|
||||
`https://gitlab.com/whyour/qinglong/-/raw/master/${_path}`,
|
||||
);
|
||||
content = res.body;
|
||||
} else if (req.params.file.startsWith('data/scripts/')) {
|
||||
content = await getFileContentByName(
|
||||
join(config.rootPath, req.params.file),
|
||||
);
|
||||
} else if (_path.startsWith('data/scripts/')) {
|
||||
content = await getFileContentByName(join(config.rootPath, _path));
|
||||
} else {
|
||||
content = await getFileContentByName(
|
||||
join(config.configPath, req.params.file),
|
||||
);
|
||||
content = await getFileContentByName(join(config.configPath, _path));
|
||||
}
|
||||
res.send({ code: 200, data: content });
|
||||
} catch (e) {
|
||||
|
||||
@@ -9,6 +9,7 @@ import { Op } from 'sequelize';
|
||||
import config from '../config';
|
||||
import { CrontabViewModel, CronViewType } from '../data/cronView';
|
||||
import { initPosition } from '../data/env';
|
||||
import { AuthDataType, SystemModel } from '../data/system';
|
||||
|
||||
export default async () => {
|
||||
const cronService = Container.get(CronService);
|
||||
@@ -127,4 +128,7 @@ export default async () => {
|
||||
// 初始化保存一次ck和定时任务数据
|
||||
await cronService.autosave_crontab();
|
||||
await envService.set_envs();
|
||||
|
||||
// 初始化增加系统配置
|
||||
await SystemModel.upsert({ type: AuthDataType.systemConfig });
|
||||
};
|
||||
|
||||
@@ -284,7 +284,7 @@ export default class SystemService {
|
||||
}
|
||||
|
||||
public async updateSystem() {
|
||||
const cp = spawn('no_tee=true ql update false', { shell: '/bin/bash' });
|
||||
const cp = spawn('real_time=true ql update false', { shell: '/bin/bash' });
|
||||
|
||||
cp.stdout.on('data', (data) => {
|
||||
this.sockService.sendMessage({
|
||||
@@ -311,7 +311,7 @@ export default class SystemService {
|
||||
}
|
||||
|
||||
public async reloadSystem(target: 'system' | 'data') {
|
||||
const cmd = `no_tee=true ql reload ${target || ''}`;
|
||||
const cmd = `real_time=true ql reload ${target || ''}`;
|
||||
const cp = spawn(cmd, { shell: '/bin/bash' });
|
||||
|
||||
cp.stdout.on('data', (data) => {
|
||||
|
||||
Reference in New Issue
Block a user