Beispiel #1
0
def deploy():
    with prefix('source $(which virtualenvwrapper.sh) && workon remote'):
        settings_file = '--settings=haxclub.settings.base'
        env_vars = config.get('env_vars')
        if not exists('~/haxclub'):
            with cd('~/'):
                run('git clone https://github.com/jsalva/haxclub')
        with cd('~/haxclub/haxclub'):
            if not exists('logs'):
                run('mkdir logs')
            run('git pull origin master')
            with shell_env(**env_vars):
                prompts = []
                prompts += expect("Type 'yes' to continue","yes")
                with expecting(prompts):
                    erun('python manage.py collectstatic %s' % settings_file)
                    erun('python manage.py migrate %s' % settings_file)
                    erun('python manage.py syncdb %s' % settings_file)
                    if exists('supervisord.pid'):
                        erun('python manage.py supervisor reload %s' % settings_file)
                    else:
                        erun('python manage.py supervisor --daemonize %s' % settings_file)

    if not exists('/tmp/nginx'):
        run('mkdir /tmp/nginx')

    put('nginx.conf','/etc/nginx/nginx.conf',use_sudo=True)
    put('nginx_haxclub.conf','/etc/nginx/conf.d/nginx_haxclub.conf',use_sudo=True)
    put('ssl/haxclub.key.nopass','/etc/ssl/certs/haxclub.key.nopass',use_sudo=True)
    put('ssl/haxclub.crt','/etc/ssl/certs/haxclub.crt',use_sudo=True)
    put('nginx_haxclub.conf','/etc/nginx/conf.d/nginx_haxclub.conf',use_sudo=True)
    sudo('service nginx stop; service nginx start;')
Beispiel #2
0
def dbinit():
    """
    Creates a default database and user with appropriate privileges
    for local development
    """

    mysql_cmd = "create database {0};"+\
    "create user {1}@\"{2}\" identified by \"{3}\";"+\
    "create user {1}@localhost identified by \"{3}\";"+\
    "grant all privileges on {0}.* to {1}@localhost;"+\
    "grant all privileges on {0}.* to {1}@\"{2}\";exit;"

    mysql_prompts = []
    mysql_prompts += expect('mysql>',mysql_cmd.format(
        config.get('env_vars').get("DATABASE_NAME"),
        config.get('env_vars').get("DATABASE_USER"),
        config.get('env_vars').get("DATABASE_CONSUMER",'%'),
        config.get('env_vars').get("DATABASE_PASSWORD")))

    with expecting(mysql_prompts):
        erun('mysql -u root')
Beispiel #3
0
def deploy():
    with prefix('source $(which virtualenvwrapper.sh) && workon remote'):
        settings_file = '--settings=haxclub.settings.base'
        env_vars = config.get('env_vars')
        if not exists('~/haxclub'):
            with cd('~/'):
                run('git clone https://github.com/jsalva/haxclub')
        with cd('~/haxclub/haxclub'):
            if not exists('logs'):
                run('mkdir logs')
            run('git pull origin master')
            with shell_env(**env_vars):
                prompts = []
                prompts += expect("Type 'yes' to continue", "yes")
                with expecting(prompts):
                    erun('python manage.py collectstatic %s' % settings_file)
                    erun('python manage.py migrate %s' % settings_file)
                    erun('python manage.py syncdb %s' % settings_file)
                    if exists('supervisord.pid'):
                        erun('python manage.py supervisor reload %s' %
                             settings_file)
                    else:
                        erun('python manage.py supervisor --daemonize %s' %
                             settings_file)

    if not exists('/tmp/nginx'):
        run('mkdir /tmp/nginx')

    put('nginx.conf', '/etc/nginx/nginx.conf', use_sudo=True)
    put('nginx_haxclub.conf',
        '/etc/nginx/conf.d/nginx_haxclub.conf',
        use_sudo=True)
    put('ssl/haxclub.key.nopass',
        '/etc/ssl/certs/haxclub.key.nopass',
        use_sudo=True)
    put('ssl/haxclub.crt', '/etc/ssl/certs/haxclub.crt', use_sudo=True)
    put('nginx_haxclub.conf',
        '/etc/nginx/conf.d/nginx_haxclub.conf',
        use_sudo=True)
    sudo('service nginx stop; service nginx start;')
Beispiel #4
0
def dbinit():
    """
    Creates a default database and user with appropriate privileges
    for local development
    """

    mysql_cmd = "create database {0};"+\
    "create user {1}@\"{2}\" identified by \"{3}\";"+\
    "create user {1}@localhost identified by \"{3}\";"+\
    "grant all privileges on {0}.* to {1}@localhost;"+\
    "grant all privileges on {0}.* to {1}@\"{2}\";exit;"

    mysql_prompts = []
    mysql_prompts += expect(
        'mysql>',
        mysql_cmd.format(
            config.get('env_vars').get("DATABASE_NAME"),
            config.get('env_vars').get("DATABASE_USER"),
            config.get('env_vars').get("DATABASE_CONSUMER", '%'),
            config.get('env_vars').get("DATABASE_PASSWORD")))

    with expecting(mysql_prompts):
        erun('mysql -u root')
Beispiel #5
0
def eruncmd(arg):
    if useSudo():
        return esudo("%s" % arg)
    else:
        return erun("%s" % arg)
Beispiel #6
0
def eruncmd(arg):
    if useSudo():
        return esudo("%s" % arg)
    else:
        return erun("%s" % arg)