Пример #1
0
def tail_logfiles(logs, milestones, interval=60):
  db = scload.connect_db()
  scload.init_listeners(db)

  cursor = db.cursor()
  scload.set_active_cursor(cursor, db)
  elapsed_time = 0

  master = scload.create_master_reader()
  scload.bootstrap_known_raceclasses(cursor)
  try:
    while True:
      try:
        interval_work(cursor, interval, master)
        pagedefs.incremental_build(cursor)
        if not interval:
          break
      except IOError, e:
        error("IOError: %s" % e)
      info("Finished batch.");

      time.sleep(interval)
      elapsed_time += interval

      pagedefs.tick_dirty()

      if crawl_utils.scoresd_stop_requested():
        info("Exit due to scoresd stop request.")
        break
  finally:
    scload.set_active_cursor(None)
    cursor.close()
    db.close()
Пример #2
0
def tail_logfiles(logs, milestones, interval=60):
    db = scload.connect_db()
    scload.init_listeners(db)

    cursor = db.cursor()
    scload.set_active_cursor(cursor, db)
    elapsed_time = 0

    master = scload.create_master_reader()
    scload.bootstrap_known_raceclasses(cursor)
    try:
        while True:
            try:
                interval_work(cursor, interval, master)
                pagedefs.incremental_build(cursor)
                if not interval:
                    break
            except IOError, e:
                error("IOError: %s" % e)
            info("Finished batch.")

            time.sleep(interval)
            elapsed_time += interval

            pagedefs.tick_dirty()

            if crawl_utils.scoresd_stop_requested():
                info("Exit due to scoresd stop request.")
                break
    finally:
        scload.set_active_cursor(None)
        cursor.close()
        db.close()
Пример #3
0
def tail_logfiles(logs, milestones, interval=60):
  db = scload.connect_db()
  scload.init_listeners(db)

  cursor = db.cursor()
  scload.set_active_cursor(cursor, db)
  elapsed_time = 0

  master = scload.create_master_reader()
  scload.bootstrap_known_raceclasses(cursor)
  scload.init_game_restrictions(cursor)

  daemon_loop = True

  if scload.OPT.run_bans:
    scload.run_bans(cursor)
    pagedefs.incremental_build(cursor)
    daemon_loop = False # a one-off command, don't really start the daemon

  try:
    while daemon_loop:
      try:
        interval_work(cursor, interval, master)
        pagedefs.incremental_build(cursor)
        if not interval:
          break
      except IOError, e:
        error("IOError: %s" % e)
      info("Finished batch.");
      if check_daemon_stop():
        break

      if not scload.OPT.force_loop and scload.OPT.run_once:
        break

      time.sleep(interval)
      elapsed_time += interval

      pagedefs.tick_dirty()

      if check_daemon_stop():
        break
  except KeyboardInterrupt: # signal or ctrl-c in non-daemon mode
    warn("Rollback triggered by interrupt signal")
    cursor.db.rollback()
  finally:
    if not scload.OPT.load_only:
      info("Flushing player pages and shutting down db connection")
      try:
        pagedefs.flush_pages(cursor) # flush any dirty player pages
      except Exception as e:
        error("Failed to flush pages: " + str(e))
    scload.set_active_cursor(None)
    cursor.close()
    db.close()
    crawl_utils.clear_scoresd_stop_request()
    info("Daemon exit")
Пример #4
0
def _cursor():
  """Easy retrieve of cursor to make interactive testing easier."""
  d = scload.connect_db()
  return d.cursor()
Пример #5
0
def _cursor():
    """Easy retrieve of cursor to make interactive testing easier."""
    d = scload.connect_db()
    return d.cursor()