mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-22 22:36:06 +08:00
修改内置token获取方式
This commit is contained in:
parent
53414e5d70
commit
a7117e4442
|
@ -3,12 +3,30 @@ import _ from 'lodash';
|
|||
import SystemService from '../services/system';
|
||||
import ScheduleService from '../services/schedule';
|
||||
import SubscriptionService from '../services/subscription';
|
||||
import config from '../config';
|
||||
import { fileExist } from '../config/util';
|
||||
|
||||
export default async () => {
|
||||
const systemService = Container.get(SystemService);
|
||||
const scheduleService = Container.get(ScheduleService);
|
||||
const subscriptionService = Container.get(SubscriptionService);
|
||||
|
||||
// 生成内置token
|
||||
let tokenCommand = `ts-node-transpile-only ${config.rootPath}/back/token.ts`;
|
||||
const tokenFile = `${config.rootPath}/static/build/token.js`;
|
||||
if (await fileExist(tokenFile)) {
|
||||
tokenCommand = `node ${tokenFile}`;
|
||||
}
|
||||
const cron = {
|
||||
id: 'token',
|
||||
name: '生成token',
|
||||
command: tokenCommand,
|
||||
};
|
||||
scheduleService.createIntervalTask(cron as any, {
|
||||
days: 28,
|
||||
runImmediately: true,
|
||||
});
|
||||
|
||||
// 运行删除日志任务
|
||||
const data = await systemService.getLogRemoveFrequency();
|
||||
if (data && data.info && data.info.frequency) {
|
||||
|
@ -17,7 +35,7 @@ export default async () => {
|
|||
name: '删除日志',
|
||||
command: `ql rmlog ${data.info.frequency}`,
|
||||
};
|
||||
await scheduleService.createIntervalTask(cron, {
|
||||
scheduleService.createIntervalTask(cron, {
|
||||
days: data.info.frequency,
|
||||
runImmediately: true,
|
||||
});
|
||||
|
|
|
@ -169,7 +169,7 @@ export default class ScheduleService {
|
|||
);
|
||||
|
||||
const job = new LongIntervalJob(
|
||||
{ ...schedule, runImmediately: false },
|
||||
{ runImmediately: false, ...schedule },
|
||||
task,
|
||||
_id,
|
||||
);
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
get_token() {
|
||||
local tokenFile="$dir_static/build/token.js"
|
||||
if [[ ! -f "$tokenFile" ]]; then
|
||||
token=$(ts-node-transpile-only "$dir_root/back/token.ts")
|
||||
else
|
||||
token=$(node "$tokenFile")
|
||||
fi
|
||||
token=$(cat $file_auth_token | jq -r .value)
|
||||
}
|
||||
|
||||
add_cron_api() {
|
||||
|
|
|
@ -24,6 +24,7 @@ file_sharecode=$dir_config/sharecode.sh
|
|||
file_config_user=$dir_config/config.sh
|
||||
file_auth_sample=$dir_sample/auth.sample.json
|
||||
file_auth_user=$dir_config/auth.json
|
||||
file_auth_token=$dir_config/token.json
|
||||
file_extra_shell=$dir_config/extra.sh
|
||||
file_task_before=$dir_config/task_before.sh
|
||||
file_task_after=$dir_config/task_after.sh
|
||||
|
|
Loading…
Reference in New Issue
Block a user