def push(*args, **kwargs): allowed_args = set( ['notest', 'syncdb', 'migrate', 'pip_update', 'norestart']) for arg in args: if arg not in allowed_args: puts('Invalid argument: %s' % arg) puts('Valid arguments are: %s' % allowed_args) return vcs.push() delete_pyc() with cd('src/' + env.conf['INSTANCE_NAME']): vcs.up() if 'pip_update' in args: pip_update(restart=False) if 'syncdb' in args: dj_cmd.syncdb() if 'migrate' in args: dj_cmd.migrate() dj_cmd.collectstatic() dj_cmd.manage('compress') # execute 'before_restart' callback kwargs.get('before_restart', lambda: None)() if 'norestart' not in args: uwsgi.uwsgi_reload() celery.celery_restart()
def deploy_project(tagname, force=False, username="******"): """ Deploys project on prepared server. """ make_src_dir(username=username) tag_dir = os.path.join(fabric.api.env.conf['SRC_DIR'], tagname) if fabric.contrib.files.exists(tag_dir): if force: fabric.api.warn(fabric.colors.yellow('Removing directory %s and all its contents.' % tag_dir)) fabric.api.run('rm -rf %s' % tag_dir) else: fabric.api.abort(fabric.colors.red('Tagged directory already exists: %s' % tagname)) if tagname == 'trunk': vcs.push(tagname) else: #fabric.api.local('rm -rf %s' % tmp_tag)) #with fabric.api.lcd('/tmp'): # vcs.export(tagname, local=True) tmp_tag = os.path.join('/tmp', '%s' % (tagname)) if not os.path.isdir(tmp_tag): fabric.api.puts(fabric.colors.green('Exporting tag %s to %s' % (tagname, tmp_tag))) vcs.export(tagname, export_dir=tmp_tag, local=True) else: fabric.api.warn(fabric.colors.yellow('Using existing export of tag %s at %s' % (tagname, tmp_tag))) fabric.contrib.project.rsync_project( local_dir=tmp_tag, remote_dir=fabric.api.env.conf['SRC_DIR'], exclude=fabric.api.env.conf['RSYNC_EXCLUDE'], extra_opts='--links --perms') #fabric.api.local('rm -rf %s' % tmp_tag) virtualenv_create(dir=tag_dir) pip_install(dir=tag_dir) fabric.api.sudo('chown -R %s:%s /srv' % (username, username))
def push(*args, **kwargs): allowed_args = set(['notest', 'syncdb', 'migrate', 'pip_update', 'norestart']) for arg in args: if arg not in allowed_args: puts('Invalid argument: %s' % arg) puts('Valid arguments are: %s' % allowed_args) return vcs.push() delete_pyc() with cd('src/' + env.conf['INSTANCE_NAME']): vcs.up() if 'pip_update' in args: virtualenv.pip_update(restart=False) if 'syncdb' in args: dj_cmd.syncdb() if 'migrate' in args: dj_cmd.migrate() dj_cmd.collectstatic() dj_cmd.manage('compress') # execute 'before_restart' callback kwargs.get('before_restart', lambda: None)() if 'norestart' not in args: uwsgi.uwsgi_reload()
def deploy_project(tagname, force=False): """ Deploys project on prepared server. """ make_src_dir() tag_dir = os.path.join(fabric.api.env.conf['SRC_DIR'], tagname) if fabric.contrib.files.exists(tag_dir): if force: fabric.api.warn(fabric.colors.yellow('Removing directory %s and all its contents.' % tag_dir)) fabric.api.run('rm -rf %s' % tag_dir) else: fabric.api.abort(fabric.colors.red('Tagged directory already exists: %s' % tagname)) if tagname == 'trunk': vcs.push(tagname) else: fabric.api.local('rm -rf %s' % os.path.join('/tmp', tagname)) with fabric.api.lcd('/tmp'): vcs.export(tagname, local=True) fabric.contrib.project.rsync_project( local_dir = os.path.join('/tmp', tagname), remote_dir = fabric.api.env.conf['SRC_DIR'], exclude = fabric.api.env.conf['RSYNC_EXCLUDE'], extra_opts='--links --perms') fabric.api.local('rm -rf %s' % os.path.join('/tmp', tagname)) virtualenv_create(dir=tag_dir) pip_install(dir=tag_dir) fabric.api.sudo('chown -R ubuntu:ubuntu /srv')
def deploy_project(tagname, force=False): """ Deploys project on prepared server. """ make_src_dir() tag_dir = os.path.join(fabric.api.env.conf['SRC_DIR'], tagname) if fabric.contrib.files.exists(tag_dir): if force: fabric.api.warn( fabric.colors.yellow( 'Removing directory %s and all its contents.' % tag_dir)) fabric.api.run('rm -rf %s' % tag_dir) else: fabric.api.abort( fabric.colors.red('Tagged directory already exists: %s' % tagname)) if tagname == 'trunk': vcs.push(tagname) else: fabric.api.local('rm -rf %s' % os.path.join('/tmp', tagname)) with fabric.api.lcd('/tmp'): vcs.export(tagname, local=True) fabric.contrib.project.rsync_project( local_dir=os.path.join('/tmp', tagname), remote_dir=fabric.api.env.conf['SRC_DIR'], exclude=fabric.api.env.conf['RSYNC_EXCLUDE'], extra_opts='--links --perms') fabric.api.local('rm -rf %s' % os.path.join('/tmp', tagname)) virtualenv_create(dir=tag_dir) pip_install(dir=tag_dir) fabric.api.sudo('chown -R ubuntu:ubuntu /srv')
def _make_clone(self): """ Creates repository clone on remote server. """ run('mkdir -p ' + env.conf.SRC_DIR) with cd(env.conf.SRC_DIR): with settings(warn_only=True): vcs.init() vcs.push() with cd(env.conf.SRC_DIR): vcs.up() #self.update_config(restart=False) vcs.configure()
def make_clone(): """ Creates repository clone on remote server. """ run('mkdir -p ' + env.conf.SRC_DIR) with cd(env.conf.SRC_DIR): with settings(warn_only=True): vcs.init() vcs.push() with cd(env.conf.SRC_DIR): vcs.up() update_django_config(restart=False) vcs.configure()
def push(*args, **kwargs): ''' Run it instead of your VCS push command. The following strings are allowed as positional arguments: * 'notest' - don't run tests * 'syncdb' - run syncdb before code reloading * 'migrate' - run migrate before code reloading * 'pip_update' - run virtualenv.pip_update before code reloading * 'norestart' - do not reload source code Keyword arguments: * before_restart - callable to be executed after code uploading but before the web server reloads the code. Customization example can be found :ref:`here <fab-push-customization>`. ''' allowed_args = set( ['notest', 'syncdb', 'migrate', 'pip_update', 'norestart']) for arg in args: if arg not in allowed_args: puts('Invalid argument: %s' % arg) puts('Valid arguments are: %s' % allowed_args) return vcs.push() utils.delete_pyc() with cd('src/' + env.conf['INSTANCE_NAME']): vcs.up() if 'pip_update' in args: virtualenv.pip_update(restart=False) if 'syncdb' in args: dj_cmd.syncdb() if 'migrate' in args: dj_cmd.migrate() # execute 'before_restart' callback kwargs.get('before_restart', lambda: None)() if 'norestart' not in args: apache.touch() if 'notest' not in args: dj_cmd.test()
def push(self, *args, **kwargs): ''' Run it instead of your VCS push command. The following strings are allowed as positional arguments: * 'notest' - don't run tests * 'syncdb' - run syncdb before code reloading * 'migrate' - run migrate before code reloading * 'pip_update' - run virtualenv.update_r before code reloading * 'norestart' - do not reload source code Keyword arguments: * before_restart - callable to be executed after code uploading but before the web server reloads the code. Customization example can be found :ref:`here <fab-push-customization>`. ''' allowed_args = set(['notest', 'syncdb', 'migrate', 'pip_update', 'norestart']) for arg in args: if arg not in allowed_args: puts('Invalid argument: %s' % arg) puts('Valid arguments are: %s' % allowed_args) return vcs.push() utils.delete_pyc() with cd('src/' + env.conf['INSTANCE_NAME']): vcs.up() if 'pip_update' in args: self.update_r(restart=False) for app in self.apps.itervalues(): if 'syncdb' in args: app.syncdb() if 'migrate' in args: app.migrate() # execute 'before_restart' callback kwargs.get('before_restart', lambda: None)() for app in self.apps.itervalues(): if 'norestart' not in args: app.restart() if 'notest' not in args: app.test()