部分优化
This commit is contained in:
parent
f4c7928fed
commit
16308b9303
@ -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
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user