Esempio n. 1
0
def run(use_minikube, server_wait=True, capture_output=False):
    logging.basicConfig()
    sys.path.append(os.path.join(ROOT_DIR_LOCATION, 'example_project'))
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example_project.settings")

    run_command(['pip', 'install', '-e', ROOT_DIR_LOCATION],
                capture_output=capture_output)
    run_command(['python', _MANAGE_PY, 'migrate', '--noinput'],
                capture_output=capture_output)
    run_command(['python', _MANAGE_PY, 'collectstatic', '--noinput'],
                capture_output=capture_output)

    create_superuser_if_missing(username='******', password='******')

    server_args = []
    if use_minikube:
        # Import minikube here, so we can install the deps first
        parent_dir = os.path.dirname(os.path.dirname(
            os.path.abspath(__file__)))
        sys.path.append(os.path.join(parent_dir, 'aimmo_runner'))

        os.chdir(ROOT_DIR_LOCATION)
        run_command([
            'pip', 'install', '-r',
            os.path.join(ROOT_DIR_LOCATION, 'minikube_requirements.txt')
        ],
                    capture_output=capture_output)
        from aimmo_runner import minikube
        minikube.start()

        server_args.append('0.0.0.0:8000')
        os.environ['AIMMO_MODE'] = 'minikube'
    else:
        time.sleep(2)
        game = run_command_async(['python', _SERVICE_PY, '127.0.0.1', '5000'],
                                 capture_output=capture_output)
        PROCESSES.append(game)
        os.environ['AIMMO_MODE'] = 'threads'

    os.environ['NODE_ENV'] = 'development' if settings.DEBUG else 'production'
    server = run_command_async(['python', _MANAGE_PY, 'runserver'] +
                               server_args,
                               capture_output=capture_output)
    frontend_bundler = run_command_async(['node', _FRONTEND_BUNDLER_JS],
                                         capture_output=capture_output)
    PROCESSES.append(server)
    PROCESSES.append(frontend_bundler)

    if server_wait is True:
        try:
            game.wait()
        except NameError:
            pass

        server.wait()

    return PROCESSES
Esempio n. 2
0
def start_game_servers(build_target, server_args):
    parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    sys.path.append(os.path.join(parent_dir, "aimmo_runner"))
    os.chdir(ROOT_DIR_LOCATION)

    # Import minikube here, so we can install the dependencies first
    from aimmo_runner import minikube

    minikube.start(build_target=build_target)

    server_args.append("0.0.0.0:8000")
    os.environ["AIMMO_MODE"] = "minikube"
Esempio n. 3
0
def start_game_servers(use_minikube, build_target, server_args):
    if use_minikube:
        parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
        sys.path.append(os.path.join(parent_dir, "aimmo_runner"))

        os.chdir(ROOT_DIR_LOCATION)

        # Import minikube here, so we can install the dependencies first
        from aimmo_runner import minikube

        minikube.start(build_target=build_target)

        server_args.append("0.0.0.0:8000")
        os.environ["AIMMO_MODE"] = "minikube"
    else:
        time.sleep(2)
        os.environ["AIMMO_MODE"] = "threads"
        docker_scripts.delete_containers()
        if build_target == "tester":
            run_command(["python", "all_tests.py"])
        else:
            docker_scripts.build_docker_images(build_target=build_target)
            docker_scripts.start_game_creator()
