@whyour/qinglong 2.19.0-5 → 2.19.0-7

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.
@@ -0,0 +1,142 @@
1
+ syntax = "proto3";
2
+
3
+ package com.ql.api;
4
+
5
+ message EnvItem {
6
+ optional int32 id = 1;
7
+ optional string name = 2;
8
+ optional string value = 3;
9
+ optional string remarks = 4;
10
+ optional int32 status = 5;
11
+ optional int64 position = 6;
12
+ }
13
+
14
+ message GetEnvsRequest { string searchValue = 1; }
15
+
16
+ message CreateEnvRequest { repeated EnvItem envs = 1; }
17
+
18
+ message UpdateEnvRequest { EnvItem env = 1; }
19
+
20
+ message DeleteEnvsRequest { repeated int32 ids = 1; }
21
+
22
+ message MoveEnvRequest {
23
+ int32 id = 1;
24
+ int32 fromIndex = 2;
25
+ int32 toIndex = 3;
26
+ }
27
+
28
+ message DisableEnvsRequest { repeated int32 ids = 1; }
29
+
30
+ message EnableEnvsRequest { repeated int32 ids = 1; }
31
+
32
+ message UpdateEnvNamesRequest {
33
+ repeated int32 ids = 1;
34
+ string name = 2;
35
+ }
36
+
37
+ message GetEnvByIdRequest { int32 id = 1; }
38
+
39
+ message EnvsResponse {
40
+ int32 code = 1;
41
+ repeated EnvItem data = 2;
42
+ optional string message = 3;
43
+ }
44
+
45
+ message EnvResponse {
46
+ int32 code = 1;
47
+ EnvItem data = 2;
48
+ optional string message = 3;
49
+ }
50
+
51
+ message Response {
52
+ int32 code = 1;
53
+ optional string message = 2;
54
+ }
55
+
56
+ message SystemNotifyRequest {
57
+ string title = 1;
58
+ string content = 2;
59
+ }
60
+
61
+ message ExtraScheduleItem {
62
+ string schedule = 1;
63
+ }
64
+
65
+ message CronItem {
66
+ optional int32 id = 1;
67
+ optional string command = 2;
68
+ optional string schedule = 3;
69
+ optional string name = 4;
70
+ repeated string labels = 5;
71
+ optional int32 sub_id = 6;
72
+ repeated ExtraScheduleItem extra_schedules = 7;
73
+ optional string task_before = 8;
74
+ optional string task_after = 9;
75
+ optional int32 status = 10;
76
+ optional string log_path = 11;
77
+ optional int32 pid = 12;
78
+ optional int64 last_running_time = 13;
79
+ optional int64 last_execution_time = 14;
80
+ }
81
+
82
+ message CreateCronRequest {
83
+ string command = 1;
84
+ string schedule = 2;
85
+ optional string name = 3;
86
+ repeated string labels = 4;
87
+ optional int32 sub_id = 5;
88
+ repeated ExtraScheduleItem extra_schedules = 6;
89
+ optional string task_before = 7;
90
+ optional string task_after = 8;
91
+ }
92
+
93
+ message UpdateCronRequest {
94
+ int32 id = 1;
95
+ optional string command = 2;
96
+ optional string schedule = 3;
97
+ optional string name = 4;
98
+ repeated string labels = 5;
99
+ optional int32 sub_id = 6;
100
+ repeated ExtraScheduleItem extra_schedules = 7;
101
+ optional string task_before = 8;
102
+ optional string task_after = 9;
103
+ }
104
+
105
+ message DeleteCronsRequest { repeated int32 ids = 1; }
106
+
107
+ message CronsResponse {
108
+ int32 code = 1;
109
+ repeated CronItem data = 2;
110
+ optional string message = 3;
111
+ }
112
+
113
+ message CronResponse {
114
+ int32 code = 1;
115
+ CronItem data = 2;
116
+ optional string message = 3;
117
+ }
118
+
119
+ message CronDetailRequest { string log_path = 1; }
120
+
121
+ message CronDetailResponse {
122
+ int32 code = 1;
123
+ CronItem data = 2;
124
+ optional string message = 3;
125
+ }
126
+
127
+ service Api {
128
+ rpc GetEnvs(GetEnvsRequest) returns (EnvsResponse) {}
129
+ rpc CreateEnv(CreateEnvRequest) returns (EnvsResponse) {}
130
+ rpc UpdateEnv(UpdateEnvRequest) returns (EnvResponse) {}
131
+ rpc DeleteEnvs(DeleteEnvsRequest) returns (Response) {}
132
+ rpc MoveEnv(MoveEnvRequest) returns (EnvResponse) {}
133
+ rpc DisableEnvs(DisableEnvsRequest) returns (Response) {}
134
+ rpc EnableEnvs(EnableEnvsRequest) returns (Response) {}
135
+ rpc UpdateEnvNames(UpdateEnvNamesRequest) returns (Response) {}
136
+ rpc GetEnvById(GetEnvByIdRequest) returns (EnvResponse) {}
137
+ rpc SystemNotify(SystemNotifyRequest) returns (Response) {}
138
+ rpc GetCronDetail(CronDetailRequest) returns (CronDetailResponse) {}
139
+ rpc CreateCron(CreateCronRequest) returns (CronResponse) {}
140
+ rpc UpdateCron(UpdateCronRequest) returns (CronResponse) {}
141
+ rpc DeleteCrons(DeleteCronsRequest) returns (Response) {}
142
+ }
@@ -0,0 +1,26 @@
1
+ syntax = "proto3";
2
+
3
+ package com.ql.cron;
4
+
5
+ service Cron {
6
+ rpc addCron(AddCronRequest) returns (AddCronResponse);
7
+ rpc delCron(DeleteCronRequest) returns (DeleteCronResponse);
8
+ }
9
+
10
+ message ISchedule { string schedule = 1; }
11
+
12
+ message ICron {
13
+ string id = 1;
14
+ string schedule = 2;
15
+ string command = 3;
16
+ repeated ISchedule extra_schedules = 4;
17
+ string name = 5;
18
+ }
19
+
20
+ message AddCronRequest { repeated ICron crons = 1; }
21
+
22
+ message AddCronResponse {}
23
+
24
+ message DeleteCronRequest { repeated string ids = 1; }
25
+
26
+ message DeleteCronResponse {}
@@ -0,0 +1,22 @@
1
+ syntax = "proto3";
2
+
3
+ package com.ql.health;
4
+
5
+ message HealthCheckRequest {
6
+ string service = 1;
7
+ }
8
+
9
+ message HealthCheckResponse {
10
+ enum ServingStatus {
11
+ UNKNOWN = 0;
12
+ SERVING = 1;
13
+ NOT_SERVING = 2;
14
+ SERVICE_UNKNOWN = 3;
15
+ }
16
+ ServingStatus status = 1;
17
+ }
18
+
19
+ service Health {
20
+ rpc Check(HealthCheckRequest) returns (HealthCheckResponse);
21
+ rpc Watch(HealthCheckRequest) returns (stream HealthCheckResponse);
22
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whyour/qinglong",
3
- "version": "2.19.0-5",
3
+ "version": "2.19.0-7",
4
4
  "description": "Timed task management platform supporting Python3, JavaScript, Shell, Typescript",
5
5
  "repository": {
6
6
  "type": "git",
package/shell/start.sh CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
- # 前置依赖 nodejs、npm
3
+ # 前置依赖 nodejs、npm、python3
4
4
  set -e
5
5
  set -x
6
6
 
@@ -68,6 +68,18 @@ fi
68
68
 
69
69
  npm install -g pnpm@8.3.1 pm2 ts-node
70
70
 
71
+ export PYTHON_SHORT_VERSION=$(python3 -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')
72
+ export PNPM_HOME=${QL_DIR}/data/dep_cache/node
73
+ export PYTHON_HOME=${QL_DIR}/data/dep_cache/python3
74
+ export PYTHONUSERBASE=${QL_DIR}/data/dep_cache/python3
75
+
76
+ export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PNPM_HOME}:${PYTHON_HOME}/bin
77
+ export NODE_PATH=/usr/local/bin:/usr/local/lib/node_modules:${PNPM_HOME}/global/5/node_modules
78
+ export PIP_CACHE_DIR=${PYTHON_HOME}/pip
79
+ export PYTHONPATH=${PYTHON_HOME}:${PYTHON_HOME}/lib/python${PYTHON_SHORT_VERSION}:${PYTHON_HOME}/lib/python${PYTHON_SHORT_VERSION}/site-packages
80
+
81
+ pip3 install --prefix ${PYTHON_HOME} requests
82
+
71
83
  cd ${QL_DIR}
72
84
  cp -f .env.example .env
73
85
  chmod 777 ${QL_DIR}/shell/*.sh
@@ -75,7 +87,15 @@ chmod 777 ${QL_DIR}/shell/*.sh
75
87
  . ${QL_DIR}/shell/share.sh
76
88
  . ${QL_DIR}/shell/env.sh
77
89
 
78
- echo -e "======================1. 检测配置文件========================\n"
90
+ log_with_style() {
91
+ local level="$1"
92
+ local message="$2"
93
+ local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
94
+
95
+ printf "\n[%s] [%7s] %s\n" "${timestamp}" "${level}" "${message}"
96
+ }
97
+
98
+ log_with_style "INFO" "🚀 1. 检测配置文件..."
79
99
  import_config "$@"
80
100
  make_dir /etc/nginx/conf.d
81
101
  make_dir /run/nginx
@@ -84,31 +104,23 @@ fix_config
84
104
 
85
105
  pm2 l &>/dev/null
86
106
 
87
- echo -e "======================2. 安装依赖========================\n"
88
- patch_version
89
-
90
- echo -e "======================3. 启动nginx========================\n"
107
+ log_with_style "INFO" "🔄 2. 启动 nginx..."
91
108
  nginx -s reload 2>/dev/null || nginx -c /etc/nginx/nginx.conf
92
- echo -e "nginx启动成功...\n"
93
109
 
94
- reload_update
110
+ log_with_style "INFO" "⚙️ 3. 启动 pm2 服务...\n"
95
111
  reload_pm2
96
112
 
97
113
  if [[ $AutoStartBot == true ]]; then
98
- echo -e "======================5. 启动bot========================\n"
114
+ log_with_style "INFO" "🤖 4. 启动 bot..."
99
115
  nohup ql bot >$dir_log/bot.log 2>&1 &
100
- echo -e "bot后台启动中...\n"
101
116
  fi
102
117
 
103
118
  if [[ $EnableExtraShell == true ]]; then
104
- echo -e "====================6. 执行自定义脚本========================\n"
119
+ log_with_style "INFO" "🛠️ 5. 执行自定义脚本..."
105
120
  nohup ql extra >$dir_log/extra.log 2>&1 &
106
- echo -e "自定义脚本后台执行中...\n"
107
121
  fi
108
122
 
109
123
  pm2 startup
110
124
  pm2 save
111
125
 
112
- echo -e "############################################################\n"
113
- echo -e "启动完成..."
114
- echo -e "############################################################\n"
126
+ log_with_style "SUCCESS" "🎉 容器启动成功!"