Merge branch 'master' of bitbucket.org:ronnyabraham/fabric

This commit is contained in:
Ronny Abraham 2017-08-08 17:27:01 +03:00
commit 64dea753cb
3 changed files with 155 additions and 1 deletions

View file

@ -193,6 +193,151 @@ def bootstrap():
db.init() db.init()
@task
def bootstrap_part1():
# import database as db
# configuration = env.config
# if env.debug:
# logger = loggify('deploy', 'bootstrap_part1')
#
# not doing a full sync, because we have to set up the rootpath,
# virtualenv, files, dir structure, etc. This means we aren't
# going to upload gunicorn and supervisor until after we've done
# everything else at the end of the bootstrapping process
sync(full=False)
# continue setting up the rootpath and virtualenv
setup_rootpath()
setup_virtualenv()
@task
def bootstrap_part2():
import database as db
configuration = env.config
if env.debug:
logger = loggify('deploy', 'bootstrap')
# create the django project
from django import create_project
create_project()
#
# link virtualenv to rootpath/private/virtualenv
src_virtual = configuration.virtualenv.paths.root
dst_virtual = configuration.paths.server.virtual
#
# link templates to rootpath/private/templates
src_templates = configuration.paths.django.templates
dst_templates = configuration.paths.server.django.templates
#
# link the django code in the project directory to the appropriate location
# in the rootpath directory
src_code = configuration.paths.django.root
dst_code = configuration.paths.server.django.code
#
# I corrected the linking code so that it deletes already existing
# links before creating them, otherwise you get really weird errors
# where the a link is recreated within the destination link
from utils import link_create
if env.debug:
logger.debug("virtualenv.root : %s"
% configuration.virtualenv.paths.root)
logger.debug("virtualenv.bin : %s\n" %
configuration.virtualenv.paths.bin)
logger.debug("paths.server\n")
logger.debug(" - root\t: %s" % configuration.paths.server.root)
logger.debug(" - media\t: %s" %
configuration.paths.server.media.static)
logger.debug(" - virtual\t: %s" % configuration.paths.server.virtual)
logger.debug(" - django.code\t: %s\n" %
configuration.paths.server.django.code)
logger.debug("django templates : %s" %
configuration.paths.django.templates)
logger.debug("django root : %s" %
configuration.paths.django.root)
logger.debug("django settings : %s" %
configuration.paths.django.settings.root)
logger.debug("django local : %s" %
configuration.paths.django.settings.local)
logger.debug(link_create(src_virtual, dst_virtual, debug=True))
logger.debug(link_create(src_templates, dst_templates, debug=True))
logger.debug(link_create(src_code, dst_code, debug=True))
else:
link_create(src_virtual, dst_virtual)
link_create(src_templates, dst_templates)
link_create(src_code, dst_code)
#
# create and link the scripts that manage the server
# e.g. nginx, supervisor, gunicorn
from nginx import upload as upload_nginx
from supervisor import upload as upload_supervisor
from django import generate as django_generate
print_console("creating gunicorn script")
django_generate('gunicorn', True)
django_generate('local', True)
print_console("creating supervisor script")
upload_supervisor()
print_console("creating nginx script")
upload_nginx()
#
# instantiate docker containers if any
import docker
print_console("check to see if docker containers are used")
if hasattr(configuration, "docker"):
print_console("generating docker configuration file")
docker.generate()
print_console("creating and starting docker container")
docker.create()
else:
print_console("no docker containers are being used. pass")
#
# create and initialize the database
print_console("in db.generate")
db.generate()
print_console("in db.init")
db.init()
@task @task
def sync(full=True, extras=False): def sync(full=True, extras=False):

View file

@ -58,7 +58,7 @@ def bootstrap_pip():
""" """
bootstraps pip bootstraps pip
""" """
upgrade() # upgrade()
setup() setup()

View file

@ -0,0 +1,9 @@
# useful regex commands
## convert href to static
`.s/href="\([^"]\+\)"/href="{% static '\1' %}"`
use when **href="/some/link/file.css"** if the
quotes are single quotes, then convert them to double