Ejemplo n.º 1
0
def nginxcfg():
    """
    Links our nginx config to the sites-enabled dir
    """
    require('hosts')
    print(cyan('-- nginxcfg // linking config file to conf.d/'))
    if not _exists('/etc/nginx/sites-enabled/%s' % (env.procname)):
        sudo('ln -s %s/conf/nginx/%s.conf /etc/nginx/sites-enabled/%s' % (env.path, env.flavor, env.procname))
    else:
        print(yellow('-- nginxcfg // %s already exists!' % env.procname))
    print(cyan('-- nginxcfg // make sure our log directories exist!'))
    if not _exists('%s/logs/nginx' % env.path):
        sudo('mkdir -p %s/logs/nginx' % env.path, user=env.project_user)
    else:
        print(yellow('-- nginxcfg // %s/logs already exists!' % (env.path)))
    print(cyan('-- nginxcfg // reloading nginx config'))
    sudo('/etc/init.d/nginx reload')
Ejemplo n.º 2
0
def upload_virtualenv_vendors():
    """
    Uploads virtualenv vendors
    """
    if not _exists(os.path.join(env.venv_path, 'node_modules')):
        print(cyan('-- upload_virtualenv_vendors // uploading node_modules'))
        put('vendors/virtualenv/node_modules', '%s/' % env.venv_path, use_sudo=True)
        print(cyan('-- upload_virtualenv_vendors // chowning...'))
        _setowner(os.path.join(env.venv_path, 'node_modules'))
        print(cyan('-- upload_virtualenv_vendors // chmoding'))
        _setperms('770', os.path.join(env.venv_path, 'node_modules'))
Ejemplo n.º 3
0
def supervisorcfg():
    """
    Links our supervisor config file to the config.d dir
    """
    require('hosts')
    print(cyan('-- supervisorcfg // linking config file to conf.d/'))
    if not _exists('/etc/supervisor/conf.d/%s.conf' % (env.procname)):
        sudo('ln -s %s/conf/supervisord/%s.conf /etc/supervisor/conf.d/%s.conf' % (env.path, env.flavor, env.procname))
    else:
        print(yellow('-- supervisorcfg // %s.conf already exists!' % (env.procname)))

    sudo('supervisorctl reread')
    sudo('supervisorctl update')
Ejemplo n.º 4
0
def deploy():
    """
    Clone the git repository to the correct directory
    """
    require('hosts')
    if not _exists(env.path):
        print(cyan('-- creating %s as %s' % (env.path, env.project_user)))
        sudo('mkdir -p %s' % env.path, user=env.project_user)
        with cd(env.path):
            if (getattr(env, 'branch', '') == ''):
                print(cyan('-- git // cloning source code into %s' % env.path))
                sudo('git clone file:///code/git/%s .' % env.repo, user=env.project_user)
            else:
                print(cyan('-- git // cloning source code branch %s into %s' % (env.branch, env.path)))
                sudo('git clone file:///code/git/%s -b %s .' % (env.repo, env.branch), user=env.project_user)
        fixprojectperms()
    else:
        print(cyan('-- directory %s exists, skipping git clone & updating instead' % env.path))
        gitpull()
Ejemplo n.º 5
0
def logrotatecfg():
    """
    Links our logrotate config file to the config.d dir
    """
    require('hosts')
    logrotate_src = "%s/etc/logrotate/%s.conf" % (env.path, env.flavor)
    print(cyan('-- logrotateconf // linking config file to conf.d/'))
    if not _exists('/etc/logrotate.d/%s.conf' % (env.procname)):
        sudo('ln -s %s /etc/logrotate.d/%s.conf' % (logrotate_src, env.procname))
    else:
        print(yellow('-- logrotateconf // %s.conf already exists!' % (env.procname)))

    # set permission to 644
    print(cyan('-- setperms // setting logrotate conf to 644'))
    sudo('chmod %s "%s"' % (perms, logrotate_src))

    # set owner to root
    print(cyan('-- setowner // setting logrotate owner to root'))
    sudo('chown root:wheel "%s"' % logrotate_src)
Ejemplo n.º 6
0
def mkvirtualenv():
    """
    Setup a fresh virtualenv.
    """
    require('hosts')
    print(cyan('-- mkvirtualenv // uploading bash_profile...'))
    put('conf/.bash_profile_source', '/home/%s/.bash_profile' % env.project_user, use_sudo=True)
    print(cyan('-- mkvirtualenv // setting owner and permissions 660'))
    _setowner(os.path.join('/home', env.project_user, '.bash_profile'))
    _setperms('660', os.path.join('/home', env.project_user, '.bash_profile'))
    print(cyan('-- mkvirtualenv // running virtualenvwrapper.sh'))
    sudo('export WORKON_HOME=/sites/.virtualenvs', user=env.project_user)
    with shell_env(WORKON_HOME='/sites/.virtualenvs'):
        sudo('source /usr/local/bin/virtualenvwrapper.sh', user=env.project_user)
    print(cyan('-- mkvirtualenv // chmoding hook.log to avoid permission trouble'))
    with _settings(warn_only=True):
        _setperms('660', os.path.join(env.venv_root, 'hook.log'))
        _setowner(os.path.join(env.venv_root, 'hook.log'))
    with _settings(warn_only=True):
        if _exists(env.venv_path):
            print(yellow('-- mkvirtualenv // virtualenv %s already exists - now removing.' % env.venv_path))
            sudo('export WORKON_HOME=/sites/.virtualenvs && source /usr/local/bin/virtualenvwrapper.sh && rmvirtualenv %s' % env.venv_name, user=env.project_user)
    sudo('export WORKON_HOME=/sites/.virtualenvs && source /usr/local/bin/virtualenvwrapper.sh && mkvirtualenv %s' % env.venv_name, user=env.project_user)
Ejemplo n.º 7
0
def exists(path):
    if _is_local(env.host):
        return os.path.exists(os.path.expanduser(path))
    else:
        return _exists(path)