Esempio n. 4
0
def run(use_minikube,
        server_wait=True,
        capture_output=False,
        test_env=False,
        build_target=None):
    logging.basicConfig()
    if test_env:
        os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test_settings")
    else:
        sys.path.append(os.path.join(ROOT_DIR_LOCATION, 'example_project'))
        os.environ.setdefault("DJANGO_SETTINGS_MODULE",
                              "example_project.settings")

    django.setup()
    run_command(['pip', 'install', '-e', ROOT_DIR_LOCATION],
                capture_output=capture_output)

    if not test_env:
        run_command(['python', _MANAGE_PY, 'migrate', '--noinput'],
                    capture_output=capture_output)
        run_command(['python', _MANAGE_PY, 'collectstatic', '--noinput'],
                    capture_output=capture_output)

    create_superuser_if_missing(username='******', password='******')

    server_args = []
    if use_minikube:
        parent_dir = os.path.dirname(os.path.dirname(
            os.path.abspath(__file__)))
        sys.path.append(os.path.join(parent_dir, 'aimmo_runner'))

        os.chdir(ROOT_DIR_LOCATION)
        run_command([
            'pip', 'install', '-r',
            os.path.join(ROOT_DIR_LOCATION, 'minikube_requirements.txt')
        ],
                    capture_output=capture_output)

        # Import minikube here, so we can install the dependencies first
        from aimmo_runner import minikube
        minikube.start(build_target=build_target)

        server_args.append('0.0.0.0:8000')
        os.environ['AIMMO_MODE'] = 'minikube'
    else:
        time.sleep(2)
        os.environ['AIMMO_MODE'] = 'threads'
        docker_scripts.delete_containers()
        if build_target == 'tester':
            run_command(['python', 'all_tests.py'])
        else:
            docker_scripts.build_docker_images(build_target=build_target)
            docker_scripts.start_game_creator()

    os.environ['NODE_ENV'] = 'development' if settings.DEBUG else 'production'
    server = run_command_async(['python', _MANAGE_PY, 'runserver'] +
                               server_args,
                               capture_output=capture_output)
    frontend_bundler = run_command_async(['node', _FRONTEND_BUNDLER_JS],
                                         capture_output=capture_output)
    PROCESSES.append(server)
    PROCESSES.append(frontend_bundler)

    if server_wait is True:
        try:
            game.wait()
        except NameError:
            pass

        server.wait()

    return PROCESSES
Esempio n. 5
0
def run(
    use_minikube,
    server_wait=True,
    capture_output=False,
    test_env=False,
    build_target=None,
):
    logging.basicConfig()

    build_worker_package()

    if test_env:
        os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test_settings")
    else:
        sys.path.append(os.path.join(ROOT_DIR_LOCATION, "example_project"))
        os.environ.setdefault("DJANGO_SETTINGS_MODULE",
                              "example_project.settings")

    django.setup()
    run_command(["pip", "install", "-e", ROOT_DIR_LOCATION],
                capture_output=capture_output)

    if not test_env:
        run_command(
            ["python", _MANAGE_PY, "migrate", "--noinput"],
            capture_output=capture_output,
        )
        run_command(
            ["python", _MANAGE_PY, "collectstatic", "--noinput"],
            capture_output=capture_output,
        )

    create_superuser_if_missing(username="******", password="******")

    server_args = []
    if use_minikube:
        parent_dir = os.path.dirname(os.path.dirname(
            os.path.abspath(__file__)))
        sys.path.append(os.path.join(parent_dir, "aimmo_runner"))

        os.chdir(ROOT_DIR_LOCATION)

        # Import minikube here, so we can install the dependencies first
        from aimmo_runner import minikube

        minikube.start(build_target=build_target)

        server_args.append("0.0.0.0:8000")
        os.environ["AIMMO_MODE"] = "minikube"
    else:
        time.sleep(2)
        os.environ["AIMMO_MODE"] = "threads"
        docker_scripts.delete_containers()
        if build_target == "tester":
            run_command(["python", "all_tests.py"])
        else:
            docker_scripts.build_docker_images(build_target=build_target)
            docker_scripts.start_game_creator()

    os.environ["NODE_ENV"] = "development" if settings.DEBUG else "production"
    os.environ["SERVER_ENV"] = "local"
    server = run_command_async(["python", _MANAGE_PY, "runserver"] +
                               server_args,
                               capture_output=capture_output)
    frontend_bundler = run_command_async(["node", _FRONTEND_BUNDLER_JS],
                                         capture_output=capture_output)
    PROCESSES.append(server)
    PROCESSES.append(frontend_bundler)

    if server_wait is True:
        try:
            game.wait()
        except NameError:
            pass

        server.wait()

    return PROCESSES