Stephan Jaekel avatar Stephan Jaekel committed 47c90f0

Moved deployment from epio to custom hosting.

Comments (0)

Files changed (4)

.epio-app

-pycd2012

.epioignore

-pyconde/site_media/
-pyconde/deployed_static_media/
-pyconde/settings.py
-setup.py.bak

epio.ini

-[wsgi]
-requirements = requirements.txt
-
-[symlinks]
-pyconde/settings.py = pyconde/conf/epio.py
-
-[services]
-postgres = true
-redis = false
-
-[django]
-base = pyconde
-append_settings = false
-
-[static]
-/site_media = ../data/media/
-/static_media = ../data/static/
-import os
+# -*- coding: utf-8 -*-
 from fabric.api import *
+from os.path import join
 
-def update():
-    localroot = os.path.dirname(__file__)
-    local('cd %s; pwd' % localroot)
-    local('cd %s;epio upload' % localroot)
-    local('cd %s;epio django -- syncdb' % localroot)
-    local('cd %s;epio django -- migrate' % localroot)
+
+env.hosts = ['pyconde00.gocept.net',]
+env.srv_user = 'pyconde'
+env.root = '/srv/pyconde/env_pyconde_2012'
+
+env.proj_name = 'pyconde'
+env.www_root = join(env.root, 'htdocs')
+env.proj_root = join(env.root, 'pycon_de_website')
+env.pip_files = (
+    join(env.proj_root, 'requirements.txt'),
+)
+env.manage_py = join(env.proj_root, env.proj_name, 'manage.py')
+
+
+def test_id():
+    srv_run('id')
+
+def srv_run(cmd):
+    return sudo(cmd, user=env.srv_user)
+
+def srv_open_shell(cmd):
+    return open_shell('sudo -u %s -s -- %s' % (env.srv_user, cmd))
+
+def ve_python(cmd):
+    return srv_run('%s %s' % (join(env.root, 'bin', 'python'), cmd))
+
+def manage_py(cmd):
+    return ve_python('%s %s' % (join(env.proj_root, env.proj_name, 'manage.py'), cmd))
+
+def supervisorctl(cmd):
+    return srv_run('%s %s' % (join(env.root, 'bin', 'supervisorctl'), cmd))
 
 def upgrade():
-    localroot = os.path.dirname(__file__)
-    update()
-    local('cd %s; epio django -- collectstatic --noinput' % localroot)
+    update_proj()
+
+    update_requirements()
+
+    syncdb()
+    migrate()
+
+    build_static_files()
+
+    restart_worker()
+
+def update():
+    update_proj()
+
+    syncdb()
+    migrate()
+
+    restart_worker()
+
+def syncdb():
+    manage_py('syncdb --noinput')
+
+def migrate():
+    manage_py('migrate')
+
+def update_requirements():
+    pip = join(env.root, 'bin', 'pip')
+    for reqfile in env.pip_files:
+        srv_run('%s install --use-mirrors -E %s -r %s' % (pip, env.root, reqfile))
+
+def update_proj():
+    srv_run('cd %s; git pull' % env.proj_root)
+
+def build_static_files():
+    manage_py('collectstatic --noinput -v1')
+
+def restart_worker():
+    return supervisorctl('restart pyconde')
+
+def djshell():
+    return srv_open_shell('%s %s shell' % (
+        join(env.root, 'bin', 'python'),
+        join(env.proj_root, env.proj_name, 'manage.py')))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.