time.sleep(600) # 10 minutes
        print "End TransactionAddrInfoUpdaterProcessDaemon"

def set_env_2():
    #2. Create logging dir
    if not os.path.exists(TX_ADDR_INFO_UPDATE_DAEMON_LOG_DIR):
        os.makedirs(TX_ADDR_INFO_UPDATE_DAEMON_LOG_DIR) 
        
if __name__ == '__main__':
    set_env_2()
    if len(sys.argv) == 3:
        env_setting = sys.argv[2]
        daemon = TransactionAddrInfoUpdaterProcessDaemon(pidfile=TX_ADDR_INFO_UPDATE_DAEMON_PID_FILE, 
                              stdout=TX_ADDR_INFO_UPDATE_DAEMON_STDOUT, 
                              stderr=TX_ADDR_INFO_UPDATE_DAEMON_STDERR)
        query_session = set_session(env_setting=env_setting)
        update_session = set_session(env_setting=env_setting)
        daemon.set_session(query_session = query_session, update_session = update_session)
        if 'start' == sys.argv[1]:
            print "start"
            daemon.start()
        elif 'stop' == sys.argv[1]:
            print "stop"
            daemon.stop()
        elif 'restart' == sys.argv[1]:
            print "restart"
            daemon.restart()
        else:
            print "Unknown command"
            sys.exit(2)
        sys.exit(0)
コード例 #2
0
        else:
            count = 1000
    except StandardError:
        print >> stderr, "wrong input arguments"
        print >> stderr, "usage: ./mainchain_update.py <local|prod> [count]"
        sys.exit(2)

    print "Set up environment to", env_setting
    if is_process_running():
        print "Process is already running. Skip this round"
        print "Program terminated normally"
        sys.exit()

    try:
        make_lock_file()
    except IOError as e:
        sys.exit("Can't open lock file")

    try:
        session = set_session(env_setting=env_setting)
        updater = MainchainUpdater(session=session,
                                   rpc_url=DEFAULT_LOCAL_BITCONID_RPC_URL)
        updater.run(count)
    except SignalSystemExit as e:
        pass
    finally:
        if os.path.exists(LOCK_FILE):
            remove_lock_file()

    print "Program terminated normally"
コード例 #3
0
ファイル: main.py プロジェクト: DMGJames/Bitcoin_listener
    except getopt.GetoptError:
        print 'main.py -n <nodefile> -e local|prod|test '
        sys.exit(2)
    for opt, arg in opts:
        if opt == '-h':
            print 'main.py -n <nodefile> -e local|prod|test'
            sys.exit()
        elif opt in ("-n"):
            inputfile = arg
        elif opt in ("-e") and arg in ['prod', 'test', 'local']:
            env = arg
    return inputfile, env


def update_db_nodes(node_file, session):
    if os.path.exists(node_file):
        node_pusher = NodePusher(session=session)
        node_pusher.update_db_nodes(file_path=node_file)
    else:
        pusher = NodePusher(session=session)
        pusher.start()


if __name__ == '__main__':
    set_env()
    (node_file, env) = get_opt(sys.argv[1:])
    env_setting = env
    session = set_session()
    update_db_nodes(node_file=node_file, session=session)
    session.close()