Skip to content

Commit

Permalink
Work in progress: tweaks for deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
Beau Hargis committed Aug 3, 2013
1 parent e8234c3 commit 6317bca
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 55 deletions.
4 changes: 2 additions & 2 deletions codalab/config/templates/freetds.conf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[global]
tds version = 8.0
tds version = 7.1
character set = UTF-8

[{{DB_SERVER}}]
port = {{DB_PORT}}
tds version = 8.0
tds version = 7.1
character set = UTF-8
host = {{DB_HOST}}
encryption = required
Expand Down
2 changes: 1 addition & 1 deletion codalab/config/templates/odbc.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ Database = {{DB_NAME}}
UID = {{DB_USER}}
PWD = {{DB_PASSWORD}}
Port = {{DB_PORT}}
TDS_Version = 8.0
TDS_Version = 7.1

2 changes: 1 addition & 1 deletion codalab/config/templates/odbcinst.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[ODBC]
Trace = Yes
Trace = No
TraceFile = /tmp/odbc-{{DB_NAME}}.log

[FreeTDS]
Expand Down
39 changes: 29 additions & 10 deletions codalab/fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,51 @@
VENV_PATH = os.path.join(THIS_DIR,'venv')
THIS_SETTINGS_DIR = os.path.join(THIS_DIR,'codalab','settings')

env.conf.DEPLOY_USER = 'wwwuser'
env.conf.DEPLOY_PATH = 'codalab_src'

def env_setup(config=env.CONFIG,settings_module='codalab.settings'):
if config is None:

sys.path.append('.')
os.environ['DJANGO_CONFIGURATION'] = config
os.environ["DJANGO_SETTINGS_MODULE"]= settings_module
os.environ["DJANGO_SETTINGS_MODULE"] = settings_module
from fabric.contrib import django

from configurations import importer

importer.install()
from fabric.contrib import django

django.settings_module(settings_module)
from django.conf import settings
from django.conf import settings as django_settings

#env.roledefs = settings.DEPLOY_ROLES
env.django_settings = settings
env_setup()
env.roledefs = django_settings.DEPLOY_ROLES
env.django_settings = django_settings

@task
def local():
def local(**kwargs):
env.run = lrun

env_setup(**kwargs)

@task
def remote():
def remote(**kwargs):
env.run = run
env_setup(**kwargs)

@task
def bootstrap_on_linux():
def clone_repo(repo_url='https://github.com/codalab/codalab.git',path=env.conf.DEPLOY_PATH):
env.run('git clone %s %s' % (repo_url, path))

@task
def provision(config='Dev'):
clone_repo()
with cd(env.conf.DEPLOY_PATH):
sudo('/bin/bash codalab/scripts/provision %s' % env.conf.DEPLOY_USER)
sudo('python manage.py config_gen --configuration=%s' % config,
user=env.conf.DEPLOY_USER)

@task
def bootstrap():
make_virtualenv(path='venv', system_site_packages=False)
with virtualenv('venv'):
run('pip install --upgrade pip')
Expand Down
7 changes: 6 additions & 1 deletion codalab/runserver
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
#!/bin/bash

THIS_DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
pushd `pwd` > /dev/null
cd $THIS_DIR

source ./config/generated/startup_env.sh
echo " .... "
echo "$DJANGO_CONFIGURATION Configuration"
echo " .... "
python manage.py runserver $1 $2
/bin/bash manage runserver "$@"
popd
29 changes: 0 additions & 29 deletions codalab/scripts/provision

This file was deleted.

22 changes: 11 additions & 11 deletions codalab/scripts/ubuntu/provision
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@
## This will eventually be a bit more configurable

THIS_DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
pushd `pwd` > /dev/null
pushd `pwd` 2>&1 > /dev/null
cd $THIS_DIR

U=$1

if [[ "$U" == "" ]] ; then
echo "Specify user"
exit 1
fi
if ! id -u "$U" > /dev/null; then
sudo useradd -m -s /bin/bash $U
sudo passwd $U
if [[ $U =~ [a-zA-Z0-9][\-\_a-zA-Z0-9]+[a-zA-Z0-9] ]] ; then
if ! id -u "$U" 2>&1 > /dev/null; then
echo "User will be added."
sudo useradd -m -s /bin/bash $U
sudo passwd $U
fi
else
echo "User not specified or username has bad characters"
exit 1
fi

echo "Installing codalab dependency meta-package..."
sudo dpkg -i *.deb > /dev/null && \
sudo apt-get -f install > /dev/null && \
echo "Updaing some user permissions..." && \
echo "Updaing some group permissions..." && \
sudo chgrp -R www-data /var/log/nginx /var/lib/nginx && \
sudo chmod -R g+rw /var/log/nginx /var/lib/nginx && \
sudo usermod -a -G www-data $U


popd > /dev/null

0 comments on commit 6317bca

Please sign in to comment.