Permalink
Browse files

changing how things are installed for the deployment

  • Loading branch information...
1 parent f71247d commit 3905959d5641e4f35a5e7497236a83624cd385a2 @robbles robbles committed Mar 8, 2012
Showing with 38 additions and 28 deletions.
  1. +38 −25 deployment/fabfile.py
  2. +0 −3 requirements.txt
View
@@ -8,17 +8,19 @@
"""
#The first thing we do is import the fabric libraries
-from fabric.api import env, hosts
-from fabric.operations import put, sudo
+from __future__ import with_statement
+from fabric.api import env, hosts, settings
+from fabric.operations import put, sudo, run
from fabric.context_managers import cd
+from fabric.contrib.files import exists
from os import path
import sys
#setup remote servers
env.user = 'vagrant'
env.password = 'vagrant'
# add remote host addresses here
-env.hosts = ['142.104.125.207:2222']
+env.hosts = ['142.104.215.106:2222']
github_repo_address = 'git://github.com/TeamGamma/directedstudies.git'
@@ -31,34 +33,44 @@ def deploy(server_type='web'):
sudo('apt-get update')
# ubuntu goodies
- sudo("""apt-get install --assume-yes build-essential python-pip python-dev python-mysqldb git-core sqlite3 apache2 libapache2-mod-wsgi""")
-
- #python goodies
- sudo('pip install -r requirements.txt')
+ sudo("""apt-get install --assume-yes build-essential python-pip python-dev python-mysqldb git-core sqlite3 apache2 libapache2-mod-wsgi python-mysqldb fabric""")
#clone git repository
- sudo('mkdir /srv/directedstudies')
- cd('/srv/directedstudies')
- sudo('git clone %s' % (github_repo_address))
+ sudo('mkdir -p /srv')
+
+ with cd('/srv'):
+ if not exists('directedstudies'):
+ sudo('git clone %s directedstudies' % (github_repo_address))
+
+ with cd('/srv/directedstudies/'):
+ sudo('git pull')
+ #python goodies
+ sudo('pip install -r directedstudies/requirements.txt')
+ sudo('pip install eventlet sql-alchemy')
+
+ run('cd /srv/directedstudies')
if server_type == 'web':
#start the web server
#configure apache for wsgi by copying the repo config to remote install
- put('config/apache/wsgi_configuration' '/etc/apache2/sites-available/')
+ sudo('cp /srv/directedstudies/deployment/config/apache/wsgi_configuration /etc/apache2/sites-available/')
#create a link to the enabled directory
- sudo("""ln -s /etc/apache2/sites-available/wsgi_configuration
- /etc/apache2/sites-enabled/wsgi_configuration_link""")
- #remove the original default link to avoid getting messed up
- sudo('rm /etc/apache2/sites-enabled/000-default')
+ sudo("""ln -s -f /etc/apache2/sites-available/wsgi_configuration /etc/apache2/sites-enabled/wsgi_configuration_link""")
+
+ sudo("mkdir -p /srv/directedstudies/logs")
#restart apache2 to configure
- sudo('service apache2 restart')
-
+ result = sudo('service apache2 restart', pty=False)
+
elif server_type == 'transaction':
+ #configure our libraries to act as packages?
+ with cd('/srv/directedstudies/'):
+ sudo('python setup.py develop')
+
#navigate to server and run it. nice and easy right?
- cd('/srv/directedstudies/sps/transactions/')
- sudo('python server.py')
+ with cd('/srv/directedstudies/sps/transactions/'):
+ sudo('python server.py')
elif server_type == 'database':
#start the database server
@@ -68,15 +80,16 @@ def deploy(server_type='web'):
#Configure the database server
#remove old config
- sudo('rm /etc/mysql/my.cnf')
+ sudo('rm -f /etc/mysql/my.cnf')
#replace with new
- sudo('rm config/mysql/my.cnf')
+ sudo('cp /srv/directedstudies/deployment/config/mysql/my.cnf /etc/mysql')
#run mysql and do the setup
- sudo ('echo "create database sps;" | mysql -h127.0.0.1 -uroot -proot')
- cd('/srv/directedstudies/')
- #use rob's fabfile to deal with setting up the tables
- sudo('fab setup_database')
+ with settings(warn_only=True):
+ sudo ('echo "create database sps;" | mysql -h127.0.0.1 -uroot -proot')
+ with cd('/srv/directedstudies/'):
+ #use rob's fabfile to deal with setting up the tables
+ sudo('fab setup_database')
else:
print 'invalid server type chosen'
View
@@ -1,11 +1,8 @@
-Fabric==1.3.4
Flask==0.8
Jinja2==2.6
SQLAlchemy==0.7.4
Werkzeug==0.8.2
supervisor==3.0a12
-MySQL-python==1.2.3c1
-eventlet==0.9.16
greenlet==0.3.4
nose==1.1.2
ipython==0.12

0 comments on commit 3905959

Please sign in to comment.