@whyour/qinglong 0.19.0 → 0.19.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/shell/share.sh
CHANGED
|
@@ -134,31 +134,6 @@ gen_random_num() {
|
|
|
134
134
|
echo $((${RANDOM} % $divi))
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
link_shell_sub() {
|
|
138
|
-
local link_path="$1"
|
|
139
|
-
local original_path="$2"
|
|
140
|
-
if [[ ! -L $link_path ]] || [[ $(readlink -f $link_path) != $original_path ]]; then
|
|
141
|
-
rm -f $link_path 2>/dev/null
|
|
142
|
-
ln -sf $original_path $link_path
|
|
143
|
-
fi
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
link_shell() {
|
|
147
|
-
if [[ $is_termux -eq 1 ]]; then
|
|
148
|
-
local path="/data/data/com.termux/files/usr/bin/"
|
|
149
|
-
elif [[ $PATH == */usr/local/bin* ]] && [[ -d /usr/local/bin ]]; then
|
|
150
|
-
local path="/usr/local/bin/"
|
|
151
|
-
else
|
|
152
|
-
local path=""
|
|
153
|
-
echo -e "脚本功能受限,请自行添加命令的软连接...\n"
|
|
154
|
-
fi
|
|
155
|
-
if [[ $path ]]; then
|
|
156
|
-
for ((i = 0; i < ${#link_name[*]}; i++)); do
|
|
157
|
-
link_shell_sub "$path${link_name[i]}" "$dir_shell/${original_name[i]}"
|
|
158
|
-
done
|
|
159
|
-
fi
|
|
160
|
-
}
|
|
161
|
-
|
|
162
137
|
define_cmd() {
|
|
163
138
|
local cmd_prefix cmd_suffix
|
|
164
139
|
if type task &>/dev/null; then
|
|
@@ -26,17 +26,20 @@ async function linkCommand() {
|
|
|
26
26
|
{
|
|
27
27
|
src: 'update.sh',
|
|
28
28
|
dest: 'ql',
|
|
29
|
+
tmp: 'ql_tmp',
|
|
29
30
|
},
|
|
30
31
|
{
|
|
31
32
|
src: 'task.sh',
|
|
32
33
|
dest: 'task',
|
|
34
|
+
tmp: 'task_tmp',
|
|
33
35
|
},
|
|
34
36
|
];
|
|
35
37
|
for (const link of linkShell) {
|
|
36
38
|
const source = path_1.default.join(index_1.default.rootPath, 'shell', link.src);
|
|
37
39
|
const target = path_1.default.join(commandDir, link.dest);
|
|
38
|
-
|
|
39
|
-
await promises_1.default.symlink(source,
|
|
40
|
+
const tmpTarget = path_1.default.join(commandDir, link.tmp);
|
|
41
|
+
await promises_1.default.symlink(source, tmpTarget);
|
|
42
|
+
await promises_1.default.rename(tmpTarget, target);
|
|
40
43
|
}
|
|
41
44
|
}
|
|
42
45
|
exports.default = async (src = 'deps') => {
|
|
@@ -370,7 +370,7 @@ let CronService = class CronService {
|
|
|
370
370
|
}
|
|
371
371
|
const logPath = `${uniqPath}/${logTime}.log`;
|
|
372
372
|
const absolutePath = path_1.default.resolve(config_1.default.logPath, `${logPath}`);
|
|
373
|
-
const cp = (0, cross_spawn_1.spawn)(`real_log_path=${logPath}
|
|
373
|
+
const cp = (0, cross_spawn_1.spawn)(`real_log_path=${logPath} no_delay=true ${this.makeCommand(cron, true)}`, { shell: '/bin/bash' });
|
|
374
374
|
await cron_1.CrontabModel.update({ status: cron_1.CrontabStatus.running, pid: cp.pid, log_path: logPath }, { where: { id } });
|
|
375
375
|
cp.stdout.on('data', async (data) => {
|
|
376
376
|
await promises_1.default.appendFile(absolutePath, data.toString());
|
|
@@ -440,12 +440,12 @@ let CronService = class CronService {
|
|
|
440
440
|
return [];
|
|
441
441
|
}
|
|
442
442
|
}
|
|
443
|
-
makeCommand(tab) {
|
|
443
|
+
makeCommand(tab, realTime) {
|
|
444
444
|
let command = tab.command.trim();
|
|
445
445
|
if (!command.startsWith(const_1.TASK_PREFIX) && !command.startsWith(const_1.QL_PREFIX)) {
|
|
446
446
|
command = `${const_1.TASK_PREFIX}${tab.command}`;
|
|
447
447
|
}
|
|
448
|
-
let commandVariable = `no_tee=true ID=${tab.id} `;
|
|
448
|
+
let commandVariable = `real_time=${Boolean(realTime)} no_tee=true ID=${tab.id} `;
|
|
449
449
|
if (tab.task_before) {
|
|
450
450
|
commandVariable += `task_before='${tab.task_before
|
|
451
451
|
.replace(/'/g, "'\\''")
|
|
@@ -95,9 +95,9 @@ let SubscriptionService = class SubscriptionService {
|
|
|
95
95
|
throw error;
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
-
async handleTask(
|
|
99
|
-
const { url } = (0, subscription_2.formatUrl)(
|
|
100
|
-
doc
|
|
98
|
+
async handleTask(_doc, needCreate = true, runImmediately = false) {
|
|
99
|
+
const { url } = (0, subscription_2.formatUrl)(_doc);
|
|
100
|
+
const doc = Object.assign(Object.assign({}, _doc), { command: (0, subscription_2.formatCommand)(_doc, url) });
|
|
101
101
|
if (doc.schedule_type === 'crontab') {
|
|
102
102
|
this.scheduleService.cancelCronTask(doc);
|
|
103
103
|
needCreate &&
|
|
@@ -237,7 +237,10 @@ let SubscriptionService = class SubscriptionService {
|
|
|
237
237
|
}
|
|
238
238
|
async getDb(query) {
|
|
239
239
|
const doc = await subscription_1.SubscriptionModel.findOne({ where: Object.assign({}, query) });
|
|
240
|
-
|
|
240
|
+
if (!doc) {
|
|
241
|
+
throw new Error(`${JSON.stringify(query)} not found`);
|
|
242
|
+
}
|
|
243
|
+
return doc.get({ plain: true });
|
|
241
244
|
}
|
|
242
245
|
async run(ids) {
|
|
243
246
|
await subscription_1.SubscriptionModel.update({ status: subscription_1.SubscriptionStatus.queued }, { where: { id: ids } });
|