mirror of
https://github.com/whyour/qinglong.git
synced 2026-08-07 01:04:39 +08:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 929d2eb574 | |||
| ebedd994dd | |||
| ee7d39f433 | |||
| eab8a93f28 | |||
| 16b20e8b54 | |||
| 6dbd980881 | |||
| 35a17fce95 | |||
| 6a3dd4f83c | |||
| 177cd3de81 | |||
| d473c3ae88 |
@@ -507,7 +507,7 @@ export default class CronService {
|
||||
let { id, command, log_name } = cron;
|
||||
|
||||
const uniqPath =
|
||||
log_name === '/dev/null'
|
||||
log_name === '/dev/null' || !log_name
|
||||
? await getUniqPath(command, `${id}`)
|
||||
: log_name;
|
||||
const logTime = dayjs().format('YYYY-MM-DD-HH-mm-ss-SSS');
|
||||
@@ -641,7 +641,11 @@ export default class CronService {
|
||||
if (!command.startsWith(TASK_PREFIX) && !command.startsWith(QL_PREFIX)) {
|
||||
command = `${TASK_PREFIX}${tab.command}`;
|
||||
}
|
||||
let commandVariable = `real_time=${Boolean(realTime)} log_name=${tab.log_name} no_tee=true ID=${tab.id} `;
|
||||
let commandVariable = `real_time=${Boolean(realTime)} no_tee=true ID=${tab.id} `;
|
||||
// Only include log_name if it has a truthy value to avoid passing null/undefined to shell
|
||||
if (tab.log_name) {
|
||||
commandVariable += `log_name=${tab.log_name} `;
|
||||
}
|
||||
if (tab.task_before) {
|
||||
commandVariable += `task_before='${tab.task_before
|
||||
.replace(/'/g, "'\\''")
|
||||
|
||||
@@ -133,15 +133,15 @@ export default class SshKeyService {
|
||||
}
|
||||
|
||||
public async addGlobalSSHKey(key: string, alias: string): Promise<void> {
|
||||
await this.generatePrivateKeyFile(`global_${alias}`, key);
|
||||
await this.generatePrivateKeyFile(`~global_${alias}`, key);
|
||||
// Create a global SSH config entry that matches all hosts
|
||||
// This allows the key to be used for any Git repository
|
||||
await this.generateGlobalSshConfig(`global_${alias}`);
|
||||
await this.generateGlobalSshConfig(`~global_${alias}`);
|
||||
}
|
||||
|
||||
public async removeGlobalSSHKey(alias: string): Promise<void> {
|
||||
await this.removePrivateKeyFile(`global_${alias}`);
|
||||
await this.removeSshConfig(`global_${alias}`);
|
||||
await this.removePrivateKeyFile(`~global_${alias}`);
|
||||
await this.removeSshConfig(`~global_${alias}`);
|
||||
}
|
||||
|
||||
private async generateGlobalSshConfig(alias: string) {
|
||||
|
||||
@@ -350,11 +350,6 @@ export default class SubscriptionService {
|
||||
for (const doc of docs) {
|
||||
await this.handleTask(doc.get({ plain: true }), false);
|
||||
}
|
||||
// Disable associated cron tasks
|
||||
const crons = await CrontabModel.findAll({ where: { sub_id: ids } });
|
||||
if (crons?.length) {
|
||||
await this.crontabService.disabled(crons.map((x) => x.id!));
|
||||
}
|
||||
}
|
||||
|
||||
public async enabled(ids: number[]) {
|
||||
@@ -364,11 +359,6 @@ export default class SubscriptionService {
|
||||
for (const doc of docs) {
|
||||
await this.handleTask(doc.get({ plain: true }));
|
||||
}
|
||||
// Enable associated cron tasks
|
||||
const crons = await CrontabModel.findAll({ where: { sub_id: ids } });
|
||||
if (crons?.length) {
|
||||
await this.crontabService.enabled(crons.map((x) => x.id!));
|
||||
}
|
||||
}
|
||||
|
||||
public async log(id: number) {
|
||||
|
||||
@@ -23,11 +23,11 @@ log_with_style() {
|
||||
if [ -f /etc/alpine-release ]; then
|
||||
if ! grep -q "^options ndots:0" /etc/resolv.conf 2>/dev/null; then
|
||||
echo "options ndots:0" >> /etc/resolv.conf
|
||||
log_with_style "INFO" "🔧 已配置 DNS 解析优化 (ndots:0)"
|
||||
log_with_style "INFO" "🔧 0. 已配置 DNS 解析优化 (ndots:0)"
|
||||
fi
|
||||
fi
|
||||
|
||||
log_with_style "INFO" "🚀 1. 检测配置文件..."
|
||||
log_with_style "INFO" "🚀 1. 检测配置文件..."
|
||||
load_ql_envs
|
||||
export_ql_envs
|
||||
. $dir_shell/env.sh
|
||||
@@ -41,16 +41,16 @@ log_with_style "INFO" "⚙️ 2. 启动 pm2 服务..."
|
||||
reload_pm2
|
||||
|
||||
if [[ $AutoStartBot == true ]]; then
|
||||
log_with_style "INFO" "🤖 3. 启动 bot..."
|
||||
log_with_style "INFO" "🤖 3. 启动 bot..."
|
||||
nohup ql bot >$dir_log/bot.log 2>&1 &
|
||||
fi
|
||||
|
||||
if [[ $EnableExtraShell == true ]]; then
|
||||
log_with_style "INFO" "🛠️ 4. 执行自定义脚本..."
|
||||
log_with_style "INFO" "🛠️ 4. 执行自定义脚本..."
|
||||
nohup ql extra >$dir_log/extra.log 2>&1 &
|
||||
fi
|
||||
|
||||
log_with_style "SUCCESS" "🎉 容器启动成功!"
|
||||
log_with_style "SUCCESS" "🎉 容器启动成功!"
|
||||
|
||||
crond -f >/dev/null
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ function run() {
|
||||
numParam,
|
||||
file_task_before,
|
||||
file_task_before_js,
|
||||
file_preload_js,
|
||||
dir_scripts,
|
||||
task_before,
|
||||
PREV_NODE_OPTIONS,
|
||||
@@ -40,7 +41,13 @@ function run() {
|
||||
const fileName = process.argv[1].replace(`${dir_scripts}/`, '');
|
||||
const tempFile = `/tmp/env_${process.pid}.json`;
|
||||
|
||||
// Export NODE_OPTIONS so task_before can use it for any node commands
|
||||
const nodeOptionsForBash = file_preload_js
|
||||
? ['-r', file_preload_js, PREV_NODE_OPTIONS].filter(Boolean).join(' ')
|
||||
: PREV_NODE_OPTIONS || '';
|
||||
|
||||
const commands = [
|
||||
`export NODE_OPTIONS="${nodeOptionsForBash}"`,
|
||||
`source ${file_task_before} ${fileName}`,
|
||||
task_before ? `eval '${task_before.replace(/'/g, "'\\''")}'` : null,
|
||||
`echo -e '${splitStr}'`,
|
||||
|
||||
@@ -44,11 +44,19 @@ def run():
|
||||
split_str = "__sitecustomize__"
|
||||
file_name = sys.argv[0].replace(f"{os.getenv('dir_scripts')}/", "")
|
||||
|
||||
# Get environment variables needed for PYTHONPATH
|
||||
dir_preload = os.getenv("dir_preload", "")
|
||||
dir_config = os.getenv("dir_config", "")
|
||||
|
||||
# 创建临时文件路径
|
||||
temp_file = f"/tmp/env_{os.getpid()}.json"
|
||||
|
||||
# Export PYTHONPATH so task_before can use it for any python commands
|
||||
pythonpath_for_bash = ':'.join(filter(None, [dir_preload, dir_config, prev_pythonpath]))
|
||||
|
||||
# 构建命令数组
|
||||
commands = [
|
||||
f'export PYTHONPATH="{pythonpath_for_bash}"',
|
||||
f'source {os.getenv("file_task_before")} {file_name}'
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user