From 16308b9303a451f82be74f130bbc24ebcd1ca912 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 24 Jan 2019 17:56:45 +0800 Subject: [PATCH] =?UTF-8?q?=E9=83=A8=E5=88=86=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/kefu_robot.json | 3 ++- tools/kefu_robot.py | 14 +++++++++----- webapp/controller/KefuController.class.php | 6 +++--- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/config/kefu_robot.json b/config/kefu_robot.json index e4c5a59..0a1ec90 100644 --- a/config/kefu_robot.json +++ b/config/kefu_robot.json @@ -2,5 +2,6 @@ "listen_port": 10001, "notify_url": "https://kefu-test.kingsome.cn/webapp/index.php?c=Kefu&a=sendMsgAllUser", "sendtime1": 32400, - "sendtime2": 64800 + "sendtime2": 64800, + "sendtime3": 0 } diff --git a/tools/kefu_robot.py b/tools/kefu_robot.py index 5512475..07771d6 100644 --- a/tools/kefu_robot.py +++ b/tools/kefu_robot.py @@ -25,12 +25,14 @@ def getDaySeconds(time_val, incdays): def sendNotify(conf, sendtime): try: - req = urllib.request.Request(conf['notify_url']) + url = conf['notify_url'] + req = urllib.request.Request(url) data = urllib.request.urlopen(req).readall() except: pass + #进入下一次循环 - tornado.ioloop.IOLoop.current().call_at(getDaySeconds(time.time(), 0) + sendtime, + tornado.ioloop.IOLoop.current().call_at(getDaySeconds(time.time(), 1) + sendtime, lambda : sendNotify(conf, sendtime)) class SelfCheckingHandler(tornado.web.RequestHandler): @@ -49,12 +51,14 @@ def make_app(): ]) if __name__ == "__main__": - conf = json.loads(open('config/kefu_robot.json', 'r').read()) + conf = json.loads(open('../config/kefu_robot.json', 'r').read()) app = make_app() app.listen(conf['listen_port']) - tornado.ioloop.IOLoop.current().call_at(getDaySeconds(time.time(), 0) + conf['sendtime1'], + tornado.ioloop.IOLoop.current().call_at(getDaySeconds(time.time(), 1) + conf['sendtime1'], lambda : sendNotify(conf, conf['sendtime1'])) - tornado.ioloop.IOLoop.current().call_at(getDaySeconds(time.time(), 0) + conf['sendtime2'], + tornado.ioloop.IOLoop.current().call_at(getDaySeconds(time.time(), 1) + conf['sendtime2'], lambda : sendNotify(conf, conf['sendtime2'])) + tornado.ioloop.IOLoop.current().call_at(time.time() + 3, + lambda : sendNotify(conf, 30)) tornado.ioloop.IOLoop.current().start() diff --git a/webapp/controller/KefuController.class.php b/webapp/controller/KefuController.class.php index 7bea2f3..84662c2 100644 --- a/webapp/controller/KefuController.class.php +++ b/webapp/controller/KefuController.class.php @@ -408,8 +408,8 @@ class KefuController { public function sendMsgAllUser() { - #error_log('sendMsgAllUser:'); - + error_log('sendMsgAllUser:'); + #error_log('request:' . json_encode($_REQUEST['xxx'])); $mysqls = $this->getAllMysql(); foreach($mysqls as $mysql_conf) { $conn = $this->getAppointMysql($mysql_conf); @@ -562,7 +562,7 @@ class KefuController { $r = $this->getRedis($accountid); $access_token = $r->get('kf_token:' . $accountid . ':'); - ##error_log('acc_token:' . $access_token); + #error_log('acc_token:' . $access_token); if (!empty($access_token)) { return $access_token; }