Commit b3a51d99 authored by Christophe Siraut's avatar Christophe Siraut
Browse files

Autodeploy with fabric. (wip)

parent 253d0fd2
#!/usr/bin/env python
'''Download/sync to git repository
Create/update virtualenv
django syncdb collectstatic'''
import os
from fabric.api import env, local, run, settings, cd, lcd, sudo
import sys
if sys.version_info[:2] == (2, 6):
from contextlib import nested
name = 'flyers'
repository = '' % name
directory = os.path.abspath(os.path.join(os.path.dirname(__file__), name))
def prod():
env.user = 'chris'
env.hosts = ['']
env.port = 3265
global directory
directory = '/var/alternc/html/c/chris/test'
def deploy_remote():
with settings(warn_only=True):
if sudo("test -d %s" % directory).failed:
sudo("git clone %s %s" % (repository, directory))
with settings(warn_only=True), cd(directory):
if sudo("test -d %s/env" % directory).failed:
sudo('virtualenv env')
run('echo "currently web folders are not owned by their owners"')
with cd(directory):
sudo('git pull')
sudo('touch %s/' % name)
#sudo('chown -R www-data .')
sudo('mkdir -p media/uploads')
sudo('env/bin/pip install -r requirements.txt')
sudo('env/bin/python collectstatic --noinput')
sudo('env/bin/python syncdb --noinput')
def deploy_local():
with settings(warn_only=True):
if local("test -d %s" % directory).failed:
local("git clone %s %s" % (repository, directory))
with lcd(directory):
local('git pull')
local('touch %s/' % name)
def deploy():
if env.hosts:
if __name__ == "__main__":
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
fastcgiconfig for django-flyer. fastcgiconfig for django-flyer.
""" """
import os import os
path = os.path.dirname(os.path.realpath(__file__)) #path = os.path.dirname(os.path.realpath(__file__))
#sys.path.insert(0, path) #sys.path.insert(0, path)
#sys.path.insert(1, os.path.join('path/virtualenv')) #sys.path.insert(1, os.path.join('path/virtualenv'))
os.environ['DJANGO_SETTINGS_MODULE'] = "flyers.settings" os.environ['DJANGO_SETTINGS_MODULE'] = "flyers.settings"
from django.core.servers.fastcgi import runfastcgi from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false") runfastcgi(method="threaded")
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment