@whyour/qinglong 2.17.8-rc.3 → 2.17.9
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/docker/docker-entrypoint.sh +2 -1
- package/package.json +1 -1
- package/sample/config.sample.sh +1 -1
- package/sample/ql_sample.js +2 -4
- package/sample/ql_sample.py +2 -3
- package/shell/otask.sh +20 -12
- package/shell/preload/sitecustomize.js +51 -3
- package/shell/preload/sitecustomize.py +53 -1
- package/shell/share.sh +47 -59
- package/shell/start.sh +11 -0
- package/shell/task.sh +2 -1
- package/shell/update.sh +2 -1
- package/static/build/config/index.js +4 -0
- package/static/build/loaders/initFile.js +14 -0
- package/static/dist/index.html +1 -1
- package/static/dist/{umi.03b3fd83.js → umi.5e777fc4.js} +1 -1
- package/version.yaml +6 -5
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
|
|
3
3
|
dir_shell=/ql/shell
|
|
4
|
-
. $dir_shell/env.sh
|
|
5
4
|
. $dir_shell/share.sh
|
|
5
|
+
. $dir_shell/env.sh
|
|
6
6
|
|
|
7
7
|
echo -e "======================1. 检测配置文件========================\n"
|
|
8
|
+
import_config "$@"
|
|
8
9
|
make_dir /etc/nginx/conf.d
|
|
9
10
|
make_dir /run/nginx
|
|
10
11
|
init_nginx
|
package/package.json
CHANGED
package/sample/config.sample.sh
CHANGED
package/sample/ql_sample.js
CHANGED
|
@@ -4,8 +4,6 @@
|
|
|
4
4
|
* 定时规则
|
|
5
5
|
* cron: 1 9 * * *
|
|
6
6
|
*/
|
|
7
|
-
const { sendNotify } = require('./sendNotify.js'); // commonjs
|
|
8
|
-
// import { sendNotify } from './sendNotify'; // es6
|
|
9
|
-
|
|
10
7
|
console.log('test scripts');
|
|
11
|
-
|
|
8
|
+
QLAPI.notify('test scripts', 'test desc');
|
|
9
|
+
console.log('test desc');
|
package/sample/ql_sample.py
CHANGED
package/shell/otask.sh
CHANGED
|
@@ -69,14 +69,18 @@ run_nohup() {
|
|
|
69
69
|
nohup node $file_name &>$log_path &
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
|
|
73
72
|
env_str_to_array() {
|
|
73
|
+
. $file_env
|
|
74
74
|
local IFS="&"
|
|
75
75
|
read -ra array <<<"${!env_param}"
|
|
76
|
+
array_length=${#array[@]}
|
|
77
|
+
clear_env
|
|
76
78
|
}
|
|
77
79
|
|
|
78
80
|
clear_non_sh_env() {
|
|
79
|
-
|
|
81
|
+
if [[ $file_param != *.sh ]]; then
|
|
82
|
+
clear_env
|
|
83
|
+
fi
|
|
80
84
|
}
|
|
81
85
|
|
|
82
86
|
## 正常运行单个脚本,$1:传入参数
|
|
@@ -96,7 +100,7 @@ run_normal() {
|
|
|
96
100
|
if [[ $isJsOrPythonFile == 'false' ]]; then
|
|
97
101
|
clear_non_sh_env
|
|
98
102
|
fi
|
|
99
|
-
|
|
103
|
+
$timeoutCmd $which_program $file_param "${script_params[@]}"
|
|
100
104
|
}
|
|
101
105
|
|
|
102
106
|
handle_env_split() {
|
|
@@ -105,7 +109,7 @@ handle_env_split() {
|
|
|
105
109
|
fi
|
|
106
110
|
|
|
107
111
|
env_str_to_array
|
|
108
|
-
local tempArr=$(echo $num_param | sed "s/-max/-${
|
|
112
|
+
local tempArr=$(echo $num_param | sed "s/-max/-${array_length}/g" | sed "s/max-/${array_length}-/g" | perl -pe "s|(\d+)(-\|~\|_)(\d+)|{\1..\3}|g")
|
|
109
113
|
local runArr=($(eval echo $tempArr))
|
|
110
114
|
array_run=($(awk -v RS=' ' '!a[$1]++' <<<${runArr[@]}))
|
|
111
115
|
}
|
|
@@ -139,7 +143,7 @@ run_concurrent() {
|
|
|
139
143
|
export "${env_param}=${array[$i - 1]}"
|
|
140
144
|
clear_non_sh_env
|
|
141
145
|
fi
|
|
142
|
-
eval
|
|
146
|
+
eval envParam="${env_param}" numParam="${i}" $timeoutCmd $which_program $file_param "${script_params[@]}" &>$single_log_path &
|
|
143
147
|
done
|
|
144
148
|
|
|
145
149
|
wait
|
|
@@ -184,7 +188,7 @@ run_designated() {
|
|
|
184
188
|
file_param=${file_param/$relative_path\//}
|
|
185
189
|
fi
|
|
186
190
|
|
|
187
|
-
|
|
191
|
+
envParam="${env_param}" numParam="${num_param}" $timeoutCmd $which_program $file_param "${script_params[@]}"
|
|
188
192
|
}
|
|
189
193
|
|
|
190
194
|
## 运行其他命令
|
|
@@ -204,22 +208,23 @@ run_else() {
|
|
|
204
208
|
$timeoutCmd $which_program $file_param "$@"
|
|
205
209
|
}
|
|
206
210
|
|
|
207
|
-
|
|
208
|
-
main() {
|
|
211
|
+
check_file() {
|
|
209
212
|
isJsOrPythonFile="false"
|
|
210
213
|
if [[ $1 == *.js ]] || [[ $1 == *.py ]] || [[ $1 == *.pyc ]] || [[ $1 == *.ts ]]; then
|
|
211
214
|
isJsOrPythonFile="true"
|
|
212
215
|
fi
|
|
213
216
|
if [[ -f $file_env ]]; then
|
|
217
|
+
get_env_array
|
|
214
218
|
if [[ $isJsOrPythonFile == 'true' ]]; then
|
|
215
|
-
export NODE_OPTIONS="${NODE_OPTIONS} -r ${
|
|
216
|
-
export PYTHONPATH="${PYTHONPATH}:${dir_preload}"
|
|
219
|
+
export NODE_OPTIONS="${NODE_OPTIONS} -r ${file_preload_js}"
|
|
220
|
+
export PYTHONPATH="${PYTHONPATH}:${dir_preload}:${dir_config}"
|
|
217
221
|
else
|
|
218
|
-
get_env_array
|
|
219
222
|
. $file_env
|
|
220
223
|
fi
|
|
221
224
|
fi
|
|
225
|
+
}
|
|
222
226
|
|
|
227
|
+
main() {
|
|
223
228
|
if [[ $1 == *.js ]] || [[ $1 == *.py ]] || [[ $1 == *.pyc ]] || [[ $1 == *.sh ]] || [[ $1 == *.ts ]]; then
|
|
224
229
|
if [[ $1 == *.sh ]]; then
|
|
225
230
|
timeoutCmd=""
|
|
@@ -255,7 +260,10 @@ main() {
|
|
|
255
260
|
}
|
|
256
261
|
|
|
257
262
|
handle_task_start "${task_shell_params[@]}"
|
|
258
|
-
|
|
263
|
+
check_file "${task_shell_params[@]}"
|
|
264
|
+
if [[ $isJsOrPythonFile == 'false' ]]; then
|
|
265
|
+
run_task_before "${task_shell_params[@]}"
|
|
266
|
+
fi
|
|
259
267
|
main "${task_shell_params[@]}"
|
|
260
268
|
run_task_after "${task_shell_params[@]}"
|
|
261
269
|
clear_env
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
+
const { execSync } = require('child_process');
|
|
2
|
+
const { sendNotify } = require('./notify.js');
|
|
1
3
|
require(`./env.js`);
|
|
2
4
|
|
|
5
|
+
function initGlobal() {
|
|
6
|
+
global.QLAPI = {
|
|
7
|
+
notify: sendNotify,
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
|
|
3
11
|
function expandRange(rangeStr, max) {
|
|
4
12
|
const tempRangeStr = rangeStr
|
|
5
13
|
.trim()
|
|
@@ -17,8 +25,43 @@ function expandRange(rangeStr, max) {
|
|
|
17
25
|
}
|
|
18
26
|
|
|
19
27
|
function run() {
|
|
20
|
-
|
|
21
|
-
|
|
28
|
+
const {
|
|
29
|
+
envParam,
|
|
30
|
+
numParam,
|
|
31
|
+
file_task_before,
|
|
32
|
+
file_task_before_js,
|
|
33
|
+
dir_scripts,
|
|
34
|
+
task_before,
|
|
35
|
+
} = process.env;
|
|
36
|
+
|
|
37
|
+
require(file_task_before_js);
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
const splitStr = '__sitecustomize__';
|
|
41
|
+
const fileName = process.argv[1].replace(`${dir_scripts}/`, '');
|
|
42
|
+
let command = `bash -c "source ${file_task_before} ${fileName}`;
|
|
43
|
+
if (task_before) {
|
|
44
|
+
command = `${command} && echo -e '执行前置命令\n' && eval "${task_before}" && echo -e '\n执行前置命令结束\n'`;
|
|
45
|
+
}
|
|
46
|
+
const res = execSync(
|
|
47
|
+
`${command} && echo "${splitStr}" && NODE_OPTIONS= node -p 'JSON.stringify(process.env)'"`,
|
|
48
|
+
{
|
|
49
|
+
encoding: 'utf-8',
|
|
50
|
+
},
|
|
51
|
+
);
|
|
52
|
+
const [output, envStr] = res.split(splitStr);
|
|
53
|
+
const newEnvObject = JSON.parse(envStr.trim());
|
|
54
|
+
for (const key in newEnvObject) {
|
|
55
|
+
process.env[key] = newEnvObject[key];
|
|
56
|
+
}
|
|
57
|
+
console.log(output);
|
|
58
|
+
} catch (error) {
|
|
59
|
+
if (!error.message.includes('spawnSync /bin/sh E2BIG')) {
|
|
60
|
+
console.log(`run task before error: `, error);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (envParam && numParam) {
|
|
22
65
|
const array = (process.env[envParam] || '').split('&');
|
|
23
66
|
const runArr = expandRange(numParam, array.length);
|
|
24
67
|
const arrayRun = runArr.map((i) => array[i - 1]);
|
|
@@ -27,4 +70,9 @@ function run() {
|
|
|
27
70
|
}
|
|
28
71
|
}
|
|
29
72
|
|
|
30
|
-
|
|
73
|
+
try {
|
|
74
|
+
initGlobal();
|
|
75
|
+
run();
|
|
76
|
+
} catch (error) {
|
|
77
|
+
console.log(`run builtin code error: `, error, '\n');
|
|
78
|
+
}
|
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import re
|
|
3
|
+
import subprocess
|
|
4
|
+
import json
|
|
5
|
+
import builtins
|
|
6
|
+
import sys
|
|
3
7
|
import env
|
|
8
|
+
from notify import send
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class BaseApi:
|
|
12
|
+
def notify(self, *args, **kwargs):
|
|
13
|
+
return send(*args, **kwargs)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def init_global():
|
|
17
|
+
QLAPI = BaseApi()
|
|
18
|
+
builtins.QLAPI = QLAPI
|
|
4
19
|
|
|
5
20
|
|
|
6
21
|
def try_parse_int(value):
|
|
@@ -30,6 +45,39 @@ def expand_range(range_str, max_value):
|
|
|
30
45
|
|
|
31
46
|
|
|
32
47
|
def run():
|
|
48
|
+
import task_before
|
|
49
|
+
|
|
50
|
+
try:
|
|
51
|
+
split_str = "__sitecustomize__"
|
|
52
|
+
file_name = sys.argv[0].replace(f"{os.getenv('dir_scripts')}/", "")
|
|
53
|
+
command = f'bash -c "source {os.getenv("file_task_before")} {file_name}'
|
|
54
|
+
task_before = os.getenv("task_before")
|
|
55
|
+
|
|
56
|
+
if task_before:
|
|
57
|
+
command += f" && echo -e '执行前置命令\n' && eval \"{task_before}\" && echo -e '\n执行前置命令结束\n'"
|
|
58
|
+
|
|
59
|
+
python_command = "PYTHONPATH= python3 -c 'import os, json; print(json.dumps(dict(os.environ)))'"
|
|
60
|
+
command += f' && echo "{split_str}" && {python_command}"'
|
|
61
|
+
|
|
62
|
+
res = subprocess.check_output(command, shell=True, encoding="utf-8")
|
|
63
|
+
output, env_str = res.split(split_str)
|
|
64
|
+
|
|
65
|
+
env_json = json.loads(env_str.strip())
|
|
66
|
+
|
|
67
|
+
for key, value in env_json.items():
|
|
68
|
+
os.environ[key] = value
|
|
69
|
+
|
|
70
|
+
print(output)
|
|
71
|
+
|
|
72
|
+
except subprocess.CalledProcessError as error:
|
|
73
|
+
print(f"run task before error: {error}")
|
|
74
|
+
except OSError as error:
|
|
75
|
+
error_message = str(error)
|
|
76
|
+
if "Argument list too long" not in error_message:
|
|
77
|
+
print(f"run task before error: {error}")
|
|
78
|
+
except Exception as error:
|
|
79
|
+
print(f"run task before error: {error}")
|
|
80
|
+
|
|
33
81
|
env_param = os.getenv("envParam")
|
|
34
82
|
num_param = os.getenv("numParam")
|
|
35
83
|
|
|
@@ -41,4 +89,8 @@ def run():
|
|
|
41
89
|
os.environ[env_param] = env_str
|
|
42
90
|
|
|
43
91
|
|
|
44
|
-
|
|
92
|
+
try:
|
|
93
|
+
init_global()
|
|
94
|
+
run()
|
|
95
|
+
except Exception as error:
|
|
96
|
+
print(f"run builtin code error: {error}\n")
|
package/shell/share.sh
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
|
|
3
3
|
## 目录
|
|
4
|
-
dir_root=$QL_DIR
|
|
5
|
-
dir_tmp=$dir_root/.tmp
|
|
6
|
-
dir_data=$dir_root/data
|
|
4
|
+
export dir_root=$QL_DIR
|
|
5
|
+
export dir_tmp=$dir_root/.tmp
|
|
6
|
+
export dir_data=$dir_root/data
|
|
7
7
|
|
|
8
8
|
if [[ $QL_DATA_DIR ]]; then
|
|
9
|
-
dir_data="${QL_DATA_DIR%/}"
|
|
9
|
+
export dir_data="${QL_DATA_DIR%/}"
|
|
10
10
|
fi
|
|
11
11
|
|
|
12
|
-
dir_shell=$dir_root/shell
|
|
13
|
-
dir_preload=$dir_shell/preload
|
|
14
|
-
dir_sample=$dir_root/sample
|
|
15
|
-
dir_static=$dir_root/static
|
|
16
|
-
dir_config=$dir_data/config
|
|
17
|
-
dir_scripts=$dir_data/scripts
|
|
18
|
-
dir_repo=$dir_data/repo
|
|
19
|
-
dir_raw=$dir_data/raw
|
|
20
|
-
dir_log=$dir_data/log
|
|
21
|
-
dir_db=$dir_data/db
|
|
22
|
-
dir_dep=$dir_data/deps
|
|
23
|
-
dir_list_tmp=$dir_log/.tmp
|
|
24
|
-
dir_update_log=$dir_log/update
|
|
25
|
-
ql_static_repo=$dir_repo/static
|
|
12
|
+
export dir_shell=$dir_root/shell
|
|
13
|
+
export dir_preload=$dir_shell/preload
|
|
14
|
+
export dir_sample=$dir_root/sample
|
|
15
|
+
export dir_static=$dir_root/static
|
|
16
|
+
export dir_config=$dir_data/config
|
|
17
|
+
export dir_scripts=$dir_data/scripts
|
|
18
|
+
export dir_repo=$dir_data/repo
|
|
19
|
+
export dir_raw=$dir_data/raw
|
|
20
|
+
export dir_log=$dir_data/log
|
|
21
|
+
export dir_db=$dir_data/db
|
|
22
|
+
export dir_dep=$dir_data/deps
|
|
23
|
+
export dir_list_tmp=$dir_log/.tmp
|
|
24
|
+
export dir_update_log=$dir_log/update
|
|
25
|
+
export ql_static_repo=$dir_repo/static
|
|
26
26
|
|
|
27
27
|
## 文件
|
|
28
|
-
file_config_sample=$dir_sample/config.sample.sh
|
|
29
|
-
file_env=$dir_preload/env.sh
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
file_task_after=$dir_config/task_after.sh
|
|
41
|
-
file_task_sample=$dir_sample/task.sample.sh
|
|
42
|
-
file_extra_sample=$dir_sample/extra.sample.sh
|
|
43
|
-
file_notify_js_sample=$dir_sample/notify.js
|
|
44
|
-
file_notify_py_sample=$dir_sample/notify.py
|
|
45
|
-
file_test_js_sample=$dir_sample/ql_sample.js
|
|
46
|
-
file_test_py_sample=$dir_sample/ql_sample.py
|
|
47
|
-
file_notify_py=$dir_scripts/notify.py
|
|
48
|
-
file_notify_js=$dir_scripts/sendNotify.js
|
|
49
|
-
file_test_js=$dir_scripts/ql_sample.js
|
|
50
|
-
file_test_py=$dir_scripts/ql_sample.py
|
|
51
|
-
nginx_app_conf=$dir_root/docker/front.conf
|
|
52
|
-
nginx_conf=$dir_root/docker/nginx.conf
|
|
53
|
-
dep_notify_py=$dir_dep/notify.py
|
|
54
|
-
dep_notify_js=$dir_dep/sendNotify.js
|
|
28
|
+
export file_config_sample=$dir_sample/config.sample.sh
|
|
29
|
+
export file_env=$dir_preload/env.sh
|
|
30
|
+
export file_preload_js=$dir_preload/sitecustomize.js
|
|
31
|
+
export file_sharecode=$dir_config/sharecode.sh
|
|
32
|
+
export file_config_user=$dir_config/config.sh
|
|
33
|
+
export file_auth_sample=$dir_sample/auth.sample.json
|
|
34
|
+
export file_auth_user=$dir_config/auth.json
|
|
35
|
+
export file_auth_token=$dir_config/token.json
|
|
36
|
+
export file_extra_shell=$dir_config/extra.sh
|
|
37
|
+
export file_task_before=$dir_config/task_before.sh
|
|
38
|
+
export file_task_before_js=$dir_config/task_before.js
|
|
39
|
+
export file_task_before_py=$dir_config/task_before.py
|
|
40
|
+
export file_task_after=$dir_config/task_after.sh
|
|
41
|
+
export file_task_sample=$dir_sample/task.sample.sh
|
|
42
|
+
export file_extra_sample=$dir_sample/extra.sample.sh
|
|
43
|
+
export file_notify_js_sample=$dir_sample/notify.js
|
|
44
|
+
export file_notify_py_sample=$dir_sample/notify.py
|
|
45
|
+
export file_test_js_sample=$dir_sample/ql_sample.js
|
|
46
|
+
export file_test_py_sample=$dir_sample/ql_sample.py
|
|
47
|
+
export file_notify_py=$dir_scripts/notify.py
|
|
48
|
+
export file_notify_js=$dir_scripts/sendNotify.js
|
|
49
|
+
export file_test_js=$dir_scripts/ql_sample.js
|
|
50
|
+
export file_test_py=$dir_scripts/ql_sample.py
|
|
51
|
+
export nginx_app_conf=$dir_root/docker/front.conf
|
|
52
|
+
export nginx_conf=$dir_root/docker/nginx.conf
|
|
53
|
+
export dep_notify_py=$dir_dep/notify.py
|
|
54
|
+
export dep_notify_js=$dir_dep/sendNotify.js
|
|
55
55
|
|
|
56
56
|
## 清单文件
|
|
57
57
|
list_crontab_user=$dir_config/crontab.list
|
|
@@ -91,10 +91,6 @@ import_config() {
|
|
|
91
91
|
else
|
|
92
92
|
default_cron="$(random_range 0 59) $(random_range 0 23) * * *"
|
|
93
93
|
fi
|
|
94
|
-
|
|
95
|
-
cpu_warn=${CpuWarn}
|
|
96
|
-
mem_warn=${MemoryWarn}
|
|
97
|
-
disk_warn=${DiskWarn}
|
|
98
94
|
}
|
|
99
95
|
|
|
100
96
|
set_proxy() {
|
|
@@ -179,12 +175,6 @@ fix_config() {
|
|
|
179
175
|
echo
|
|
180
176
|
fi
|
|
181
177
|
|
|
182
|
-
if [[ ! -f $file_env ]]; then
|
|
183
|
-
echo -e "检测到config配置目录下不存在env.sh,创建一个空文件用于初始化...\n"
|
|
184
|
-
touch $file_env
|
|
185
|
-
echo
|
|
186
|
-
fi
|
|
187
|
-
|
|
188
178
|
if [[ ! -f $file_task_before ]]; then
|
|
189
179
|
echo -e "复制一份 $file_task_sample 为 $file_task_before\n"
|
|
190
180
|
cp -fv $file_task_sample $file_task_before
|
|
@@ -463,7 +453,7 @@ run_task_before() {
|
|
|
463
453
|
|
|
464
454
|
if [[ $task_before ]]; then
|
|
465
455
|
echo -e "执行前置命令\n"
|
|
466
|
-
eval "$task_before"
|
|
456
|
+
eval "$task_before" "$@"
|
|
467
457
|
echo -e "\n执行前置命令结束\n"
|
|
468
458
|
fi
|
|
469
459
|
}
|
|
@@ -473,7 +463,7 @@ run_task_after() {
|
|
|
473
463
|
|
|
474
464
|
if [[ $task_after ]]; then
|
|
475
465
|
echo -e "\n执行后置命令\n"
|
|
476
|
-
eval "$task_after"
|
|
466
|
+
eval "$task_after" "$@"
|
|
477
467
|
echo -e "\n执行后置命令结束"
|
|
478
468
|
fi
|
|
479
469
|
}
|
|
@@ -494,5 +484,3 @@ init_env
|
|
|
494
484
|
detect_termux
|
|
495
485
|
detect_macos
|
|
496
486
|
define_cmd
|
|
497
|
-
|
|
498
|
-
import_config $1
|
package/shell/start.sh
CHANGED
|
@@ -27,6 +27,14 @@ if [[ ! $QL_DATA_DIR ]]; then
|
|
|
27
27
|
exit 1
|
|
28
28
|
fi
|
|
29
29
|
|
|
30
|
+
command="$1"
|
|
31
|
+
|
|
32
|
+
if [[ $command == "reload" ]]; then
|
|
33
|
+
mkdir -p /run/nginx
|
|
34
|
+
nginx -s reload 2>/dev/null || nginx -c /etc/nginx/nginx.conf
|
|
35
|
+
exit 1
|
|
36
|
+
fi
|
|
37
|
+
|
|
30
38
|
# 安装依赖
|
|
31
39
|
os_name=$(source /etc/os-release && echo "$ID")
|
|
32
40
|
|
|
@@ -92,6 +100,9 @@ if [[ $EnableExtraShell == true ]]; then
|
|
|
92
100
|
echo -e "自定义脚本后台执行中...\n"
|
|
93
101
|
fi
|
|
94
102
|
|
|
103
|
+
pm2 startup
|
|
104
|
+
pm2 save
|
|
105
|
+
|
|
95
106
|
echo -e "############################################################\n"
|
|
96
107
|
echo -e "启动完成..."
|
|
97
108
|
echo -e "############################################################\n"
|
package/shell/task.sh
CHANGED
|
@@ -19,7 +19,7 @@ define_program() {
|
|
|
19
19
|
elif [[ $file_param == *.py ]] || [[ $file_param == *.pyc ]]; then
|
|
20
20
|
which_program="python3"
|
|
21
21
|
elif [[ $file_param == *.sh ]]; then
|
|
22
|
-
which_program="
|
|
22
|
+
which_program="."
|
|
23
23
|
elif [[ $file_param == *.ts ]]; then
|
|
24
24
|
which_program="ts-node-transpile-only"
|
|
25
25
|
else
|
|
@@ -113,6 +113,7 @@ init_begin_time() {
|
|
|
113
113
|
begin_timestamp=$(format_timestamp "$time_format" "$time")
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
+
import_config "$@"
|
|
116
117
|
while getopts ":lm:" opt; do
|
|
117
118
|
case $opt in
|
|
118
119
|
l)
|
package/shell/update.sh
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
|
|
3
3
|
dir_shell=$QL_DIR/shell
|
|
4
|
-
. $dir_shell/env.sh
|
|
5
4
|
. $dir_shell/share.sh
|
|
6
5
|
. $dir_shell/api.sh
|
|
6
|
+
. $dir_shell/env.sh
|
|
7
7
|
|
|
8
8
|
send_mark=$dir_shell/send_mark
|
|
9
9
|
|
|
@@ -563,6 +563,7 @@ main() {
|
|
|
563
563
|
fi
|
|
564
564
|
}
|
|
565
565
|
|
|
566
|
+
import_config "$@"
|
|
566
567
|
main "$@"
|
|
567
568
|
|
|
568
569
|
exit 0
|
|
@@ -38,6 +38,8 @@ const systemLogPath = path_1.default.join(dataPath, 'syslog/');
|
|
|
38
38
|
const envFile = path_1.default.join(preloadPath, 'env.sh');
|
|
39
39
|
const jsEnvFile = path_1.default.join(preloadPath, 'env.js');
|
|
40
40
|
const pyEnvFile = path_1.default.join(preloadPath, 'env.py');
|
|
41
|
+
const jsNotifyFile = path_1.default.join(preloadPath, 'notify.js');
|
|
42
|
+
const pyNotifyFile = path_1.default.join(preloadPath, 'notify.py');
|
|
41
43
|
const confFile = path_1.default.join(configPath, 'config.sh');
|
|
42
44
|
const crontabFile = path_1.default.join(configPath, 'crontab.list');
|
|
43
45
|
const authConfigFile = path_1.default.join(configPath, 'auth.json');
|
|
@@ -86,6 +88,8 @@ exports.default = {
|
|
|
86
88
|
envFile,
|
|
87
89
|
jsEnvFile,
|
|
88
90
|
pyEnvFile,
|
|
91
|
+
jsNotifyFile,
|
|
92
|
+
pyNotifyFile,
|
|
89
93
|
dbPath,
|
|
90
94
|
uploadPath,
|
|
91
95
|
configPath,
|
|
@@ -30,7 +30,11 @@ const sampleNotifyJsFile = path_1.default.join(samplePath, 'notify.js');
|
|
|
30
30
|
const sampleNotifyPyFile = path_1.default.join(samplePath, 'notify.py');
|
|
31
31
|
const scriptNotifyJsFile = path_1.default.join(scriptPath, 'sendNotify.js');
|
|
32
32
|
const scriptNotifyPyFile = path_1.default.join(scriptPath, 'notify.py');
|
|
33
|
+
const jsNotifyFile = path_1.default.join(preloadPath, 'notify.js');
|
|
34
|
+
const pyNotifyFile = path_1.default.join(preloadPath, 'notify.py');
|
|
33
35
|
const TaskBeforeFile = path_1.default.join(configPath, 'task_before.sh');
|
|
36
|
+
const TaskBeforeJsFile = path_1.default.join(configPath, 'task_before.js');
|
|
37
|
+
const TaskBeforePyFile = path_1.default.join(configPath, 'task_before.py');
|
|
34
38
|
const TaskAfterFile = path_1.default.join(configPath, 'task_after.sh');
|
|
35
39
|
const homedir = os_1.default.homedir();
|
|
36
40
|
const sshPath = path_1.default.resolve(homedir, '.ssh');
|
|
@@ -52,6 +56,8 @@ exports.default = async () => {
|
|
|
52
56
|
const scriptNotifyJsFileExist = await (0, util_1.fileExist)(scriptNotifyJsFile);
|
|
53
57
|
const scriptNotifyPyFileExist = await (0, util_1.fileExist)(scriptNotifyPyFile);
|
|
54
58
|
const TaskBeforeFileExist = await (0, util_1.fileExist)(TaskBeforeFile);
|
|
59
|
+
const TaskBeforeJsFileExist = await (0, util_1.fileExist)(TaskBeforeJsFile);
|
|
60
|
+
const TaskBeforePyFileExist = await (0, util_1.fileExist)(TaskBeforePyFile);
|
|
55
61
|
const TaskAfterFileExist = await (0, util_1.fileExist)(TaskAfterFile);
|
|
56
62
|
if (!configDirExist) {
|
|
57
63
|
await promises_1.default.mkdir(configPath);
|
|
@@ -90,6 +96,8 @@ exports.default = async () => {
|
|
|
90
96
|
if (!confFileExist) {
|
|
91
97
|
await promises_1.default.writeFile(confFile, await promises_1.default.readFile(sampleConfigFile));
|
|
92
98
|
}
|
|
99
|
+
await promises_1.default.writeFile(jsNotifyFile, await promises_1.default.readFile(sampleNotifyJsFile));
|
|
100
|
+
await promises_1.default.writeFile(pyNotifyFile, await promises_1.default.readFile(sampleNotifyPyFile));
|
|
93
101
|
if (!scriptNotifyJsFileExist) {
|
|
94
102
|
await promises_1.default.writeFile(scriptNotifyJsFile, await promises_1.default.readFile(sampleNotifyJsFile));
|
|
95
103
|
}
|
|
@@ -99,6 +107,12 @@ exports.default = async () => {
|
|
|
99
107
|
if (!TaskBeforeFileExist) {
|
|
100
108
|
await promises_1.default.writeFile(TaskBeforeFile, await promises_1.default.readFile(sampleTaskShellFile));
|
|
101
109
|
}
|
|
110
|
+
if (!TaskBeforeJsFileExist) {
|
|
111
|
+
await promises_1.default.writeFile(TaskBeforeJsFile, '// The JavaScript code that executes before the JavaScript task execution will execute.');
|
|
112
|
+
}
|
|
113
|
+
if (!TaskBeforePyFileExist) {
|
|
114
|
+
await promises_1.default.writeFile(TaskBeforePyFile, '# The Python code that executes before the Python task execution will execute.');
|
|
115
|
+
}
|
|
102
116
|
if (!TaskAfterFileExist) {
|
|
103
117
|
await promises_1.default.writeFile(TaskAfterFile, await promises_1.default.readFile(sampleTaskShellFile));
|
|
104
118
|
}
|