Commit 38818e16 authored by qinhaitao's avatar qinhaitao

Merge branch 'c_server_ts_perf-phone' into 'c_server_ts_perf'

云告警增加phone

See merge request !46
parents a38f24a6 65818afe
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
"main": "index.js", "main": "index.js",
"title": "测试活动", "title": "测试活动",
"author": "duiba", "author": "duiba",
"phone": "13184232663",
"license": "ISC", "license": "ISC",
"sdkVersion": "*", "sdkVersion": "*",
"dependencies": { "dependencies": {
......
...@@ -4,8 +4,7 @@ const configPackage = require('../../../package.json') ...@@ -4,8 +4,7 @@ const configPackage = require('../../../package.json')
* @param message * @param message
*/ */
export const cloundAlarm = async (context: IContext<IParams>, message: string, stack: string) => { export const cloundAlarm = async (context: IContext<IParams>, message: string, stack: string) => {
console.warn(configPackage) const { title, author, phone } = configPackage
const { title, author } = configPackage
const envTxt = { const envTxt = {
'test': '测试环境', 'test': '测试环境',
'pre': '预发环境', 'pre': '预发环境',
...@@ -22,7 +21,8 @@ export const cloundAlarm = async (context: IContext<IParams>, message: string, s ...@@ -22,7 +21,8 @@ export const cloundAlarm = async (context: IContext<IParams>, message: string, s
}, },
"at": { "isAtAll": false, "atMobiles": [], "atUserIds": [] } "at": { "isAtAll": false, "atMobiles": [], "atUserIds": [] }
} }
const result = await context.cloud.httpApi.invoke( const result = await Promise.all([
context.cloud.httpApi.invoke(
{ {
'domain':'https://oapi.dingtalk.com', 'domain':'https://oapi.dingtalk.com',
'path': '/robot/send', 'path': '/robot/send',
...@@ -34,6 +34,24 @@ export const cloundAlarm = async (context: IContext<IParams>, message: string, s ...@@ -34,6 +34,24 @@ export const cloundAlarm = async (context: IContext<IParams>, message: string, s
'Content-Type':'application/json;charset=UTF-8', 'Content-Type':'application/json;charset=UTF-8',
}, },
'body': text 'body': text
}); }),
context.cloud.httpApi.invoke(
{
'domain':'https://oapi.dingtalk.com',
'path': '/robot/send',
'params': {
'access_token': 'f6d0d8ecdab3ad77dc51b5173f630f1c0e0fcbe90e994d0a642fb0b516dfd24c'
},
'method':'POST',
'headers': {
'Content-Type':'application/json;charset=UTF-8',
},
'body': {
"msgtype": "text",
"at": { "isAtAll": false, "atMobiles": [ phone ], "atUserIds": [] },
"text": { 'content': '云告警'}
}
})
])
return result return result
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment