예제 #1
0
 def __init__(self,
              command,
              timeout=300,
              db_name=None,
              db_function=None,
              kill_time=None):
     Daemon.__init__(self, timeout, kill_time)
     self.command = command
     self.db_name = db_name
     self.db_function = db_function
     self.is_first = True
예제 #2
0
    def __init__(self, username, password, timeout = 1, kill_time = None):
        Daemon.__init__(self, timeout, kill_time)

        self.user = username
        self.password = password

        #rv, mailboxes = conn.list()
        #if rv == 'OK':
        #    print "Mailboxes:"
        #    print mailboxes

        self.need_stop = False
예제 #3
0
    def __init__(self, username, password, timeout=1, kill_time=None):
        Daemon.__init__(self, timeout, kill_time)

        self.user = username
        self.password = password

        #rv, mailboxes = conn.list()
        #if rv == 'OK':
        #    print "Mailboxes:"
        #    print mailboxes

        self.need_stop = False
예제 #4
0
                    'castle_monster_exp_3': castle_monster_exp_3,
                    'attacker_monster_exp_1': attacker_monster_exp_1,
                    'attacker_monster_exp_2': attacker_monster_exp_2,
                    'attacker_monster_exp_3': attacker_monster_exp_3,
                })
            )
        except IntegrityError:
            log.warn('update_battle|re_update_id=%s', battle_id)
        battle_id += 1

    with open('cron_battle.log', 'w') as f:
        f.write(str(battle_id))


if __name__=="__main__":

    if web3 is None:
        web3 = Web3(HTTPProvider('http://localhost:8545'))
    if memcache is None:
        memcache = MemcacheClient(('localhost', 11211))

    def main():
        while True:
            try:
                update_battle()
            except Exception as e:
                log.error('cron_battle_error|error=%s,traceback=%s', e, traceback.format_exc())
            time.sleep(5)

    Daemon(main, 'cron_battle.pid', './cron_daemon_output.log').main()
    # main()
예제 #5
0
 def __init__(self, command, timeout=300, db_name=None, db_function=None, kill_time=None):
     Daemon.__init__(self, timeout, kill_time)
     self.command = command
     self.db_name = db_name
     self.db_function = db_function
     self.is_first = True
예제 #6
0
        attemptList = [i + j for j in xrange(0, min(step, total_borrow - i))]
        thread = Thread(target=addBorrow, args=(attemptList, ))
        thread.start()
        threads.append(thread)
    for thread in threads:
        thread.join()
    memcache_client.set('sell_list', json.dumps(monList))
    memcache_client.set('borrow_list', json.dumps(borrowList))

    with open('cron_market.log', 'a') as f:
        f.write("\n")
        f.write("Last update time: " + str(
            datetime.datetime.fromtimestamp(int(time.time())).strftime(
                '%Y-%m-%d %H:%M:%S')) + "\n")
        f.write("Block no: " + str(eth_block_no) + "\n")
        f.write("Total_sell: " + str(total) + "\n")
        f.write("Total_borrow: " + str(total_borrow) + "\n")
        f.write("Elasped: " + str(time.time() - start_time) + "\n")


if __name__ == "__main__":
    if memcache_client is None:
        memcache_client = MemcacheClient(('localhost', 11211))

    def main():
        while True:
            cache_market()

    from common.daemon import Daemon
    Daemon(main, 'cron_market.pid', './cron_daemon_output.log').main()
    # main()
예제 #7
0
        crontask.register_task("0 1 8 * * 2,6",
                               task=tournament.start_tournaments)

        #	crontask.register_task("*/50 * * * *", task=crawl_adventure_presale.crawl_adventure_presale)

        #	crontask.register_task("*/30 * * * *", task=crawl_egg.crawl_monster_egg_data)
        #crontask.register_task("*/20 * * * *", task=crawl_egg.fix_bonus_egg)
        #crontask.register_task("*/40 * * * *", task=crawl_egg.fix_egg_info)

        #crontask.register_task("*/50 * * * *", task=crawl_explore.cron_run_setting)

        crontask.register_task("0 0 1 * *", task=cal_txn.call)
        #crontask.register_task("*/70 * * * *", task=crawl_market_history.craw_market_seller)

        #crontask.register_task("*/50 * * * *", task=crawl_market.crawl_market)
        # crontask.register_task("0 59 7 * * 0,4", task=crawl_market.fix_borrow_problem)

        # crontask.register_task("*/50 * * * *", task=crawl_monster.crawl_monster)
        # crontask.register_task("0 59 7 * * 0,4", task=crawl_monster.fix_stats_monster)

        # crontask.register_task("*/20 * * * * *", task=crawl_rank_data.crawl_rank_data)
        # crontask.register_task("*/25 * * * * *", task=crawl_rank_data.re_craw_energy)
        # crontask.register_task("0 59 7 * * 0,4", task=crawl_rank_data.clone_player_data)

        crontask.run()

    from common.daemon import Daemon
    Daemon(main,
           os.path.abspath(__file__).replace(".py", ".pid"),
           "./log/service_daemon.log").main()
예제 #8
0
                base_stat_6=monster_stat[5],
                extra_data=json.dumps({}))
            if DEBUG: print "create", ": ", monster_id
            log.info('update_monster|created|monster_id=%s', monster_id)
        monster_id += 1


if __name__ == "__main__":

    if web3 is None:
        web3 = Web3(HTTPProvider('http://localhost:8545'))
    if memcache is None:
        memcache = MemcacheClient(('localhost', 11211))

    def main():
        while True:
            try:
                start = time.time()
                update_monster()
                if DEBUG: print "Elapsed: ", time.time() - start
            except Exception as e:
                if DEBUG: traceback.print_exc()
                log.error('cron_monster_error|error=%s,traceback=%s', e,
                          traceback.format_exc())
            time.sleep(5)

    if DEBUG:
        main()
    else:
        Daemon(main, 'cron_monster.pid', './cron_daemon_output.log').main()