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

This commit is contained in:
Ronny Abraham 2017-11-09 00:34:05 +02:00
commit 18871417e1
14 changed files with 239 additions and 9 deletions

View file

@ -295,18 +295,27 @@ class DeployMeta(QtGui.QMainWindow):
projectname=dquery.get('project.name'),
branchext=dquery.get('project.extension'))
virtualenv_name = "{projectname}_{branchext}".format(
projectname=dquery.get('project.name'),
branchext=dquery.get('project.extension'))
nested_path(
self.config_data, 'database.name', database_name)
nested_path(
self.config_data, 'virtualenv.name', dquery.get('project.name'))
self.config_data, 'virtualenv.name', virtualenv_name)
if self.currentbranch == 'development':
projectpath = "{projectname}.prj".format(
projectname=dquery.get('project.name'))
nested_path(
self.config_data, 'project.paths.home', projectpath)
nested_path(
self.config_data, 'virtualenv.name',
dquery.get('project.name'))
def add_widgetrow(self, key, grid):
row = grid.rowCount()

View file

@ -8,7 +8,7 @@ from utils import virtualenv_source, booleanize, loggify
from utils import print_console
from pip import setup_virtualenv
from pip import setup as pip_requirements
from pip import bootstrap_pip
import os
@ -78,8 +78,156 @@ def bootstrap():
setup_rootpath()
setup_virtualenv()
bootstrap_pip()
pip_requirements()
# 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
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

View file

@ -381,6 +381,11 @@ def generate_scripts(template_name, make_copy=False):
@task
def generate(param=None, make_copy=False):
"""
param can be one of settings, local, wsgi
make_copy must be set to True if you want it to actually do anthing
"""
SCRIPT_LIST = ['settings', 'local', 'wsgi']
PARAM_LIST = list(SCRIPT_LIST)
PARAM_LIST.append('gunicorn')
@ -396,6 +401,7 @@ def generate(param=None, make_copy=False):
print "django:generate make_copy : %s\n" % make_copy
print "django:generate script : %s" % param
if env.debug:
print "django:generate script : %s" % param
print "django:generate make_copy : %s\n" % make_copy
@ -408,7 +414,6 @@ def generate(param=None, make_copy=False):
if not param:
# this is where script=None, generate all scripts
for scriptkey in SCRIPT_LIST:
generate_scripts(scriptkey, make_copy)

View file

@ -349,6 +349,9 @@ def get_config(branchname):
dataobject.server.nginx.port = config['nginx']['port']
dataobject.server.nginx.socket = config['nginx']['socket']
print "DEBUG -- socket: %s" % dataobject.server.nginx.socket
if config['project']['host'] == "localhost":
dataobject.server.nginx.host = "{projectname}.{ext}".format(
ext=dataobject.project.extension,

View file

@ -98,6 +98,7 @@ def upload():
context['error_log'] = configuration.logging.nginx.error
context['port'] = configuration.server.nginx.port
context['socket'] = configuration.server.nginx.socket
context['django_host'] = configuration.server.django.host
context['django_port'] = configuration.server.django.port

View file

@ -53,6 +53,38 @@ def setup_virtualenv():
run(mkvirtualenv_cmd)
@task
def bootstrap_pip():
"""
bootstraps pip
"""
# upgrade()
setup()
@task
def upgrade():
"""
upgrade pip to latest version
"""
# configuration = env.config
if env.debug:
logging.basicConfig(
format='\n%(levelname)s: deploy.pip %(message)s',
level=logging.DEBUG)
pipinstall_cmd = "pip install --upgrade pip"
if env.debug:
logging.debug("with virtualenv(): run(\"\n\t%s\n\t\")" %
pipinstall_cmd)
else:
with virtualenv():
run(pipinstall_cmd)
@task
def setup():
"""

View file

@ -70,7 +70,7 @@ USE_DEBUG_TOOLBAR = DEBUG
# allow template debug outputs on {{ project_branch }} environment
INTERNAL_IPS = ['127.0.0.1', '127.0.0.2', '127.0.0.3', ]
ALLOWED_HOSTS = [configuration.project.extendedname, ]
ALLOWED_HOSTS = [configuration.project.extendedname, configuration.project.host]
# -----------------------------------------
# Debug logging to the console

View file

@ -22,7 +22,7 @@ maintenance:
nginx:
commands: {start: nginx, status: ps waux | grep nginx, stop: nginx -s stop}
editor: mvim
execute: local
execute: sudo
supervisor:
commands: {reload: supervisorctl reload, start: supervisorctl start, status: supervisorctl
status, stop: supervisorctl stop, update: supervisorctl update}

View file

@ -26,7 +26,8 @@ paths:
extras:
code: "extras/scripts/code"
fixtures: "extras/data/fixtures"
fixtures: "var/fixtures"
ssh: "share/ssh"
templates:
conf: "usr/etc"

View file

@ -264,8 +264,8 @@ add the following:
sudo pip install virtualenv
sudo pip install virtualenvwrapper
cat "WORKON_HOME=~/.virtualenvs" >> .bashrc
cat ". /usr/local/bin/virtualenvwrapper.sh" >> .bashrc
echo "WORKON_HOME=~/.virtualenvs" >> .bashrc
echo ". /usr/local/bin/virtualenvwrapper.sh" >> .bashrc
### install nginx

View file

@ -0,0 +1 @@
env LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix openssl)/include" pip install cryptography

View file

@ -0,0 +1 @@
xcode-select --install

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

View file

@ -0,0 +1,20 @@
##Sass
### How to set up sass watch with multiple directories
````
sass -I share/media/projectwide_sass_files
--watch code/apps/sassdir:code/apps/cssdir
````
### How to get vim to work with a sass file include
````
let g:syntastic_sass_sass_args="
-I /Full/share/media/projectwide_sass_files"
````
[fixing syntastic check args](http://stackoverflow.com/questions/29041876/fixing-syntasticcheck-bootstrap-error-vim-syntastic-plugin)
[syntastic manual](https://github.com/vim-syntastic/syntastic/blob/master/doc/syntastic.txt)