コード例 #1
0
ファイル: api.py プロジェクト: Hoedic/fab_taxi
def deploy_api(commit='master'):
    now = int(time.time())
    require.files.directory(env.deployment_dir(now))
    with cd(env.deployment_dir(now)):
        run(u'wget {}'.format(env.apitaxi_archive.format(commit)))
        run('unzip {}.zip'.format(commit))
        if commit != 'master':
            run('mv APITaxi-{} APITaxi-master'.format(commit))

    with cd(env.apitaxi_dir(now)):
        require.python.virtualenv(env.apitaxi_venv_path(now))
        with python.virtualenv(env.apitaxi_venv_path(now)):
            python.install_pip(use_sudo=False)
            require.python.package('uwsgi')
            python.install_requirements('requirements.txt')
            put(environ['APITAXI_CONFIG_FILE'], env.apitaxi_config_path(now))
            with shell_env(APITAXI_CONFIG_FILE=env.apitaxi_config_path(now)):
                for i in range(1, 30):
                    if service.is_running('supervisor'):
                        break
                    time.sleep(1)
                run('python manage.py db upgrade')
                install_admin_user()
        deploy_front(now)
        deploy_nginx_api_site(now)
    if not service.is_running('nginx'):
        service.start('nginx')
    clean_directories(now)
    stop_old_processes(now)
    restart_stats_workers(now)
コード例 #2
0
def restart_nginx():
    print(green("Restarting Nginx"))
    if service.is_running('nginx'):
        #service.restart('nginx')
        service.reload('nginx')
    else:
        service.start('nginx')
コード例 #3
0
ファイル: kraken.py プロジェクト: pbougue/fabric_navitia
def create_eng_instance(instance):
    """ Create a new kraken instance (idempotent)
        * Install requirements
        * Deploy the binary, the templatized ini configuration in a dedicated
          directory with rights to www-data and the logdir
        * Deploy initscript and add it to startup
        * Start the service
    """
    instance = get_real_instance(instance)
    for host in instance.kraken_engines:
        with settings(host_string=host):
            # base_conf
            require.files.directory(instance.kraken_basedir,
                                    owner=env.KRAKEN_USER,
                                    group=env.KRAKEN_USER,
                                    use_sudo=True)
            # logs
            require.files.directory(env.kraken_log_basedir,
                                    owner=env.KRAKEN_USER,
                                    group=env.KRAKEN_USER,
                                    use_sudo=True)

            update_eng_instance_conf(instance, host)

            # kraken.ini, pid and binary symlink
            kraken_bin = "{}/{}/kraken".format(env.kraken_basedir,
                                               instance.name)
            if not is_link(kraken_bin):
                idempotent_symlink("/usr/bin/kraken",
                                   kraken_bin,
                                   use_sudo=True)
                sudo('chown -h {user} {bin}'.format(user=env.KRAKEN_USER,
                                                    bin=kraken_bin))

            kraken = "kraken_{}".format(instance.name)
            if not service.is_running(kraken):
                # TODO test this on systemd machines
                if env.use_systemd:
                    sudo("systemctl enable kraken_{}.service".format(
                        instance.name))
                else:
                    sudo("update-rc.d kraken_{} defaults".format(
                        instance.name))
                print(
                    blue(
                        "INFO: kraken {instance} instance is starting on {server}, "
                        "waiting 5 seconds, we will check if processus is running"
                        .format(instance=instance.name,
                                server=get_host_addr(env.host_string))))
                service.start(kraken)
                run("sleep 5")  # we wait a bit for the kraken to pop

            with settings(warn_only=True):
                run("pgrep --list-name --full /srv/kraken/{}/kraken".format(
                    instance.name))
            print(
                blue("INFO: kraken {instance} instance is running on {server}".
                     format(instance=instance.name,
                            server=get_host_addr(host))))
