__init__.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:flux 作者: NiklasRosenstein 项目源码 文件源码
def main():
  ''' Runs the Flux Flask application and all required components. '''

  # Test if Git version is at least 2.3 (for GIT_SSH_COMMAND)
  git_version = subprocess.check_output(['git', '--version']).decode().strip()
  git_version = re.search('^git version (\d\.\d+)', git_version)
  if git_version:
    git_version = git_version.group(1)
  if not git_version or int(git_version.split('.')[1]) < 3:
    print('Error: {!r} installed but need at least 2.3'.format(git_version))
    sys.exit(1)

  # Make sure the root user exists and has all privileges, and that
  # the password is up to date.
  with models.Session() as session:
    models.User.create_or_update_root(session)

  # Create a dispatcher for the sub-url under which the app is run.
  url_prefix = urlparse(config.app_url).path
  if url_prefix and url_prefix != '/':
    print(url_prefix)
    from werkzeug.wsgi import DispatcherMiddleware
    target_app = DispatcherMiddleware(flask.Flask('_dummy_app'), {
      url_prefix: app,
    })
  else:
    target_app = app

  print(' * starting builder threads...')
  build.run_consumers(num_threads=config.parallel_builds)
  build.update_queue()
  try:
    from werkzeug.serving import run_simple
    run_simple(config.host, config.port, target_app, use_reloader=False)
  finally:
    print(' * stopping builder threads...')
    build.stop_consumers()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号