Base payment scheme.
[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('/etc/init.d/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     ]
45     env.services = [
46         Supervisord('wolnelektury'),
47         Supervisord('wolnelektury.celery'),
48         Memcached(),
49     ]
50
51
52 @task
53 def beta():
54     env.hosts = ['giewont.icm.edu.pl']
55     env.user = 'lektury'
56     env.app_path = '/srv/wolnelektury.pl/beta'
57     env.ve = '/srv/wolnelektury.pl/ve'
58     env.django_root_path = 'src'
59     env.requirements_file = 'requirements/requirements.txt'
60     env.pre_collectstatic = [
61         ManageTask('update_counters'),
62     ]
63     env.services = [
64         Supervisord('beta'),
65     ]
66
67
68 @task
69 def staging():
70     env.hosts = ['san.nowoczesnapolska.org.pl:2223']
71     env.user = 'staging'
72     env.app_path = '/home/staging/wolnelektury.pl'
73     env.services = [
74         DebianGunicorn('wolnelektury'),
75     ]