Ejemplo n.º 1
0
def start():
    helpers.check_minimum_requirements()
    sudo('python %(current_path)s/%(project)s/manage.py '
            'runfcgi --settings=%(django_settings)s host=%(fcgi_host)s '
            'port=%(fcgi_port)s protocol=%(fcgi_protocol)s '
            'outlog=%(fcgi_outlog)s '
            'errlog=%(fcgi_errlog)s '
            'debug=%(fcgi_debug)s '
            'pidfile=%(fcgi_pidfile)s' % env, user=env.sudo_user)
Ejemplo n.º 2
0
def update_code():
    helpers.check_minimum_requirements()
    env.previous_revision = sudo("cat %(current_path)s/%(project)s/REVISION" % env, user=env.sudo_user)
    helpers.add_rollback("Restoring to previous REVISION", lambda: _restore_revision(env.previous_revision))
    # update the now warm repository to the latest code, pointless if we've
    # just cloned
    with cd("%(current_path)s/%(project)s" % env):
        sudo("git pull", user=env.sudo_user)
        # store the BRANCH and REVISION in a local file for future reference
        # when the shit certainly sometime will hit the fan
        sudo("echo %(branch)s > BRANCH" % env, user=env.sudo_user)
        sudo("echo `git rev-list --max-count=1 deploy` > REVISION" % env, user=env.sudo_user)
Ejemplo n.º 3
0
def checkout_code():
    """
    Do a git clone or pull depending on whether this is a cold deploy or not
    """
    helpers.check_minimum_requirements()
    
    # remove the newest release completely if something goes wrong
    helpers.add_rollback("Removing checkout of project '%(current_release)s'" % env, 
                            lambda: sudo("rm -rf %(current_release)s" % env, user=env.sudo_user))
    
    # FIXME:    this is hacky, we should have a file.exists() type if function
    #           to check the server if a file exists
    
    # run a check to see if we've already got a repository checked out
    cold_check = run("if [ -d %(shared_path)s/repositories/%(project)s ]; then "
                    "echo 'warm'; "
                "else "
                    "echo 'cold'; fi" % env)
    
    # FIXME:    this probably needs to be split into two different functions,
    #           one that does 'git clone' and the other that does 'git pull'
    
    # if it's a cold start then checkout the full repository and switch to the 
    # deploy branch
    if cold_check == "cold":
        sudo("git clone %(repository)s %(shared_path)s/repositories/%(project)s" % env, user=env.sudo_user)
    
    # update the now warm repository to the latest code, pointless if we've
    # just cloned
    with cd("%(shared_path)s/repositories/%(project)s" % env):
        sudo("git pull", user=env.sudo_user)
    
    # create the release path
    sudo("mkdir -p %(current_release)s/%(project)s" % env, user=env.sudo_user)
    # copy it to the current release path
    sudo("cp -RPp %(shared_path)s/repositories/%(project)s %(current_release)s/" % env, user=env.sudo_user)
    with cd("%(current_release)s/%(project)s" % env):
        # create a new local deploy branch, tracking the development/production 
        # branches in origin
        sudo("git checkout -b deploy origin/%(branch)s" % env, user=env.sudo_user)
        # store the BRANCH and REVISION in a local file for future reference
        # when the shit certainly sometime will hit the fan
        sudo("echo %(branch)s > BRANCH" % env, user=env.sudo_user)
        sudo("echo `git rev-list --max-count=1 deploy` > REVISION" % env, user=env.sudo_user)
Ejemplo n.º 4
0
def copy_settings_file(file_name):
    # def remove_settings_files_rollback():
    #     sudo("rm -rf %(current_path)s/%(project)s/environments/live/%(branch)s.py" % env, user=env.sudo_user)
    #     sudo("rm -rf %(current_path)s/%(project)s/environments/live/testing.py" % env, user=env.sudo_user)
    # helpers.add_rollback("Removing settings files", remove_settings_files_rollback)
    helpers.check_minimum_requirements()
    run("mkdir -p ~/fabrictmp")
    put(
        "~/Documents/Repositories/txtalert/environments/live/%s" % file_name,
        "~/fabrictmp/%s" % file_name
    )
    sudo(
        "cp ~/fabrictmp/%s "
        "%s/%s/environments/live/%s" % (
            file_name,
            env.current_path,
            env.project,
            file_name
        ), 
        user=env.sudo_user
    )
    run("rm ~/fabrictmp/%s" % file_name)
    run("rmdir ~/fabrictmp")
Ejemplo n.º 5
0
def stop():
    helpers.check_minimum_requirements()
    sudo('if [ -f %(fcgi_pidfile)s ]; then kill -HUP `cat %(fcgi_pidfile)s`; fi' % env, user=env.sudo_user)