def nginx_setup(): """ Updates nginx config and restarts nginx. """ name = env.conf['INSTANCE_NAME'] utils.upload_config_template('nginx.config', '/etc/nginx/sites-available/%s' % name, use_sudo=True) with settings(warn_only=True): sudo('ln -s /etc/nginx/sites-available/%s /etc/nginx/sites-enabled/%s' % (name, name)) nginx_start()
def redis_setup(): """ Setups Redis """ utils.upload_config_template('redis.conf', '/etc/redis/redis.conf', use_sudo=True) sudo('update-rc.d redis-server defaults') redis_restart()
def apache_make_config(): """ Updates apache config. """ _apache_setup_port() name = env.conf['INSTANCE_NAME'] utils.upload_config_template('apache.config', '/etc/apache2/sites-available/%s' % name, use_sudo=True) sudo('a2ensite %s' % name)
def upload_wsgi(self): """ Uploads wsgi deployment script. """ wsgi_dir = self.get_wsgi_dir() run('mkdir -p ' + wsgi_dir) utils.upload_config_template( self.wsgi, posixpath.join(wsgi_dir, self.get_wsgi_file_name()) )
def upload_config(self): """ Updates apache config. """ name = self._get_server_config_name() utils.upload_config_template(self.config, '/etc/apache2/sites-available/%s' % name, extra_context={'CURRENT_BACKEND': self}, use_sudo=True) sudo('a2ensite %s' % name)
def update_config(self): """ Updates nginx config and restarts nginx. """ name = self._get_server_config_name() utils.upload_config_template(self.config, '/etc/nginx/sites-available/%s' % name, use_sudo=True) with settings(warn_only=True): sudo('ln -s /etc/nginx/sites-available/%s /etc/nginx/sites-enabled/%s' % (name, name)) sudo('invoke-rc.d nginx restart')
def nginx_setup(): """ Updates nginx config and restarts nginx. """ name = env.conf['INSTANCE_NAME'] utils.upload_config_template('nginx.config', '/etc/nginx/sites-available/%s' % name, use_sudo=True) with settings(warn_only=True): sudo( 'ln -s /etc/nginx/sites-available/%s /etc/nginx/sites-enabled/%s' % (name, name)) nginx_start()
def celerybeat_setup(): """ Setups Celerybeat. """ utils.upload_config_template('celerybeat.sh', '/etc/init.d/celerybeat_%s' % env.conf['INSTANCE_NAME'], use_sudo=True) if not files.exists('/etc/init.d/celeryd_%s' % env.conf['INSTANCE_NAME']): print "You must setup “celeryd” before “celerybeat”!!!" return sudo('chmod +x /etc/init.d/celerybeat_%s' % env.conf['INSTANCE_NAME']) sudo('update-rc.d celerybeat_%s defaults' % env.conf['INSTANCE_NAME']) celerybeat_start()
def uwsgi_setup(): """ Setups uWSGI. """ name = env.conf['INSTANCE_NAME'] sudo('adduser --system --no-create-home --disabled-login --disabled-password --group uwsgi') sudo('mkdir -p /var/log/uwsgi') sudo('chown uwsgi: /var/log/uwsgi') utils.upload_config_template('uwsgi.sh', '/etc/init.d/uwsgi-%s' % name, use_sudo=True) sudo('chmod +x /etc/init.d/uwsgi-%s' % name) sudo('update-rc.d uwsgi-%s defaults' % name) uwsgi_restart()
def celery_setup(): """ Setups Celery. """ sudo('adduser --system --no-create-home --disabled-login --disabled-password --group celery') utils.upload_config_template('celeryd.sh', '/etc/init.d/celeryd', use_sudo=True) utils.upload_config_template('celeryd.conf', '/etc/default/celeryd', use_sudo=True) sudo('mkdir -p /var/log/celery') sudo('chmod 777 /var/log/celery') sudo('chmod +x /etc/init.d/celeryd') sudo('update-rc.d celeryd defaults') celery_start()
def uwsgi_setup(): """ Setups uWSGI. """ name = env.conf['INSTANCE_NAME'] sudo( 'adduser --system --no-create-home --disabled-login --disabled-password --group uwsgi' ) sudo('mkdir -p /var/log/uwsgi') sudo('chown uwsgi: /var/log/uwsgi') utils.upload_config_template('uwsgi.sh', '/etc/init.d/uwsgi-%s' % name, use_sudo=True) sudo('chmod +x /etc/init.d/uwsgi-%s' % name) sudo('update-rc.d uwsgi-%s defaults' % name) uwsgi_restart()
def configure(self): upload_config_template('hgrc', env.conf.SRC_DIR + '/.hg/hgrc', skip_unexistent=True)
def pip_setup_conf(): """ Sets up pip.conf file """ run('mkdir -p .pip') utils.upload_config_template('pip.conf', env.conf.HOME_DIR + '/.pip/pip.conf', skip_unexistent=True)
def profile_template(): """Installs profile (shell) template.""" upload_config_template("profile", "~/.profile", use_sudo=False)
def configure(): upload_config_template('hgrc', env.conf.SRC_DIR + '/.hg/hgrc', skip_unexistent=True)
def apache_make_wsgi(): """ Uploads wsgi deployment script. """ wsgi_dir = env.conf['ENV_DIR'] + '/var/wsgi/' run('mkdir -p ' + wsgi_dir) file_name = env.conf['INSTANCE_NAME'] + '.py' utils.upload_config_template('django_wsgi.py', wsgi_dir + file_name)
def do_setup_conf(): run('mkdir --parents %s.pip' % home_dir) utils.upload_config_template('pip.conf', home_dir + '.pip/pip.conf', skip_unexistent=True)