Ejemplo n.º 1
0
def deploy(version, venv_dir, profile):
    """ 发布指定的版本,会自动安装项目运行所需要的包

        version:build之后的版本
        venv_dir:虚拟环境名称
        profile:profile参数会传递到supervisord.conf中
    """

    if not version:
        version = build.get_latest_version()

    virtualenv.ensure(venv_dir)

    pre_hook = getattr(env, 'DEPLOY_PRE_HOOK', None)
    post_hook = getattr(env, 'DEPLOY_POST_HOOK', None)

    with virtualenv.activate(venv_dir):
        if callable(pre_hook):
            pre_hook(version, venv_dir, profile)
        supervisor.ensure(project=env.PROJECT, profile=profile)
        package.install(env.PROJECT, version)
        supervisor.shutdown()
        supervisor.start()
        if callable(post_hook):
            post_hook(version, venv_dir, profile)
Ejemplo n.º 2
0
def start(venv_dir=None, retry=0, retry_interval=2, max_retries=3):
    """
    重启指定虚拟环境的supervisor
    venv_dir 指定虚拟环境地址
    retry 当前重试次数
    retry_interval 多少秒后开始重试
    max_retries 最大重试次数
    """

    if retry > max_retries:
        print(red('start supervisord FAIL!'))
        return

    if venv_dir:
        with virtualenv.activate(venv_dir):
            start()

    if 'CURRENT_VIRTUAL_ENV_DIR' not in env:
        raise Exception('只可以在虚拟环境安装Python包')

    venv_dir = env.CURRENT_VIRTUAL_ENV_DIR

    with settings(warn_only=True), cd(venv_dir):
        # 停止supervisor管理的进程
        result = run('bin/supervisord -c etc/supervisord.conf ')
        if result:
            retry += 1
            print(green('start supervisord fail, retry[{}]'.format(retry)))
            start(retry=retry, retry_interval=retry_interval, max_retries=max_retries)
Ejemplo n.º 3
0
def deploy(version, venv_dir, profile):
    """ 发布指定的版本,会自动安装项目运行所需要的包

        version:build之后的版本
        venv_dir:虚拟环境名称
        profile:profile参数会传递到supervisord.conf中
    """

    if not version:
        version = build.get_latest_version()

    virtualenv.ensure(venv_dir)

    pre_hook = getattr(env, 'DEPLOY_PRE_HOOK', None)
    post_hook = getattr(env, 'DEPLOY_POST_HOOK', None)

    with virtualenv.activate(venv_dir):
        if callable(pre_hook):
            pre_hook(version, venv_dir, profile)
        supervisor.ensure(project=env.PROJECT, profile=profile)
        package.install(env.PROJECT, version)
        supervisor.shutdown()
        supervisor.start()
        if callable(post_hook):
            post_hook(version, venv_dir, profile)
Ejemplo n.º 4
0
def start(venv_dir=None, retry=0, retry_interval=2, max_retries=3):
    """
    重启指定虚拟环境的supervisor
    venv_dir 指定虚拟环境地址
    retry 当前重试次数
    retry_interval 多少秒后开始重试
    max_retries 最大重试次数
    """

    if retry > max_retries:
        print(red('start supervisord FAIL!'))
        return

    if venv_dir:
        with virtualenv.activate(venv_dir):
            start()

    if 'CURRENT_VIRTUAL_ENV_DIR' not in env:
        raise Exception('只可以在虚拟环境安装Python包')

    venv_dir = env.CURRENT_VIRTUAL_ENV_DIR

    with settings(warn_only=True), cd(venv_dir):
        # 停止supervisor管理的进程
        result = run('bin/supervisord -c etc/supervisord.conf ')
        if result:
            retry += 1
            print(green('start supervisord fail, retry[{}]'.format(retry)))
            start(retry=retry,
                  retry_interval=retry_interval,
                  max_retries=max_retries)
Ejemplo n.º 5
0
def git_deploy(venv_dir, profile):
    virtualenv.ensure(venv_dir)

    with virtualenv.activate(venv_dir):
        supervisor.ensure(project=env.PROJECT, profile=profile)
        package.install_from_git(env.PROJECT)
        supervisor.shutdown()
        supervisor.start()
Ejemplo n.º 6
0
def git_deploy(venv_dir, profile):
    virtualenv.ensure(venv_dir)

    with virtualenv.activate(venv_dir):
        supervisor.ensure(project=env.PROJECT, profile=profile)
        package.install_from_git(env.PROJECT)
        supervisor.shutdown()
        supervisor.start()
Ejemplo n.º 7
0
def _supervisor_command(command, venv_dir=None):
    if venv_dir:
        with virtualenv.activate(venv_dir):
            _supervisor_command(command)

    if 'CURRENT_VIRTUAL_ENV_DIR' not in env:
        raise Exception('只可以在虚拟环境安装Python包')

    venv_dir = env.CURRENT_VIRTUAL_ENV_DIR

    # 停止supervisor管理的进程
    with settings(warn_only=True), cd(venv_dir):
        run('bin/supervisorctl -c etc/supervisord.conf ' + command)
Ejemplo n.º 8
0
def deploy(version, venv_dir, profile):
    """
    发布指定的版本

    会自动安装项目运行所需要的包
    """

    virtualenv.ensure(venv_dir)
    with virtualenv.activate(venv_dir):
        supervisor.ensure(project=env.PROJECT, profile=profile)
        package.install(env.PROJECT, version)
        supervisor.shutdown()
        supervisor.start()
Ejemplo n.º 9
0
def _supervisor_command(command, venv_dir=None):
    if venv_dir:
        with virtualenv.activate(venv_dir):
            _supervisor_command(command)

    if 'CURRENT_VIRTUAL_ENV_DIR' not in env:
        raise Exception('只可以在虚拟环境安装Python包')

    venv_dir = env.CURRENT_VIRTUAL_ENV_DIR

    # 停止supervisor管理的进程
    with settings(warn_only=True), cd(venv_dir):
        run('bin/supervisorctl -c etc/supervisord.conf ' + command)
Ejemplo n.º 10
0
def deploy(version, venv_dir, profile):
    """
    发布指定的版本

    会自动安装项目运行所需要的包
    """

    virtualenv.ensure(venv_dir)

    with virtualenv.activate(venv_dir):
        supervisor.ensure(project=env.PROJECT, profile=profile)
        package.install(env.PROJECT, version)
        supervisor.shutdown()
        supervisor.start()
Ejemplo n.º 11
0
def start(venv_dir=None):
    """重启指定虚拟环境的supervisor"""

    if venv_dir:
        with virtualenv.activate(venv_dir):
            start()

    if 'CURRENT_VIRTUAL_ENV_DIR' not in env:
        raise Exception('只可以在虚拟环境安装Python包')

    venv_dir = env.CURRENT_VIRTUAL_ENV_DIR

    with settings(warn_only=True), cd(venv_dir):
        # 停止supervisor管理的进程
        run('bin/supervisord -c etc/supervisord.conf ')
Ejemplo n.º 12
0
def start(venv_dir=None):
    """重启指定虚拟环境的supervisor"""

    if venv_dir:
        with virtualenv.activate(venv_dir):
            start()

    if 'CURRENT_VIRTUAL_ENV_DIR' not in env:
        raise Exception('只可以在虚拟环境安装Python包')

    venv_dir = env.CURRENT_VIRTUAL_ENV_DIR

    with settings(warn_only=True), cd(venv_dir):
        # 停止supervisor管理的进程
        run('bin/supervisord -c etc/supervisord.conf ')