コード例 #4
0
ファイル: mariadb.py プロジェクト: lgunsch/helix-cloud-ops
def bootstrap_cluster():
    """Run on the first machine of a new cluster, without any mysqld daemons running."""
    puts(red('This should be run on the FIRST machine of the new cluster'))
    puts(red('No other mysqld daemons should be running for this cluster'))
    if service.is_running('mysql'):
        service.stop('mysql')
    # nohup below is very important. See:
    # http://serverfault.com/questions/709223/galera-new-cluster-wsrep-unknown-error-141
    run('nohup service mysql bootstrap')
コード例 #5
0
ファイル: mariadb.py プロジェクト: lgunsch/helix-cloud-ops
def start(name='mysql'):
    """Defaults to `mysql`, but may also be `garb` for the arbitrator."""
    # nohup below is very important. See:
    # http://serverfault.com/questions/709223/galera-new-cluster-wsrep-unknown-error-141
    if service.is_running(name):
        puts(red('{} is already running. Restarting (not reload) to '
                 'init cluster membership.'.format(name)))
        run('nohup service {} restart'.format(name))
    else:
        run('nohup service {} start'.format(name))
コード例 #6
0
def stopped(service):
    """
    Require a service to be stopped.

    ::

        from fabtools import require

        require.service.stopped('foo')
    """
    if is_running(service):
        stop(service)
コード例 #7
0
def restarted(service):
    """
    Require a service to be restarted.

    ::

        from fabtools import require

        require.service.restarted('foo')
    """
    if is_running(service):
        restart(service)
    else:
        start(service)
コード例 #8
0
ファイル: service.py プロジェクト: zloy531/fabtools3
def stopped(service):
    """
    Require a service to be stopped.

    ::

        from fabtools import require

        require.service.stopped('foo')
    """
    if is_running(service):
        if using_systemd():
            systemd.stop(service)
        else:
            stop(service)
コード例 #9
0
ファイル: fabfile.py プロジェクト: Gnuside/cozy-setup
def install_haibu():
    """
    Setup Haibu Application Manager.
    """

    with cd('/home/cozy/cozy-setup'):
        cozydo('HOME=/home/cozy npm install')
        sudo('cp paas.conf /etc/init/')

    if not service.is_running("paas"):
        service.start('paas')
    else:
        service.restart('paas')

    print(green("Haibu successfully started"))
コード例 #10
0
ファイル: kraken.py プロジェクト: CanalTP/fabric_navitia
def create_eng_instance(instance):
    """ Create a new kraken instance (idempotent)
        * Install requirements
        * Deploy the binary, the templatized ini configuration in a dedicated
          directory with rights to www-data and the logdir
        * Deploy initscript and add it to startup
        * Start the service
    """
    instance = get_real_instance(instance)
    for host in instance.kraken_engines:
        with settings(host_string=host):
            # base_conf
            require.files.directory(instance.kraken_basedir,
                                    owner=env.KRAKEN_USER, group=env.KRAKEN_USER, use_sudo=True)
            # logs
            require.files.directory(env.kraken_log_basedir,
                                    owner=env.KRAKEN_USER, group=env.KRAKEN_USER, use_sudo=True)

            update_eng_instance_conf(instance, host)

            # kraken.ini, pid and binary symlink
            kraken_bin = "{}/{}/kraken".format(env.kraken_basedir, instance.name)
            if not is_link(kraken_bin):
                idempotent_symlink("/usr/bin/kraken", kraken_bin, use_sudo=True)
                sudo('chown -h {user} {bin}'.format(user=env.KRAKEN_USER, bin=kraken_bin))

            kraken = "kraken_{}".format(instance.name)
            if not service.is_running(kraken):
                # TODO test this on systemd machines
                if env.use_systemd:
                    sudo("systemctl enable kraken_{}.service".format(instance.name))
                else:
                    sudo("update-rc.d kraken_{} defaults".format(instance.name))
                print(blue("INFO: kraken {instance} instance is starting on {server}, "
                           "waiting 5 seconds, we will check if processus is running"
                    .format(instance=instance.name, server=get_host_addr(env.host_string))))
                service.start(kraken)
                run("sleep 5")  # we wait a bit for the kraken to pop

            with settings(warn_only=True):
                run("pgrep --list-name --full /srv/kraken/{}/kraken".format(instance.name))
            print(blue("INFO: kraken {instance} instance is running on {server}".
                       format(instance=instance.name, server=get_host_addr(host))))
