Beispiel #1
0
def _update_scripts(conn: Connection, config: str, daily_scripts_dir: str):
    cron_daily_dir = '/etc/cron.daily'
    with conn.cd(daily_scripts_dir):
        conn.sudo('cp newdjangosite-{0}-* {1}'.format(config, cron_daily_dir))

    with conn.cd(cron_daily_dir):
        conn.sudo('chmod 755 newdjangosite-{0}-*'.format(config))
Beispiel #2
0
def _compile_source(conn: Connection, config: str, repo_dir: str, web_dir: str,
                    virtualenv_python: str):
    with conn.cd(repo_dir):
        conn.run('venv/bin/pip install --quiet --requirement=requirements.txt')

    with conn.cd(web_dir):
        conn.sudo('find . -iname "*.pyc" -delete')
        conn.sudo('{0} -m compileall .'.format(virtualenv_python))
        conn.sudo('{0} manage_{1}.py collectstatic --noinput'.format(
            virtualenv_python, config))
Beispiel #3
0
def _reload_web(conn: Connection, config: str, nginx_dir: str, ssl: bool,
                ssl_dir: str):
    with conn.cd(nginx_dir):
        conn.sudo(
            'cp {0}.yourdomain.tld /etc/nginx/sites-enabled/'.format(config))

    if ssl:
        with conn.cd(ssl_dir):
            conn.sudo('cp {0}.yourdomain.tld.* /etc/nginx/ssl'.format(config))
            conn.sudo('chown root /etc/nginx/ssl/{0}.yourdomain.tld.*'.format(
                config))
            conn.sudo('chgrp root /etc/nginx/ssl/{0}.yourdomain.tld.*'.format(
                config))
            conn.sudo(
                'chmod 644 /etc/nginx/ssl/{0}.yourdomain.tld.*'.format(config))

    conn.sudo('/etc/init.d/nginx reload')
Beispiel #4
0
def _reload_code(conn: Connection, config: str, uwsgi_dir: str):
    with conn.cd(uwsgi_dir):
        conn.sudo('cp newdjangosite-{0}.ini /etc/uwsgi/apps-available'.format(
            config))
        conn.sudo(
            'chmod 644 /etc/uwsgi/apps-available/newdjangosite-{0}.ini'.format(
                config))
        conn.sudo('systemctl enable uwsgi-app@newdjangosite-{0}.socket'.format(
            config))
        conn.sudo(
            'systemctl enable uwsgi-app@newdjangosite-{0}.service'.format(
                config))
        conn.sudo('systemctl start uwsgi-app@newdjangosite-{0}.socket'.format(
            config))
        conn.sudo(
            'touch /var/run/uwsgi/newdjangosite-{0}.reload'.format(config))
Beispiel #5
0
def _update_source(conn: Connection, repo_dir: str, branch: str):
    directory(conn, repo_dir, group=WEBADMIN_GROUP, mode='ug+w', sudo=True)
    with conn.cd(repo_dir):
        conn.run('sudo git fetch origin')
        conn.run('sudo git reset --hard origin/{0}'.format(branch))
Beispiel #6
0
def _run_tests(conn: Connection, config: str, web_dir: str,
               virtualenv_python: str):
    with conn.cd(web_dir):
        conn.run('{0} manage_{1}.py test'.format(virtualenv_python, config))
Beispiel #7
0
def _update_database(conn: Connection, config: str, web_dir: str,
                     virtualenv_python: str):
    with conn.cd(web_dir):
        conn.sudo('{0} manage_{1}.py migrate'.format(virtualenv_python,
                                                     config))