Beispiel #1
0
"""

from deployer.host import LocalHost
from deployer.node import Node


class example_settings(Node):
    # Run everything on the local machine
    class Hosts:
        host = {LocalHost}

    # A nested node with some examples.
    class examples(Node):
        def say_hello(self):
            self.hosts.run('echo hello world')

        def directory_listing_in_superuser_home(self):
            self.hosts.sudo('ls ~')

        def return_hello_world(self):
            return 'Hello world'

        def raise_exception(self):
            raise Exception('Custom exception')


if __name__ == '__main__':
    # Start an interactive shell.
    from deployer.client import start
    start(example_settings)
Beispiel #2
0
        with self.hosts.cd(self.preciosa_project):
            self.hosts.run('%s install -r requirements.txt' % self.pip)

    def edit_local_settings(self):
        with self.hosts.cd(self.preciosa_project):
            self.hosts.run('vim preciosa/local_settings.py')
        self.restart()

    def debug(self, port='8000'):
        self.hosts.run('sudo supervisorctl stop preciosa')
        self.hosts.run('sudo service nginx stop')
        self.django_command('runserver %s:%s' % (self.ip, port))
        self.hosts.run('sudo service nginx start')
        self.hosts.run('sudo supervisorctl start preciosa')

    def update(self, branch='develop'):
        with self.hosts.cd(self.preciosa_project):
            self.hosts.run('git fetch')
            self.hosts.run('git reset --hard origin/%s' % branch)

    def deploy(self, branch='develop'):
        self.update(branch)
        self.pip_update()
        # self.django_command('migrate')
        self.restart()


if __name__ == '__main__':
    from deployer.client import start
    start(Preciosa)
Beispiel #3
0
        with self.host.prefix(self.activate_cmd):
            # Cd to the place where we have our 'manage.py' file.
            with self.host.cd('~/git/django-project/'):
                self.host.run('./manage.py {}'.format(command))

    def django_shell(self):
        """ Open interactive Django shell. """
        self.run_management_command('shell')

    def install_gunicorn(self):
        """ Install gunicorn inside the virtualenv. """
        self.install_package('gunicorn')

    def install_supervisord(self):
        """ Install supervisord inside the virtualenv. """
        self.install_package('supervisor')

    def run_gunicorn(self):
        """ Run the gunicorn server """
        self.run_management_command('run_gunicorn')

    def upload_supervisor_config(self):
        """ Upload the content of the variable 'supervisor_config' in the
        supervisord configuration file. """
        with self.host.open('/etc/supervisor/conf.d/django-project.conf') as f:
            f.write(supervisor_config)


if __name__ == '__main':
    start(DjangoDeployment)
Beispiel #4
0
        try:
            self.hosts.sudo(cmd)
        except:
            pass

    def setproductionsettings(self):
        self.hosts.sudo('touch /etc/production.txt')
        self.hosts.sudo(
            "echo 'x3h)318k2awulf%&e@z08!tswh21&tbt!wdya4osy5o797l_7(' >> /etc/production.txt"
        )
        self.hosts.sudo('echo "dbbackupbksys" >> /etc/production.txt')
        self.hosts.sudo(
            'echo "CkD5/KNWSF/BV4sM0XcnyrfBgPmZXjQW4i/FR4l2wX2Mn/PMZtZ/5u9D2wP6JUpXHDyJUwDtaiAECnuOYBPmfw==" >> /etc/production.txt'
        )
        self.hosts.sudo('echo "bksysdb" >> /etc/production.txt')


class remote_host(SSHHost):
    address = ip
    username = '******'
    key_filename = keyLocation


class DjangoDeploymentOnHost(DjangoDeployment):
    class Hosts:
        host = remote_host


if __name__ == '__main__':
    start(DjangoDeploymentOnHost)
Beispiel #5
0
#!/usr/bin/env python
from deployer.client import start
from deployer.node import Node

class DjangoDeployment(Node):
    pass

if __name__ == '__main':
    start(DjangoDeployment)
Beispiel #6
0
        """update requirements.txt"""
        with self.hosts.cd(self.preciosa_project):
            self.hosts.run('%s install -r requirements.txt' % self.pip)

    def edit_local_settings(self):
        with self.hosts.cd(self.preciosa_project):
            self.hosts.run('vim preciosa/local_settings.py')
        self.restart()

    def debug(self, port='8000'):
        self.hosts.run('sudo supervisorctl stop preciosa')
        self.hosts.run('sudo service nginx stop')
        self.django_command('runserver %s:%s' % (self.ip, port))
        self.hosts.run('sudo service nginx start')
        self.hosts.run('sudo supervisorctl start preciosa')

    def update(self, branch='develop'):
        with self.hosts.cd(self.preciosa_project):
            self.hosts.run('git fetch')
            self.hosts.run('git reset --hard origin/%s' % branch)

    def deploy(self, branch='develop'):
        self.update(branch)
        self.pip_update()
        # self.django_command('migrate')
        self.restart()

if __name__ == '__main__':
    from deployer.client import start
    start(Preciosa)
Beispiel #7
0
            self.hosts.run('git stash pop')

    def pip_install(self):
        with self.hosts.cd(PROJECT_DIRECTORY):
            self.hosts.run("'%s' install -r requirements.txt" % esc1(PIP))

    def django_manage(self, command):
        with self.hosts.cd(PROJECT_DIRECTORY):
            self.hosts.run("'%s' manage.py %s" % (esc1(PYTHON), command))

    def django_collectstatic(self):
        self.django_manage('collectstatic --noinput')

    def django_migrate(self):
        self.django_manage('migrate')

    def restart_app(self):
        self.hosts.sudo("sv restart '%s'" % (esc1(RUNIT_SERVICE),))

    def deploy(self):
        self.git_fetch()
        self.git_checkout()
        self.pip_install()
        self.django_collectstatic()
        self.django_migrate()
        self.restart_app()


if __name__ == '__main__':
    start(AdvreportTestProjectDeployment)
from deployer.host import LocalHost
from deployer.node import Node


class example_settings(Node):
    # Run everything on the local machine
    class Hosts:
        host = {LocalHost}

    # A nested node with some examples.
    class examples(Node):
        def say_hello(self):
            self.hosts.run("echo hello world")

        def directory_listing_in_superuser_home(self):
            self.hosts.sudo("ls ~")

        def return_hello_world(self):
            return "Hello world"

        def raise_exception(self):
            raise Exception("Custom exception")


if __name__ == "__main__":
    # Start an interactive shell.
    from deployer.client import start

    start(example_settings)