コード例 #11
0
ファイル: api.py プロジェクト: odtvince/fab_taxi
def deploy_api():
    now = int(time.time())
    require.files.directory(env.deployment_dir(now))
    with cd(env.deployment_dir(now)):
        run('wget https://github.com/openmaraude/APITaxi/archive/master.zip')
        run('unzip master.zip')

    with cd(env.apitaxi_dir(now)):
        require.python.virtualenv(env.apitaxi_venv_path(now))
        with python.virtualenv(env.apitaxi_venv_path(now)):
            python.install_pip()
            require.python.package('uwsgi')
            python.install_requirements('requirements.txt')
            put(environ['APITAXI_CONFIG_FILE'], env.apitaxi_config_path(now))
            run('python manage.py db upgrade')
        deploy_nginx_api_site(now)
    if not service.is_running('nginx'):
        service.start('nginx')
    clean_directories(now)
    stop_old_processes(now)
コード例 #12
0
def _update_ssh_setting(sshd_config, name, value):
    """
    Update a yes/no setting in the SSH config file
    """

    with watch(sshd_config) as config_file:

        with shell_env():

            # First try to change existing setting
            sed(sshd_config,
                r'^(\s*#\s*)?%s\s+(yes|no)' % name,
                '%s %s' % (name, value),
                use_sudo=True)

            # Then append setting if it's still missing
            _append(sshd_config, '%s %s' % (name, value), use_sudo=True)

    if config_file.changed and is_running('ssh'):
        restart('ssh')
コード例 #13
0
ファイル: ssh.py プロジェクト: artnez/fabtools
def _update_ssh_setting(sshd_config, name, value):
    """
    Update a yes/no setting in the SSH config file
    """

    with watch(sshd_config) as config_file:

        # First try to change existing setting
        sed(sshd_config,
            r'^(\s*#\s*)?%s\s+(yes|no)' % name,
            '%s %s' % (name, value),
            use_sudo=True)

        # Then append setting if it's still missing
        _append(sshd_config,
                '%s %s' % (name, value),
                use_sudo=True)

    if config_file.changed and is_running('ssh'):
        restart('ssh')
コード例 #14
0
def restart(component):
    if service.is_running(component):
        service.restart(component)
    else:
        service.start(component)
コード例 #15
0
ファイル: fabfile.py プロジェクト: hoelzro/giraffe
def restart_app(service_name=SERVICE_NAME):
    if service.is_running(SERVICE_NAME):
        service.restart(SERVICE_NAME)
    else:
        service.start(SERVICE_NAME)
コード例 #16
0
ファイル: dash.py プロジェクト: odtvince/fab_taxi
def restart_influxdb():
    if service.is_running('influxdb'):
        require.service.restart('influxdb')
    else:
        require.service.start('influxdb')
コード例 #17
0
def install_fail2ban():
    require.deb.package(['fail2ban'])
    if not service.is_running('fail2ban'):
        service.start('fail2ban')
コード例 #18
0
def restart_app(service_name=SERVICE_NAME):
    if service.is_running(SERVICE_NAME):
        service.restart(SERVICE_NAME)
    else:
        service.start(SERVICE_NAME)
コード例 #19
0
ファイル: dash.py プロジェクト: Hoedic/fab_taxi
def restart_influxdb():
    if service.is_running('influxdb'):
        sudo('service influxdb restart', pty=False)
    else:
        require.service.start('influxdb')