mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-22 22:36:06 +08:00
增加手动停止标识
This commit is contained in:
parent
678e3e2dc6
commit
43d6ac2071
|
@ -56,7 +56,9 @@ function run() {
|
||||||
for (const key in newEnvObject) {
|
for (const key in newEnvObject) {
|
||||||
process.env[key] = newEnvObject[key];
|
process.env[key] = newEnvObject[key];
|
||||||
}
|
}
|
||||||
console.log(output);
|
if (output) {
|
||||||
|
console.log(output);
|
||||||
|
}
|
||||||
if (task_before) {
|
if (task_before) {
|
||||||
console.log('执行前置命令结束\n');
|
console.log('执行前置命令结束\n');
|
||||||
}
|
}
|
||||||
|
@ -89,6 +91,10 @@ try {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
process.on('SIGTERM', (code) => {
|
||||||
|
process.exit(15);
|
||||||
|
});
|
||||||
|
|
||||||
run();
|
run();
|
||||||
|
|
||||||
const { sendNotify } = require('./notify.js');
|
const { sendNotify } = require('./notify.js');
|
||||||
|
|
|
@ -5,6 +5,7 @@ import json
|
||||||
import builtins
|
import builtins
|
||||||
import sys
|
import sys
|
||||||
import env
|
import env
|
||||||
|
import signal
|
||||||
|
|
||||||
|
|
||||||
def try_parse_int(value):
|
def try_parse_int(value):
|
||||||
|
@ -63,7 +64,8 @@ def run():
|
||||||
for key, value in env_json.items():
|
for key, value in env_json.items():
|
||||||
os.environ[key] = value
|
os.environ[key] = value
|
||||||
|
|
||||||
print(output)
|
if len(output) > 0:
|
||||||
|
print(output)
|
||||||
if task_before:
|
if task_before:
|
||||||
print("执行前置命令结束")
|
print("执行前置命令结束")
|
||||||
|
|
||||||
|
@ -95,7 +97,13 @@ def run():
|
||||||
os.environ[env_param] = env_str
|
os.environ[env_param] = env_str
|
||||||
|
|
||||||
|
|
||||||
|
def handle_sigterm(signum, frame):
|
||||||
|
sys.exit(15)
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
signal.signal(signal.SIGTERM, handle_sigterm)
|
||||||
|
|
||||||
run()
|
run()
|
||||||
|
|
||||||
from notify import send
|
from notify import send
|
||||||
|
|
|
@ -467,10 +467,12 @@ handle_task_end() {
|
||||||
local end_time=$(format_time "$time_format" "$etime")
|
local end_time=$(format_time "$time_format" "$etime")
|
||||||
local end_timestamp=$(format_timestamp "$time_format" "$etime")
|
local end_timestamp=$(format_timestamp "$time_format" "$etime")
|
||||||
local diff_time=$(($end_timestamp - $begin_timestamp))
|
local diff_time=$(($end_timestamp - $begin_timestamp))
|
||||||
|
local suffix=""
|
||||||
|
[[ "$MANUAL" == "true" ]] && suffix="(手动停止)"
|
||||||
|
|
||||||
[[ "$diff_time" == 0 ]] && diff_time=1
|
[[ "$diff_time" == 0 ]] && diff_time=1
|
||||||
|
|
||||||
echo -e "\n## 执行结束... $end_time 耗时 $diff_time 秒 "
|
echo -e "\n## 执行结束$suffix... $end_time 耗时 $diff_time 秒 "
|
||||||
[[ $ID ]] && update_cron "\"$ID\"" "1" "" "$log_path" "$begin_timestamp" "$diff_time"
|
[[ $ID ]] && update_cron "\"$ID\"" "1" "" "$log_path" "$begin_timestamp" "$diff_time"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ dir_shell=$QL_DIR/shell
|
||||||
|
|
||||||
trap "single_hanle" 2 3 20 15 14 19 1
|
trap "single_hanle" 2 3 20 15 14 19 1
|
||||||
single_hanle() {
|
single_hanle() {
|
||||||
eval handle_task_end "$@" "$cmd"
|
eval MANUAL=true handle_task_end "$@" "$cmd"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,4 +6,6 @@ export const LANG_MAP = {
|
||||||
'.mjs': 'javascript',
|
'.mjs': 'javascript',
|
||||||
'.sh': 'shell',
|
'.sh': 'shell',
|
||||||
'.ts': 'typescript',
|
'.ts': 'typescript',
|
||||||
|
'.ini': 'ini',
|
||||||
|
'.json': 'json'
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user