# -*- coding: utf-8 -*- from demeter.core import * import json class Core(object): # 实时同步 def rsync(self, table, id): command = Demeter.path + 'sync.py -t ' + str(table) + ' -i ' + str(id) Shell.popen("python3 " + command, bg=True) #self.sync(table, {'id':id}) # 远程同步 def sync(self, table, search={}): farm = Demeter.service('common').list('farm', search={'eros_status':1}) state = True data = Demeter.service('common').list(table, state=state, search=search) if not data: state = False data = Demeter.service('common').list(table, state=state, search=search) param = {} param['data'] = json.dumps(data) param['table'] = table if farm and data: for v in farm: url = 'http://' + v['eros_server'] + ':8081/interface/sync' Demeter.curl(url, param, 'post')