1
This commit is contained in:
parent
422a55fcd5
commit
39aec63518
@ -46,6 +46,37 @@ def fetchEventTimerFunc(refresh_time):
|
|||||||
lambda : fetchEventTimerFunc(refresh_time))
|
lambda : fetchEventTimerFunc(refresh_time))
|
||||||
f7.app.createAsyncTask(done_callback, fetchEvent, ())
|
f7.app.createAsyncTask(done_callback, fetchEvent, ())
|
||||||
|
|
||||||
|
def dailyMail():
|
||||||
|
mysql_cluster_conf = json.loads(open(CONFIG_DIR + '/mailsender.mysql.cluster.json', 'r').read())
|
||||||
|
for conf in mysql_cluster_conf:
|
||||||
|
conn = pymysql.connect(host = conf['host'],
|
||||||
|
port = conf['port'],
|
||||||
|
user = conf['user'],
|
||||||
|
passwd = conf['passwd'],
|
||||||
|
db = conf['dbname'],
|
||||||
|
charset = 'utf8'
|
||||||
|
)
|
||||||
|
cursor = conn.cursor()
|
||||||
|
last_idx = db_idx_hash.get(conf['instance_id'], 0)
|
||||||
|
while True:
|
||||||
|
cursor.execute('SELECT idx, sender_id, event_name, param1, param2 '
|
||||||
|
'FROM `event` '
|
||||||
|
'WHERE idx > %d AND status = 0 AND event_name = "vip_level_up" '
|
||||||
|
'LIMIT 0, 1000'
|
||||||
|
% (last_idx))
|
||||||
|
for row in cursor:
|
||||||
|
last_idx = max(row[0], last_idx)
|
||||||
|
time.sleep(0.001);
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
#end while
|
||||||
|
|
||||||
|
def dailyMailTimerFunc(refresh_time):
|
||||||
|
def done_callback():
|
||||||
|
f7.timer.callAt(refresh_time,
|
||||||
|
lambda : dailyMailTimerFunc(refresh_time))
|
||||||
|
f7.app.createAsyncTask(done_callback, dailyMail, ())
|
||||||
|
|
||||||
def getConf():
|
def getConf():
|
||||||
cluster_conf = json.loads(open(CONFIG_DIR + '/mailsender.cluster.json', 'r').read())
|
cluster_conf = json.loads(open(CONFIG_DIR + '/mailsender.cluster.json', 'r').read())
|
||||||
for conf in cluster_conf:
|
for conf in cluster_conf:
|
||||||
@ -67,6 +98,9 @@ if __name__ == "__main__":
|
|||||||
conf['refresh_time'] = 10
|
conf['refresh_time'] = 10
|
||||||
f7.timer.callLater(conf['refresh_time'],
|
f7.timer.callLater(conf['refresh_time'],
|
||||||
lambda : fetchEventTimerFunc(conf['refresh_time']))
|
lambda : fetchEventTimerFunc(conf['refresh_time']))
|
||||||
|
conf['daily_mail_sendtime'] = 10
|
||||||
|
f7.timer.callAt(conf['daily_mail_sendtime'],
|
||||||
|
lambda : dailyMailTimerFunc(conf['daily_mail_sendtime']))
|
||||||
|
|
||||||
f7.app.listen(conf['listen_port'])
|
f7.app.listen(conf['listen_port'])
|
||||||
f7.app.start()
|
f7.app.start()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user