update librarian
[wolnelektury.git] / fabfile.py
1 # -*- coding: utf-8 -*-
2 from fnpdeploy import *
3
4 try:
5     from fabfile_local import *
6 except ImportError:
7     pass
8
9
10 env.project_name = 'wolnelektury'
11
12
13 class ManageTask(Task):
14     def __init__(self, name, params='', **kwargs):
15         super(ManageTask, self).__init__(**kwargs)
16         self.name = name
17         self.params = params
18
19     def run(self):
20         require('app_path', 'project_name')
21         with cd(get_django_root_path('current')):
22             run('source %(ve)s/bin/activate && python manage.py %(task)s %(params)s' % {
23                 've': env.ve,
24                 'task': self.name,
25                 'params': self.params,
26             }, pty=True)
27
28
29 class Memcached(Service):
30     def run(self):
31         print '>>> memcached: restart'
32         sudo('service memcached restart', shell=False)
33
34
35 @task
36 def production():
37     env.hosts = ['giewont.icm.edu.pl']
38     env.user = 'lektury'
39     env.app_path = '/srv/wolnelektury.pl'
40     env.django_root_path = 'src'
41     env.requirements_file = 'requirements/requirements.txt'
42     env.pre_collectstatic = [
43         ManageTask('update_counters'),
44         ManageTask('localepack', '-c'),
45     ]
46     env.services = [
47         Supervisord('wolnelektury'),
48         Supervisord('wolnelektury.celery'),
49         Memcached(),
50     ]
51
52
53 @task
54 def beta():
55     env.hosts = ['giewont.icm.edu.pl']
56     env.user = 'lektury'
57     env.app_path = '/srv/wolnelektury.pl/beta'
58     env.ve = '/srv/wolnelektury.pl/ve'
59     env.django_root_path = 'src'
60     env.requirements_file = 'requirements/requirements.txt'
61     env.pre_collectstatic = [
62         ManageTask('update_counters'),
63         ManageTask('localepack', '-c'),
64     ]
65     env.services = [
66         Supervisord('beta'),
67     ]
68
69
70 @task
71 def staging():
72     env.hosts = ['san.nowoczesnapolska.org.pl:2223']
73     env.user = 'staging'
74     env.app_path = '/home/staging/wolnelektury.pl'
75     env.services = [
76         DebianGunicorn('wolnelektury'),
77     ]