@whyour/qinglong 0.3.2 → 0.4.0
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/README-en.md +47 -88
- package/README.md +48 -87
- package/package.json +5 -1
- package/sample/notify.js +19 -9
- package/sample/notify.py +89 -47
- package/shell/api.sh +15 -15
- package/shell/otask.sh +1 -1
- package/shell/update.sh +12 -13
- package/static/build/api/system.js +1 -2
- package/static/build/api/user.js +5 -1
- package/static/build/config/serverEnv.js +1 -1
- package/static/build/data/dependence.js +1 -1
- package/static/build/data/notify.js +2 -0
- package/static/build/data/open.js +1 -8
- package/static/build/loaders/express.js +1 -9
- package/static/build/loaders/initFile.js +24 -6
- package/static/build/loaders/sentry.js +7 -1
- package/static/build/schedule/addCron.js +2 -2
- package/static/build/schedule/health.js +2 -2
- package/static/build/services/cron.js +50 -44
- package/static/build/services/dependence.js +82 -79
- package/static/build/services/env.js +1 -1
- package/static/build/services/notify.js +5 -5
- package/static/build/services/open.js +1 -1
- package/static/build/services/schedule.js +42 -40
- package/static/build/services/subscription.js +7 -13
- package/static/build/services/system.js +2 -2
- package/static/build/shared/pLimit.js +16 -0
- package/static/build/shared/runCron.js +29 -0
- package/static/dist/{1571.a97c18af.async.js → 1571.68121491.async.js} +3 -3
- package/static/dist/{9371.27629d57.async.js → 1654.e06fbac5.async.js} +1 -1
- package/static/dist/2260.d9fbd460.async.js +1 -0
- package/static/dist/2536.a60b8e3c.async.js +1 -0
- package/static/dist/{2618.2d258f44.async.js → 2618.1484edc2.async.js} +2 -2
- package/static/dist/2715.80e099e1.async.js +1 -0
- package/static/dist/{3490.8aaeafbb.async.js → 3490.8d2d9399.async.js} +1 -1
- package/static/dist/3639.58c3a3f1.async.js +5 -0
- package/static/dist/3800.5488ae14.async.js +2 -0
- package/static/dist/3820.faa46a6a.async.js +1 -0
- package/static/dist/4124.8cba8410.async.js +1 -0
- package/static/dist/4163.a1d279c3.async.js +1 -0
- package/static/dist/4346.5ab6fdc1.async.js +1 -0
- package/static/dist/{4378.70f18b85.async.js → 4378.70083a42.async.js} +2 -2
- package/static/dist/4491.96ee9a9f.async.js +4 -0
- package/static/dist/4804.183d71af.async.js +27 -0
- package/static/dist/4925.eca85085.async.js +1 -0
- package/static/dist/5008.c612bbdb.async.js +11 -0
- package/static/dist/5035.2489750b.async.js +67 -0
- package/static/dist/5310.6c4eff46.async.js +1 -0
- package/static/dist/5484.826c5ee3.async.js +1 -0
- package/static/dist/5969.87aeb075.async.js +1 -0
- package/static/dist/6304.51c52839.async.js +1 -0
- package/static/dist/6433.69941426.async.js +22 -0
- package/static/dist/6661.5cda5ce0.async.js +1 -0
- package/static/dist/6805.798ec30a.async.js +1 -0
- package/static/dist/{412.7e4d2d42.async.js → 7382.305c10b2.async.js} +2 -2
- package/static/dist/{7393.b7603b10.async.js → 7393.d9ed4b3a.async.js} +1 -1
- package/static/dist/7567.a224d0a6.async.js +5 -0
- package/static/dist/{7742.eec663d7.async.js → 7742.dd8a0112.async.js} +2 -2
- package/static/dist/8037.386b415d.async.js +1 -0
- package/static/dist/8297.e6ac1ce9.async.js +1 -0
- package/static/dist/8432.5bbc2cdd.async.js +1 -0
- package/static/dist/858.d51fc4e2.async.js +1 -0
- package/static/dist/8612.84caf0a5.async.js +1 -0
- package/static/dist/{8966.d92806db.async.js → 8657.805a96f7.async.js} +2 -2
- package/static/dist/8844.8525fd2e.async.js +81 -0
- package/static/dist/9065.6684b5d0.async.js +1 -0
- package/static/dist/921.198cefa6.async.js +6 -0
- package/static/dist/{9504.06cb7ea5.async.js → 9504.6d4e29e7.async.js} +1 -1
- package/static/dist/9673.18a70227.async.js +3 -0
- package/static/dist/986.ab6a48a4.async.js +1 -0
- package/static/dist/index.html +1 -1
- package/static/dist/layouts__index.285d8505.chunk.css +1 -0
- package/static/dist/layouts__index.3db43e0b.async.js +1 -0
- package/static/dist/src__pages__404.8794c158.async.js +1 -0
- package/static/dist/{src__pages__config__index.b5bde963.async.js → src__pages__config__index.7fb61af5.async.js} +3 -3
- package/static/dist/{src__pages__crontab__index.be4295e5.async.js → src__pages__crontab__index.5cfa7d5b.async.js} +2 -2
- package/static/dist/src__pages__crontab__logModal.44ad577c.async.js +2 -0
- package/static/dist/src__pages__crontab__modal.6d17fdcf.async.js +5 -0
- package/static/dist/src__pages__crontab__viewCreateModal.3db14204.async.js +4 -0
- package/static/dist/src__pages__crontab__viewManageModal.9f899650.async.js +4 -0
- package/static/dist/src__pages__dependence__index.3b140a79.async.js +2 -0
- package/static/dist/src__pages__dependence__logModal.e49658d5.async.js +4 -0
- package/static/dist/src__pages__dependence__modal.94ff002a.async.js +5 -0
- package/static/dist/{src__pages__diff__index.200be0dc.async.js → src__pages__diff__index.240e4991.async.js} +3 -3
- package/static/dist/{src__pages__env__editNameModal.9898b16a.async.js → src__pages__env__editNameModal.047bb3ba.async.js} +2 -2
- package/static/dist/src__pages__env__index.48602d18.async.js +2 -0
- package/static/dist/src__pages__env__modal.8b48ffa4.async.js +5 -0
- package/static/dist/src__pages__error__index.c0477141.async.js +4 -0
- package/static/dist/{src__pages__initialization__index.bcf87634.chunk.css → src__pages__initialization__index.66819338.chunk.css} +1 -1
- package/static/dist/src__pages__initialization__index.978a7f09.async.js +21 -0
- package/static/dist/src__pages__log__index.ae245070.async.js +1 -0
- package/static/dist/src__pages__login__index.8eb4df8e.async.js +2 -0
- package/static/dist/{src__pages__script__editModal.9a8934a1.async.js → src__pages__script__editModal.02b12902.async.js} +2 -2
- package/static/dist/{src__pages__script__editNameModal.42003a2f.async.js → src__pages__script__editNameModal.2773cb7b.async.js} +2 -2
- package/static/dist/{src__pages__script__index.670d9577.async.js → src__pages__script__index.679510cd.async.js} +3 -3
- package/static/dist/{src__pages__script__renameModal.3b9285b0.async.js → src__pages__script__renameModal.ea3b6689.async.js} +2 -2
- package/static/dist/{src__pages__script__saveModal.475c369d.async.js → src__pages__script__saveModal.312a0beb.async.js} +2 -2
- package/static/dist/{src__pages__script__setting.d41d33ae.async.js → src__pages__script__setting.11abc6ae.async.js} +2 -2
- package/static/dist/src__pages__setting__about.1460b7fa.async.js +1 -0
- package/static/dist/{src__pages__setting__appModal.4edca962.async.js → src__pages__setting__appModal.74267529.async.js} +2 -2
- package/static/dist/src__pages__setting__checkUpdate.ce2e30bb.async.js +4 -0
- package/static/dist/src__pages__setting__index.9fcd6dc2.async.js +2 -0
- package/static/dist/src__pages__setting__loginLog.0708083b.async.js +18 -0
- package/static/dist/src__pages__setting__notification.15a286d0.async.js +21 -0
- package/static/dist/src__pages__setting__other.00a69cf4.async.js +1 -0
- package/static/dist/src__pages__setting__security.62b6b562.async.js +4 -0
- package/static/dist/src__pages__subscription__index.708b6c8f.async.js +2 -0
- package/static/dist/src__pages__subscription__logModal.3a1a8e58.async.js +2 -0
- package/static/dist/src__pages__subscription__modal.c034f25a.async.js +4 -0
- package/static/dist/umi.cb44a99a.js +11 -0
- package/version.yaml +10 -5
- package/static/dist/1655.37556417.async.js +0 -4
- package/static/dist/1766.e0c12c07.async.js +0 -27
- package/static/dist/2260.04ae2823.async.js +0 -1
- package/static/dist/2715.30714799.async.js +0 -1
- package/static/dist/3639.62e1ddf6.async.js +0 -5
- package/static/dist/3820.ad340d47.async.js +0 -1
- package/static/dist/4011.3a02258a.async.js +0 -22
- package/static/dist/4124.6a5a1531.async.js +0 -1
- package/static/dist/4163.5180a456.async.js +0 -1
- package/static/dist/4180.e830b6e6.async.js +0 -2
- package/static/dist/4925.4425d963.async.js +0 -1
- package/static/dist/5008.8fcc2d24.async.js +0 -11
- package/static/dist/5310.9c3e0c09.async.js +0 -1
- package/static/dist/5319.dd84246e.async.js +0 -1
- package/static/dist/5484.ac83d6b4.async.js +0 -1
- package/static/dist/5544.6baaab99.async.js +0 -81
- package/static/dist/6304.613145ef.async.js +0 -1
- package/static/dist/6661.f5843bf4.async.js +0 -1
- package/static/dist/6794.4c503d6d.async.js +0 -5
- package/static/dist/6805.f5be6007.async.js +0 -1
- package/static/dist/7461.ed40fa5f.async.js +0 -1
- package/static/dist/7466.15597d4f.async.js +0 -1
- package/static/dist/7938.4e3377e7.async.js +0 -67
- package/static/dist/8037.61d0095e.async.js +0 -1
- package/static/dist/8297.3d6c376d.async.js +0 -1
- package/static/dist/8352.e0fbb494.async.js +0 -1
- package/static/dist/8432.30267db1.async.js +0 -1
- package/static/dist/8447.d0f63993.async.js +0 -1
- package/static/dist/9065.0806f3e5.async.js +0 -1
- package/static/dist/9280.aacaa172.async.js +0 -6
- package/static/dist/9673.a1545ea3.async.js +0 -3
- package/static/dist/986.c108246f.async.js +0 -1
- package/static/dist/layouts__index.3de47467.chunk.css +0 -1
- package/static/dist/layouts__index.a6451a2c.async.js +0 -1
- package/static/dist/src__pages__404.b5140a4b.async.js +0 -1
- package/static/dist/src__pages__crontab__logModal.0f6a4945.async.js +0 -2
- package/static/dist/src__pages__crontab__modal.cb176c70.async.js +0 -5
- package/static/dist/src__pages__crontab__viewCreateModal.f2b8a69a.async.js +0 -4
- package/static/dist/src__pages__crontab__viewManageModal.b86bbb79.async.js +0 -4
- package/static/dist/src__pages__dependence__index.c17201d7.async.js +0 -2
- package/static/dist/src__pages__dependence__logModal.42c56e18.async.js +0 -4
- package/static/dist/src__pages__dependence__modal.58620a62.async.js +0 -5
- package/static/dist/src__pages__env__index.c79218f4.async.js +0 -2
- package/static/dist/src__pages__env__modal.07f411f1.async.js +0 -5
- package/static/dist/src__pages__error__index.2f9d7c50.async.js +0 -4
- package/static/dist/src__pages__initialization__index.af82f7e1.async.js +0 -21
- package/static/dist/src__pages__log__index.5e63a6b7.async.js +0 -1
- package/static/dist/src__pages__login__index.44d624a7.async.js +0 -2
- package/static/dist/src__pages__setting__about.7ca2707b.async.js +0 -1
- package/static/dist/src__pages__setting__checkUpdate.dd497877.async.js +0 -4
- package/static/dist/src__pages__setting__index.4a85066e.async.js +0 -2
- package/static/dist/src__pages__setting__loginLog.c8ddd712.async.js +0 -18
- package/static/dist/src__pages__setting__notification.e124b7ae.async.js +0 -21
- package/static/dist/src__pages__setting__other.a58b5fae.async.js +0 -1
- package/static/dist/src__pages__setting__security.aabc2d21.async.js +0 -4
- package/static/dist/src__pages__subscription__index.04531731.async.js +0 -2
- package/static/dist/src__pages__subscription__logModal.b86a5c9b.async.js +0 -2
- package/static/dist/src__pages__subscription__modal.ea198f81.async.js +0 -4
- package/static/dist/umi.29bfaff2.js +0 -11
- /package/static/dist/{8352.d2d0a2c7.chunk.css → 8612.d2d0a2c7.chunk.css} +0 -0
- /package/static/dist/{7394.59dcf306.chunk.css → 9439.59dcf306.chunk.css} +0 -0
package/sample/notify.py
CHANGED
|
@@ -76,6 +76,8 @@ push_config = {
|
|
|
76
76
|
'QMSG_KEY': '', # qmsg 酱的 QMSG_KEY
|
|
77
77
|
'QMSG_TYPE': '', # qmsg 酱的 QMSG_TYPE
|
|
78
78
|
|
|
79
|
+
'QYWX_ORIGIN': '', # 企业微信代理地址
|
|
80
|
+
|
|
79
81
|
'QYWX_AM': '', # 企业微信应用
|
|
80
82
|
|
|
81
83
|
'QYWX_KEY': '', # 企业微信机器人
|
|
@@ -164,8 +166,7 @@ def dingding_bot(title: str, content: str) -> None:
|
|
|
164
166
|
|
|
165
167
|
timestamp = str(round(time.time() * 1000))
|
|
166
168
|
secret_enc = push_config.get("DD_BOT_SECRET").encode("utf-8")
|
|
167
|
-
string_to_sign = "{}\n{}".format(
|
|
168
|
-
timestamp, push_config.get("DD_BOT_SECRET"))
|
|
169
|
+
string_to_sign = "{}\n{}".format(timestamp, push_config.get("DD_BOT_SECRET"))
|
|
169
170
|
string_to_sign_enc = string_to_sign.encode("utf-8")
|
|
170
171
|
hmac_code = hmac.new(
|
|
171
172
|
secret_enc, string_to_sign_enc, digestmod=hashlib.sha256
|
|
@@ -231,8 +232,11 @@ def gotify(title: str, content: str) -> None:
|
|
|
231
232
|
print("gotify 服务启动")
|
|
232
233
|
|
|
233
234
|
url = f'{push_config.get("GOTIFY_URL")}/message?token={push_config.get("GOTIFY_TOKEN")}'
|
|
234
|
-
data = {
|
|
235
|
-
|
|
235
|
+
data = {
|
|
236
|
+
"title": title,
|
|
237
|
+
"message": content,
|
|
238
|
+
"priority": push_config.get("GOTIFY_PRIORITY"),
|
|
239
|
+
}
|
|
236
240
|
response = requests.post(url, data=data).json()
|
|
237
241
|
|
|
238
242
|
if response.get("id"):
|
|
@@ -291,9 +295,13 @@ def pushdeer(title: str, content: str) -> None:
|
|
|
291
295
|
print("PushDeer 服务的 DEER_KEY 未设置!!\n取消推送")
|
|
292
296
|
return
|
|
293
297
|
print("PushDeer 服务启动")
|
|
294
|
-
data = {
|
|
295
|
-
|
|
296
|
-
|
|
298
|
+
data = {
|
|
299
|
+
"text": title,
|
|
300
|
+
"desp": content,
|
|
301
|
+
"type": "markdown",
|
|
302
|
+
"pushkey": push_config.get("DEER_KEY"),
|
|
303
|
+
}
|
|
304
|
+
url = "https://api2.pushdeer.com/message/push"
|
|
297
305
|
if push_config.get("DEER_URL"):
|
|
298
306
|
url = push_config.get("DEER_URL")
|
|
299
307
|
|
|
@@ -313,7 +321,7 @@ def chat(title: str, content: str) -> None:
|
|
|
313
321
|
print("chat 服务的 CHAT_URL或CHAT_TOKEN 未设置!!\n取消推送")
|
|
314
322
|
return
|
|
315
323
|
print("chat 服务启动")
|
|
316
|
-
data =
|
|
324
|
+
data = "payload=" + json.dumps({"text": title + "\n" + content})
|
|
317
325
|
url = push_config.get("CHAT_URL") + push_config.get("CHAT_TOKEN")
|
|
318
326
|
response = requests.post(url, data=data)
|
|
319
327
|
|
|
@@ -347,11 +355,9 @@ def pushplus_bot(title: str, content: str) -> None:
|
|
|
347
355
|
print("PUSHPLUS 推送成功!")
|
|
348
356
|
|
|
349
357
|
else:
|
|
350
|
-
|
|
351
358
|
url_old = "http://pushplus.hxtrip.com/send"
|
|
352
359
|
headers["Accept"] = "application/json"
|
|
353
|
-
response = requests.post(
|
|
354
|
-
url=url_old, data=body, headers=headers).json()
|
|
360
|
+
response = requests.post(url=url_old, data=body, headers=headers).json()
|
|
355
361
|
|
|
356
362
|
if response["code"] == 200:
|
|
357
363
|
print("PUSHPLUS(hxtrip) 推送成功!")
|
|
@@ -370,8 +376,7 @@ def qmsg_bot(title: str, content: str) -> None:
|
|
|
370
376
|
print("qmsg 服务启动")
|
|
371
377
|
|
|
372
378
|
url = f'https://qmsg.zendee.cn/{push_config.get("QMSG_TYPE")}/{push_config.get("QMSG_KEY")}'
|
|
373
|
-
payload = {
|
|
374
|
-
"msg": f'{title}\n\n{content.replace("----", "-")}'.encode("utf-8")}
|
|
379
|
+
payload = {"msg": f'{title}\n\n{content.replace("----", "-")}'.encode("utf-8")}
|
|
375
380
|
response = requests.post(url=url, params=payload).json()
|
|
376
381
|
|
|
377
382
|
if response["code"] == 0:
|
|
@@ -420,9 +425,12 @@ class WeCom:
|
|
|
420
425
|
self.CORPID = corpid
|
|
421
426
|
self.CORPSECRET = corpsecret
|
|
422
427
|
self.AGENTID = agentid
|
|
428
|
+
self.ORIGIN = "https://qyapi.weixin.qq.com"
|
|
429
|
+
if push_config.get("QYWX_ORIGIN"):
|
|
430
|
+
self.ORIGIN = push_config.get("QYWX_ORIGIN")
|
|
423
431
|
|
|
424
432
|
def get_access_token(self):
|
|
425
|
-
url = "
|
|
433
|
+
url = f"{self.ORIGIN}/cgi-bin/gettoken"
|
|
426
434
|
values = {
|
|
427
435
|
"corpid": self.CORPID,
|
|
428
436
|
"corpsecret": self.CORPSECRET,
|
|
@@ -432,10 +440,7 @@ class WeCom:
|
|
|
432
440
|
return data["access_token"]
|
|
433
441
|
|
|
434
442
|
def send_text(self, message, touser="@all"):
|
|
435
|
-
send_url = (
|
|
436
|
-
"https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token="
|
|
437
|
-
+ self.get_access_token()
|
|
438
|
-
)
|
|
443
|
+
send_url = f"{self.ORIGIN}/cgi-bin/message/send?access_token={self.get_access_token()}"
|
|
439
444
|
send_values = {
|
|
440
445
|
"touser": touser,
|
|
441
446
|
"msgtype": "text",
|
|
@@ -449,10 +454,7 @@ class WeCom:
|
|
|
449
454
|
return respone["errmsg"]
|
|
450
455
|
|
|
451
456
|
def send_mpnews(self, title, message, media_id, touser="@all"):
|
|
452
|
-
send_url = (
|
|
453
|
-
"https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token="
|
|
454
|
-
+ self.get_access_token()
|
|
455
|
-
)
|
|
457
|
+
send_url = f"https://{self.HOST}/cgi-bin/message/send?access_token={self.get_access_token()}"
|
|
456
458
|
send_values = {
|
|
457
459
|
"touser": touser,
|
|
458
460
|
"msgtype": "mpnews",
|
|
@@ -485,7 +487,11 @@ def wecom_bot(title: str, content: str) -> None:
|
|
|
485
487
|
return
|
|
486
488
|
print("企业微信机器人服务启动")
|
|
487
489
|
|
|
488
|
-
|
|
490
|
+
origin = "https://qyapi.weixin.qq.com"
|
|
491
|
+
if push_config.get("QYWX_ORIGIN"):
|
|
492
|
+
origin = push_config.get("QYWX_ORIGIN")
|
|
493
|
+
|
|
494
|
+
url = f"{origin}/cgi-bin/webhook/send?key={push_config.get('QYWX_KEY')}"
|
|
489
495
|
headers = {"Content-Type": "application/json;charset=utf-8"}
|
|
490
496
|
data = {"msgtype": "text", "text": {"content": f"{title}\n\n{content}"}}
|
|
491
497
|
response = requests.post(
|
|
@@ -547,24 +553,28 @@ def aibotk(title: str, content: str) -> None:
|
|
|
547
553
|
"""
|
|
548
554
|
使用 智能微秘书 推送消息。
|
|
549
555
|
"""
|
|
550
|
-
if
|
|
556
|
+
if (
|
|
557
|
+
not push_config.get("AIBOTK_KEY")
|
|
558
|
+
or not push_config.get("AIBOTK_TYPE")
|
|
559
|
+
or not push_config.get("AIBOTK_NAME")
|
|
560
|
+
):
|
|
551
561
|
print("智能微秘书 的 AIBOTK_KEY 或者 AIBOTK_TYPE 或者 AIBOTK_NAME 未设置!!\n取消推送")
|
|
552
562
|
return
|
|
553
563
|
print("智能微秘书 服务启动")
|
|
554
564
|
|
|
555
|
-
if push_config.get("AIBOTK_TYPE") ==
|
|
565
|
+
if push_config.get("AIBOTK_TYPE") == "room":
|
|
556
566
|
url = "https://api-bot.aibotk.com/openapi/v1/chat/room"
|
|
557
567
|
data = {
|
|
558
568
|
"apiKey": push_config.get("AIBOTK_KEY"),
|
|
559
569
|
"roomName": push_config.get("AIBOTK_NAME"),
|
|
560
|
-
"message": {"type": 1, "content": f
|
|
570
|
+
"message": {"type": 1, "content": f"【青龙快讯】\n\n{title}\n{content}"},
|
|
561
571
|
}
|
|
562
572
|
else:
|
|
563
573
|
url = "https://api-bot.aibotk.com/openapi/v1/chat/contact"
|
|
564
574
|
data = {
|
|
565
575
|
"apiKey": push_config.get("AIBOTK_KEY"),
|
|
566
576
|
"name": push_config.get("AIBOTK_NAME"),
|
|
567
|
-
"message": {"type": 1, "content": f
|
|
577
|
+
"message": {"type": 1, "content": f"【青龙快讯】\n\n{title}\n{content}"},
|
|
568
578
|
}
|
|
569
579
|
body = json.dumps(data).encode(encoding="utf-8")
|
|
570
580
|
headers = {"Content-Type": "application/json"}
|
|
@@ -580,29 +590,52 @@ def smtp(title: str, content: str) -> None:
|
|
|
580
590
|
"""
|
|
581
591
|
使用 SMTP 邮件 推送消息。
|
|
582
592
|
"""
|
|
583
|
-
if
|
|
584
|
-
|
|
593
|
+
if (
|
|
594
|
+
not push_config.get("SMTP_SERVER")
|
|
595
|
+
or not push_config.get("SMTP_SSL")
|
|
596
|
+
or not push_config.get("SMTP_EMAIL")
|
|
597
|
+
or not push_config.get("SMTP_PASSWORD")
|
|
598
|
+
or not push_config.get("SMTP_NAME")
|
|
599
|
+
):
|
|
600
|
+
print(
|
|
601
|
+
"SMTP 邮件 的 SMTP_SERVER 或者 SMTP_SSL 或者 SMTP_EMAIL 或者 SMTP_PASSWORD 或者 SMTP_NAME 未设置!!\n取消推送"
|
|
602
|
+
)
|
|
585
603
|
return
|
|
586
604
|
print("SMTP 邮件 服务启动")
|
|
587
605
|
|
|
588
|
-
message = MIMEText(content,
|
|
589
|
-
message[
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
606
|
+
message = MIMEText(content, "plain", "utf-8")
|
|
607
|
+
message["From"] = formataddr(
|
|
608
|
+
(
|
|
609
|
+
Header(push_config.get("SMTP_NAME"), "utf-8").encode(),
|
|
610
|
+
push_config.get("SMTP_EMAIL"),
|
|
611
|
+
)
|
|
612
|
+
)
|
|
613
|
+
message["To"] = formataddr(
|
|
614
|
+
(
|
|
615
|
+
Header(push_config.get("SMTP_NAME"), "utf-8").encode(),
|
|
616
|
+
push_config.get("SMTP_EMAIL"),
|
|
617
|
+
)
|
|
618
|
+
)
|
|
619
|
+
message["Subject"] = Header(title, "utf-8")
|
|
594
620
|
|
|
595
621
|
try:
|
|
596
|
-
smtp_server =
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
622
|
+
smtp_server = (
|
|
623
|
+
smtplib.SMTP_SSL(push_config.get("SMTP_SERVER"))
|
|
624
|
+
if push_config.get("SMTP_SSL") == "true"
|
|
625
|
+
else smtplib.SMTP(push_config.get("SMTP_SERVER"))
|
|
626
|
+
)
|
|
627
|
+
smtp_server.login(
|
|
628
|
+
push_config.get("SMTP_EMAIL"), push_config.get("SMTP_PASSWORD")
|
|
629
|
+
)
|
|
630
|
+
smtp_server.sendmail(
|
|
631
|
+
push_config.get("SMTP_EMAIL"),
|
|
632
|
+
push_config.get("SMTP_EMAIL"),
|
|
633
|
+
message.as_bytes(),
|
|
634
|
+
)
|
|
602
635
|
smtp_server.close()
|
|
603
636
|
print("SMTP 邮件 推送成功!")
|
|
604
637
|
except Exception as e:
|
|
605
|
-
print(f
|
|
638
|
+
print(f"SMTP 邮件 推送失败!{e}")
|
|
606
639
|
|
|
607
640
|
|
|
608
641
|
def one() -> str:
|
|
@@ -645,9 +678,19 @@ if push_config.get("QYWX_KEY"):
|
|
|
645
678
|
notify_function.append(wecom_bot)
|
|
646
679
|
if push_config.get("TG_BOT_TOKEN") and push_config.get("TG_USER_ID"):
|
|
647
680
|
notify_function.append(telegram_bot)
|
|
648
|
-
if
|
|
681
|
+
if (
|
|
682
|
+
push_config.get("AIBOTK_KEY")
|
|
683
|
+
and push_config.get("AIBOTK_TYPE")
|
|
684
|
+
and push_config.get("AIBOTK_NAME")
|
|
685
|
+
):
|
|
649
686
|
notify_function.append(aibotk)
|
|
650
|
-
if
|
|
687
|
+
if (
|
|
688
|
+
push_config.get("SMTP_SERVER")
|
|
689
|
+
and push_config.get("SMTP_SSL")
|
|
690
|
+
and push_config.get("SMTP_EMAIL")
|
|
691
|
+
and push_config.get("SMTP_PASSWORD")
|
|
692
|
+
and push_config.get("SMTP_NAME")
|
|
693
|
+
):
|
|
651
694
|
notify_function.append(smtp)
|
|
652
695
|
|
|
653
696
|
|
|
@@ -659,7 +702,7 @@ def send(title: str, content: str) -> None:
|
|
|
659
702
|
# 根据标题跳过一些消息推送,环境变量:SKIP_PUSH_TITLE 用回车分隔
|
|
660
703
|
skipTitle = os.getenv("SKIP_PUSH_TITLE")
|
|
661
704
|
if skipTitle:
|
|
662
|
-
if
|
|
705
|
+
if title in re.split("\n", skipTitle):
|
|
663
706
|
print(f"{title} 在SKIP_PUSH_TITLE环境变量内,跳过推送!")
|
|
664
707
|
return
|
|
665
708
|
|
|
@@ -669,8 +712,7 @@ def send(title: str, content: str) -> None:
|
|
|
669
712
|
content += "\n\n" + text
|
|
670
713
|
|
|
671
714
|
ts = [
|
|
672
|
-
threading.Thread(target=mode, args=(
|
|
673
|
-
title, content), name=mode.__name__)
|
|
715
|
+
threading.Thread(target=mode, args=(title, content), name=mode.__name__)
|
|
674
716
|
for mode in notify_function
|
|
675
717
|
]
|
|
676
718
|
[t.start() for t in ts]
|
package/shell/api.sh
CHANGED
|
@@ -30,10 +30,10 @@ add_cron_api() {
|
|
|
30
30
|
local name=$(echo "$1" | awk -F ":" '{print $3}')
|
|
31
31
|
local sub_id=$(echo "$1" | awk -F ":" '{print $4}')
|
|
32
32
|
else
|
|
33
|
-
local schedule
|
|
34
|
-
local command
|
|
35
|
-
local name
|
|
36
|
-
local sub_id
|
|
33
|
+
local schedule="$1"
|
|
34
|
+
local command="$2"
|
|
35
|
+
local name="$3"
|
|
36
|
+
local sub_id="$4"
|
|
37
37
|
fi
|
|
38
38
|
|
|
39
39
|
if [[ ! $sub_id ]];then
|
|
@@ -69,10 +69,10 @@ update_cron_api() {
|
|
|
69
69
|
local name=$(echo "$1" | awk -F ":" '{print $3}')
|
|
70
70
|
local id=$(echo "$1" | awk -F ":" '{print $4}')
|
|
71
71
|
else
|
|
72
|
-
local schedule
|
|
73
|
-
local command
|
|
74
|
-
local name
|
|
75
|
-
local id
|
|
72
|
+
local schedule="$1"
|
|
73
|
+
local command="$2"
|
|
74
|
+
local name="$3"
|
|
75
|
+
local id="$4"
|
|
76
76
|
fi
|
|
77
77
|
|
|
78
78
|
local api=$(
|
|
@@ -103,8 +103,8 @@ update_cron_command_api() {
|
|
|
103
103
|
local command=$(echo "$1" | awk -F ":" '{print $1}')
|
|
104
104
|
local id=$(echo "$1" | awk -F ":" '{print $2}')
|
|
105
105
|
else
|
|
106
|
-
local command
|
|
107
|
-
local id
|
|
106
|
+
local command="$1"
|
|
107
|
+
local id="$2"
|
|
108
108
|
fi
|
|
109
109
|
|
|
110
110
|
local api=$(
|
|
@@ -130,7 +130,7 @@ update_cron_command_api() {
|
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
del_cron_api() {
|
|
133
|
-
local ids
|
|
133
|
+
local ids="$1"
|
|
134
134
|
local currentTimeStamp=$(date +%s)
|
|
135
135
|
local api=$(
|
|
136
136
|
curl -s --noproxy "*" "http://0.0.0.0:5600/open/crons?t=$currentTimeStamp" \
|
|
@@ -183,8 +183,8 @@ update_cron() {
|
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
notify_api() {
|
|
186
|
-
local title
|
|
187
|
-
local content
|
|
186
|
+
local title="$1"
|
|
187
|
+
local content="$2"
|
|
188
188
|
local currentTimeStamp=$(date +%s)
|
|
189
189
|
local api=$(
|
|
190
190
|
curl -s --noproxy "*" "http://0.0.0.0:5600/open/system/notify?t=$currentTimeStamp" \
|
|
@@ -202,14 +202,14 @@ notify_api() {
|
|
|
202
202
|
code=$(echo "$api" | jq -r .code)
|
|
203
203
|
message=$(echo "$api" | jq -r .message)
|
|
204
204
|
if [[ $code == 200 ]]; then
|
|
205
|
-
echo -e "
|
|
205
|
+
echo -e "通知发送成功🎉"
|
|
206
206
|
else
|
|
207
207
|
echo -e "通知失败(${message})"
|
|
208
208
|
fi
|
|
209
209
|
}
|
|
210
210
|
|
|
211
211
|
find_cron_api() {
|
|
212
|
-
local params
|
|
212
|
+
local params="$1"
|
|
213
213
|
local currentTimeStamp=$(date +%s)
|
|
214
214
|
local api=$(
|
|
215
215
|
curl -s --noproxy "*" "http://0.0.0.0:5600/open/crons/detail?$params&t=$currentTimeStamp" \
|
package/shell/otask.sh
CHANGED
|
@@ -38,7 +38,7 @@ gen_array_scripts() {
|
|
|
38
38
|
if [[ -f $file ]] && [[ $file == *.js && $file != sendNotify.js ]]; then
|
|
39
39
|
let i++
|
|
40
40
|
array_scripts[i]=$(echo "$file" | perl -pe "s|$dir_scripts/||g")
|
|
41
|
-
array_scripts_name[i]=$(grep "new Env" $file | awk -F "'
|
|
41
|
+
array_scripts_name[i]=$(grep "new Env" $file | awk -F "\(" '{print $2}' | awk -F "\)" '{print $1}' | sed 's:.*\('\''\|"\)\([^"'\'']*\)\('\''\|"\).*:\2:' | sed 's:"::g' | sed "s:'::g" | head -1)
|
|
42
42
|
[[ -z ${array_scripts_name[i]} ]] && array_scripts_name[i]="<未识别出活动名称>"
|
|
43
43
|
fi
|
|
44
44
|
done
|
package/shell/update.sh
CHANGED
|
@@ -31,7 +31,7 @@ output_list_add_drop() {
|
|
|
31
31
|
local list=$1
|
|
32
32
|
local type=$2
|
|
33
33
|
if [[ -s $list ]]; then
|
|
34
|
-
echo -e "检测到有$type的定时任务:\n"
|
|
34
|
+
echo -e "检测到有${type}的定时任务:\n"
|
|
35
35
|
cat $list
|
|
36
36
|
echo
|
|
37
37
|
fi
|
|
@@ -44,7 +44,7 @@ del_cron() {
|
|
|
44
44
|
local path=$2
|
|
45
45
|
local detail=""
|
|
46
46
|
local ids=""
|
|
47
|
-
echo -e "
|
|
47
|
+
echo -e "开始尝试自动删除失效的定时任务..."
|
|
48
48
|
for cron in $(cat $list_drop); do
|
|
49
49
|
local id=$(cat $list_crontab_user | grep -E "$cmd_task.* $cron" | perl -pe "s|.*ID=(.*) $cmd_task.* $cron\.*|\1|" | head -1 | awk -F " " '{print $1}')
|
|
50
50
|
if [[ $ids ]]; then
|
|
@@ -54,7 +54,7 @@ del_cron() {
|
|
|
54
54
|
fi
|
|
55
55
|
cron_file="$dir_scripts/${cron}"
|
|
56
56
|
if [[ -f $cron_file ]]; then
|
|
57
|
-
cron_name=$(grep "new Env" $cron_file | awk -F "\(" '{print $2}' | awk -F "\)" '{print $1}' | sed 's
|
|
57
|
+
cron_name=$(grep "new Env" $cron_file | awk -F "\(" '{print $2}' | awk -F "\)" '{print $1}' | sed 's:.*\('\''\|"\)\([^"'\'']*\)\('\''\|"\).*:\2:' | sed 's:"::g' | sed "s:'::g" | head -1)
|
|
58
58
|
rm -f $cron_file
|
|
59
59
|
fi
|
|
60
60
|
[[ -z $cron_name ]] && cron_name="$cron"
|
|
@@ -75,7 +75,7 @@ del_cron() {
|
|
|
75
75
|
add_cron() {
|
|
76
76
|
local list_add=$1
|
|
77
77
|
local path=$2
|
|
78
|
-
echo -e "
|
|
78
|
+
echo -e "开始尝试自动添加定时任务..."
|
|
79
79
|
local detail=""
|
|
80
80
|
cd $dir_scripts
|
|
81
81
|
for file in $(cat $list_add); do
|
|
@@ -92,7 +92,7 @@ add_cron() {
|
|
|
92
92
|
s| | |g;
|
|
93
93
|
}" | sort -u | head -1
|
|
94
94
|
)
|
|
95
|
-
cron_name=$(grep "new Env" $file | awk -F "\(" '{print $2}' | awk -F "\)" '{print $1}' | sed 's
|
|
95
|
+
cron_name=$(grep "new Env" $file | awk -F "\(" '{print $2}' | awk -F "\)" '{print $1}' | sed 's:.*\('\''\|"\)\([^"'\'']*\)\('\''\|"\).*:\2:' | sed 's:"::g' | sed "s:'::g" | head -1)
|
|
96
96
|
[[ -z $cron_name ]] && cron_name="$file_name"
|
|
97
97
|
[[ -z $cron_line ]] && cron_line=$(grep "cron:" $file | awk -F ":" '{print $2}' | head -1 | xargs)
|
|
98
98
|
[[ -z $cron_line ]] && cron_line=$(grep "cron " $file | awk -F "cron \"" '{print $2}' | awk -F "\" " '{print $1}' | head -1 | xargs)
|
|
@@ -193,7 +193,7 @@ update_raw() {
|
|
|
193
193
|
s| | |g;
|
|
194
194
|
}" | sort -u | head -1
|
|
195
195
|
)
|
|
196
|
-
cron_name=$(grep "new Env" $raw_file_name | awk -F "\(" '{print $2}' | awk -F "\)" '{print $1}' | sed 's
|
|
196
|
+
cron_name=$(grep "new Env" $raw_file_name | awk -F "\(" '{print $2}' | awk -F "\)" '{print $1}' | sed 's:.*\('\''\|"\)\([^"'\'']*\)\('\''\|"\).*:\2:' | sed 's:"::g' | sed "s:'::g" | head -1)
|
|
197
197
|
[[ -z $cron_name ]] && cron_name="$raw_file_name"
|
|
198
198
|
[[ -z $cron_line ]] && cron_line=$(grep "cron:" $raw_file_name | awk -F ":" '{print $2}' | head -1 | xargs)
|
|
199
199
|
[[ -z $cron_line ]] && cron_line=$(grep "cron " $raw_file_name | awk -F "cron \"" '{print $2}' | awk -F "\" " '{print $1}' | head -1 | xargs)
|
|
@@ -243,10 +243,9 @@ update_qinglong() {
|
|
|
243
243
|
echo -e "使用 ${mirror} 源更新...\n"
|
|
244
244
|
export isFirstStartServer=false
|
|
245
245
|
|
|
246
|
-
local all_branch=$(cd ${dir_root} && git branch -a)
|
|
247
246
|
local primary_branch="master"
|
|
248
|
-
if [[ "${
|
|
249
|
-
primary_branch="
|
|
247
|
+
if [[ "${QL_BRANCH}" == "develop" ]]; then
|
|
248
|
+
primary_branch="develop"
|
|
250
249
|
fi
|
|
251
250
|
[[ -f $dir_root/package.json ]] && ql_depend_old=$(cat $dir_root/package.json)
|
|
252
251
|
reset_romote_url ${dir_root} "https://${mirror}.com/whyour/qinglong.git" ${primary_branch}
|
|
@@ -364,10 +363,10 @@ gen_list_repo() {
|
|
|
364
363
|
done
|
|
365
364
|
files=$(eval $cmd | sed 's/^..//')
|
|
366
365
|
if [[ $path ]]; then
|
|
367
|
-
files=$(echo "$files" | egrep $path)
|
|
366
|
+
files=$(echo "$files" | egrep "$path")
|
|
368
367
|
fi
|
|
369
368
|
if [[ $blackword ]]; then
|
|
370
|
-
files=$(echo "$files" | egrep -v $blackword)
|
|
369
|
+
files=$(echo "$files" | egrep -v "$blackword")
|
|
371
370
|
fi
|
|
372
371
|
|
|
373
372
|
cp -f $file_notify_js "${dir_scripts}/${uniq_path}"
|
|
@@ -375,7 +374,7 @@ gen_list_repo() {
|
|
|
375
374
|
|
|
376
375
|
if [[ $dependence ]]; then
|
|
377
376
|
cd ${repo_path}
|
|
378
|
-
results=$(eval $cmd | sed 's/^..//' | egrep $dependence)
|
|
377
|
+
results=$(eval $cmd | sed 's/^..//' | egrep "$dependence")
|
|
379
378
|
for _file in ${results}; do
|
|
380
379
|
file_path=$(dirname $_file)
|
|
381
380
|
make_dir "${dir_scripts}/${uniq_path}/${file_path}"
|
|
@@ -388,7 +387,7 @@ gen_list_repo() {
|
|
|
388
387
|
fi
|
|
389
388
|
|
|
390
389
|
for file in ${files}; do
|
|
391
|
-
filename=$(basename $file)
|
|
390
|
+
filename=$(basename "$file")
|
|
392
391
|
cp -f $file "$dir_scripts/${uniq_path}/${filename}"
|
|
393
392
|
echo "${uniq_path}/${filename}" >>"$dir_list_tmp/${uniq_path}_scripts.list"
|
|
394
393
|
# cron_id=$(cat $list_crontab_user | grep -E "$cmd_task.* ${uniq_path}_${filename}" | perl -pe "s|.*ID=(.*) $cmd_task.* ${uniq_path}_${filename}\.*|\1|" | head -1 | awk -F " " '{print $1}')
|
|
@@ -52,8 +52,7 @@ exports.default = (app) => {
|
|
|
52
52
|
let isInitialized = true;
|
|
53
53
|
if (Object.keys(authInfo).length === 2 &&
|
|
54
54
|
authInfo.username === 'admin' &&
|
|
55
|
-
authInfo.password === 'admin'
|
|
56
|
-
envCount === 0) {
|
|
55
|
+
authInfo.password === 'admin') {
|
|
57
56
|
isInitialized = false;
|
|
58
57
|
}
|
|
59
58
|
res.send({
|
package/static/build/api/user.js
CHANGED
|
@@ -10,6 +10,7 @@ const celebrate_1 = require("celebrate");
|
|
|
10
10
|
const multer_1 = __importDefault(require("multer"));
|
|
11
11
|
const path_1 = __importDefault(require("path"));
|
|
12
12
|
const uuid_1 = require("uuid");
|
|
13
|
+
const express_rate_limit_1 = __importDefault(require("express-rate-limit"));
|
|
13
14
|
const config_1 = __importDefault(require("../config"));
|
|
14
15
|
const route = (0, express_1.Router)();
|
|
15
16
|
const storage = multer_1.default.diskStorage({
|
|
@@ -25,7 +26,10 @@ const storage = multer_1.default.diskStorage({
|
|
|
25
26
|
const upload = (0, multer_1.default)({ storage: storage });
|
|
26
27
|
exports.default = (app) => {
|
|
27
28
|
app.use('/user', route);
|
|
28
|
-
route.post('/login', (0,
|
|
29
|
+
route.post('/login', (0, express_rate_limit_1.default)({
|
|
30
|
+
windowMs: 15 * 60 * 1000,
|
|
31
|
+
max: 100,
|
|
32
|
+
}), (0, celebrate_1.celebrate)({
|
|
29
33
|
body: celebrate_1.Joi.object({
|
|
30
34
|
username: celebrate_1.Joi.string().required(),
|
|
31
35
|
password: celebrate_1.Joi.string().required(),
|
|
@@ -6,7 +6,7 @@ let pickedEnv;
|
|
|
6
6
|
function getPickedEnv() {
|
|
7
7
|
if (pickedEnv)
|
|
8
8
|
return pickedEnv;
|
|
9
|
-
const picked = (0, lodash_1.pick)(process.env, ['QlBaseUrl']);
|
|
9
|
+
const picked = (0, lodash_1.pick)(process.env, ['QlBaseUrl', 'DeployEnv']);
|
|
10
10
|
pickedEnv = picked;
|
|
11
11
|
return picked;
|
|
12
12
|
}
|
|
@@ -9,7 +9,7 @@ class Dependence {
|
|
|
9
9
|
this.status =
|
|
10
10
|
typeof options.status === 'number' && DependenceStatus[options.status]
|
|
11
11
|
? options.status
|
|
12
|
-
: DependenceStatus.
|
|
12
|
+
: DependenceStatus.queued;
|
|
13
13
|
this.type = options.type || DependenceTypes.nodejs;
|
|
14
14
|
this.timestamp = new Date().toString();
|
|
15
15
|
this.name = options.name;
|
|
@@ -97,6 +97,7 @@ class WeWorkBotNotification extends NotificationBaseInfo {
|
|
|
97
97
|
constructor() {
|
|
98
98
|
super(...arguments);
|
|
99
99
|
this.weWorkBotKey = '';
|
|
100
|
+
this.weWorkOrigin = '';
|
|
100
101
|
}
|
|
101
102
|
}
|
|
102
103
|
exports.WeWorkBotNotification = WeWorkBotNotification;
|
|
@@ -104,6 +105,7 @@ class WeWorkAppNotification extends NotificationBaseInfo {
|
|
|
104
105
|
constructor() {
|
|
105
106
|
super(...arguments);
|
|
106
107
|
this.weWorkAppKey = '';
|
|
108
|
+
this.weWorkOrigin = '';
|
|
107
109
|
}
|
|
108
110
|
}
|
|
109
111
|
exports.WeWorkAppNotification = WeWorkAppNotification;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AppModel = exports.
|
|
3
|
+
exports.AppModel = exports.App = void 0;
|
|
4
4
|
const _1 = require(".");
|
|
5
5
|
const sequelize_1 = require("sequelize");
|
|
6
6
|
class App {
|
|
@@ -13,13 +13,6 @@ class App {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
exports.App = App;
|
|
16
|
-
var CrontabStatus;
|
|
17
|
-
(function (CrontabStatus) {
|
|
18
|
-
CrontabStatus[CrontabStatus["running"] = 0] = "running";
|
|
19
|
-
CrontabStatus[CrontabStatus["idle"] = 1] = "idle";
|
|
20
|
-
CrontabStatus[CrontabStatus["disabled"] = 2] = "disabled";
|
|
21
|
-
CrontabStatus[CrontabStatus["queued"] = 3] = "queued";
|
|
22
|
-
})(CrontabStatus = exports.CrontabStatus || (exports.CrontabStatus = {}));
|
|
23
16
|
exports.AppModel = _1.sequelize.define('App', {
|
|
24
17
|
name: { type: sequelize_1.DataTypes.STRING, unique: 'name' },
|
|
25
18
|
scopes: sequelize_1.DataTypes.JSON,
|
|
@@ -117,8 +117,7 @@ exports.default = ({ app }) => {
|
|
|
117
117
|
let isInitialized = true;
|
|
118
118
|
if (Object.keys(authInfo).length === 2 &&
|
|
119
119
|
authInfo.username === 'admin' &&
|
|
120
|
-
authInfo.password === 'admin'
|
|
121
|
-
envCount === 0) {
|
|
120
|
+
authInfo.password === 'admin') {
|
|
122
121
|
isInitialized = false;
|
|
123
122
|
}
|
|
124
123
|
if (isInitialized) {
|
|
@@ -158,13 +157,6 @@ exports.default = ({ app }) => {
|
|
|
158
157
|
}
|
|
159
158
|
return next(err);
|
|
160
159
|
});
|
|
161
|
-
app.use(Sentry.Handlers.errorHandler({
|
|
162
|
-
shouldHandleError(error) {
|
|
163
|
-
// 排除 SequelizeUniqueConstraintError / NotFound
|
|
164
|
-
return (!['SequelizeUniqueConstraintError'].includes(error.name) ||
|
|
165
|
-
!['Not Found'].includes(error.message));
|
|
166
|
-
},
|
|
167
|
-
}));
|
|
168
160
|
app.use((err, req, res, next) => {
|
|
169
161
|
Sentry.captureException(err);
|
|
170
162
|
res.status(err.status || 500);
|
|
@@ -20,10 +20,15 @@ const logPath = path_1.default.join(dataPath, 'log/');
|
|
|
20
20
|
const uploadPath = path_1.default.join(dataPath, 'upload/');
|
|
21
21
|
const bakPath = path_1.default.join(dataPath, 'bak/');
|
|
22
22
|
const samplePath = path_1.default.join(rootPath, 'sample/');
|
|
23
|
+
const tmpPath = path_1.default.join(logPath, '.tmp/');
|
|
23
24
|
const confFile = path_1.default.join(configPath, 'config.sh');
|
|
24
25
|
const authConfigFile = path_1.default.join(configPath, 'auth.json');
|
|
25
26
|
const sampleConfigFile = path_1.default.join(samplePath, 'config.sample.sh');
|
|
26
27
|
const sampleAuthFile = path_1.default.join(samplePath, 'auth.sample.json');
|
|
28
|
+
const sampleNotifyJsFile = path_1.default.join(samplePath, 'notify.js');
|
|
29
|
+
const sampleNotifyPyFile = path_1.default.join(samplePath, 'notify.py');
|
|
30
|
+
const scriptNotifyJsFile = path_1.default.join(scriptPath, 'sendNotify.js');
|
|
31
|
+
const scriptNotifyPyFile = path_1.default.join(scriptPath, 'notify.py');
|
|
27
32
|
const homedir = os_1.default.homedir();
|
|
28
33
|
const sshPath = path_1.default.resolve(homedir, '.ssh');
|
|
29
34
|
const sshdPath = path_1.default.join(dataPath, 'ssh.d');
|
|
@@ -37,21 +42,21 @@ exports.default = async () => {
|
|
|
37
42
|
const sshDirExist = await (0, util_1.fileExist)(sshPath);
|
|
38
43
|
const bakDirExist = await (0, util_1.fileExist)(bakPath);
|
|
39
44
|
const sshdDirExist = await (0, util_1.fileExist)(sshdPath);
|
|
45
|
+
const tmpDirExist = await (0, util_1.fileExist)(tmpPath);
|
|
46
|
+
const scriptNotifyJsFileExist = await (0, util_1.fileExist)(scriptNotifyJsFile);
|
|
47
|
+
const scriptNotifyPyFileExist = await (0, util_1.fileExist)(scriptNotifyPyFile);
|
|
40
48
|
if (!configDirExist) {
|
|
41
49
|
fs_1.default.mkdirSync(configPath);
|
|
42
50
|
}
|
|
43
|
-
if (!authFileExist) {
|
|
44
|
-
fs_1.default.writeFileSync(authConfigFile, fs_1.default.readFileSync(sampleAuthFile));
|
|
45
|
-
}
|
|
46
|
-
if (!confFileExist) {
|
|
47
|
-
fs_1.default.writeFileSync(confFile, fs_1.default.readFileSync(sampleConfigFile));
|
|
48
|
-
}
|
|
49
51
|
if (!scriptDirExist) {
|
|
50
52
|
fs_1.default.mkdirSync(scriptPath);
|
|
51
53
|
}
|
|
52
54
|
if (!logDirExist) {
|
|
53
55
|
fs_1.default.mkdirSync(logPath);
|
|
54
56
|
}
|
|
57
|
+
if (!tmpDirExist) {
|
|
58
|
+
fs_1.default.mkdirSync(tmpPath);
|
|
59
|
+
}
|
|
55
60
|
if (!uploadDirExist) {
|
|
56
61
|
fs_1.default.mkdirSync(uploadPath);
|
|
57
62
|
}
|
|
@@ -64,6 +69,19 @@ exports.default = async () => {
|
|
|
64
69
|
if (!sshdDirExist) {
|
|
65
70
|
fs_1.default.mkdirSync(sshdPath);
|
|
66
71
|
}
|
|
72
|
+
// 初始化文件
|
|
73
|
+
if (!authFileExist) {
|
|
74
|
+
fs_1.default.writeFileSync(authConfigFile, fs_1.default.readFileSync(sampleAuthFile));
|
|
75
|
+
}
|
|
76
|
+
if (!confFileExist) {
|
|
77
|
+
fs_1.default.writeFileSync(confFile, fs_1.default.readFileSync(sampleConfigFile));
|
|
78
|
+
}
|
|
79
|
+
if (!scriptNotifyJsFileExist) {
|
|
80
|
+
fs_1.default.writeFileSync(scriptNotifyJsFile, fs_1.default.readFileSync(sampleNotifyJsFile));
|
|
81
|
+
}
|
|
82
|
+
if (!scriptNotifyPyFileExist) {
|
|
83
|
+
fs_1.default.writeFileSync(scriptNotifyPyFile, fs_1.default.readFileSync(sampleNotifyPyFile));
|
|
84
|
+
}
|
|
67
85
|
dotenv_1.default.config({ path: confFile });
|
|
68
86
|
logger_1.default.info('✌️ Init file down');
|
|
69
87
|
};
|
|
@@ -34,12 +34,18 @@ const util_1 = require("../config/util");
|
|
|
34
34
|
exports.default = async ({ expressApp }) => {
|
|
35
35
|
const { version } = await (0, util_1.parseVersion)(config_1.default.versionFile);
|
|
36
36
|
Sentry.init({
|
|
37
|
+
ignoreErrors: [
|
|
38
|
+
/SequelizeUniqueConstraintError/i,
|
|
39
|
+
/Validation error/i,
|
|
40
|
+
/UnauthorizedError/i,
|
|
41
|
+
/celebrate request validation failed/i,
|
|
42
|
+
],
|
|
37
43
|
dsn: 'https://f4b5b55fb3c645b29a5dc2d70a1a4ef4@o1098464.ingest.sentry.io/6122819',
|
|
38
44
|
integrations: [
|
|
39
45
|
new Sentry.Integrations.Http({ tracing: true }),
|
|
40
46
|
new Tracing.Integrations.Express({ app: expressApp }),
|
|
41
47
|
],
|
|
42
|
-
tracesSampleRate: 0.
|
|
48
|
+
tracesSampleRate: 0.8,
|
|
43
49
|
release: version,
|
|
44
50
|
});
|
|
45
51
|
expressApp.use(Sentry.Handlers.requestHandler());
|