|
2 | 2 | import os
|
3 | 3 |
|
4 | 4 | from fabric.api import local, run, cd, prefix, env, sudo, settings, shell_env
|
5 |
| -from deploy import server |
6 |
| - |
7 |
| -env.host_string = '{user}@{host}:{port}'.format( |
8 |
| - user=env.pycon_user, |
9 |
| - host=env.pycon_host, |
10 |
| - port=env.pycon_port |
11 |
| - ) |
12 | 5 |
|
| 6 | +env.use_ssh_config = True |
| 7 | +env.user = 'pyconkr' |
| 8 | +env.hosts = ['pythonkorea1'] |
13 | 9 |
|
14 | 10 | def deploy(target='dev', sha1=None):
|
15 | 11 | if sha1 is None:
|
16 | 12 | # get current working git sha1
|
17 | 13 | sha1 = local('git rev-parse HEAD', capture=True)
|
18 | 14 | # server code reset to current working sha1
|
19 |
| - home_dir = '/home/pyconkr/{target}.pycon.kr/pyconkr-2016'.format(target=target) |
| 15 | + home_dir = '/home/pyconkr/{target}.pycon.kr/pyconkr-2017'.format(target=target) |
20 | 16 |
|
21 | 17 | if target == 'dev':
|
22 |
| - python_env = '/home/pyconkr/.pyenv/versions/pyconkr-2016-dev' |
| 18 | + python_env = '/home/pyconkr/.pyenv/versions/pyconkr-2017-dev' |
23 | 19 | else:
|
24 |
| - python_env = '/home/pyconkr/.pyenv/versions/pyconkr-2016' |
| 20 | + python_env = '/home/pyconkr/.pyenv/versions/pyconkr-2017' |
25 | 21 |
|
26 | 22 | with settings(cd(home_dir), shell_env(DJANGO_SETTINGS_MODULE='pyconkr.settings_prod')):
|
27 |
| - sudo('git fetch --all -p', user='pyconkr') |
28 |
| - sudo('git reset --hard ' + sha1, user='pyconkr') |
29 |
| - sudo('bower install', user='pyconkr') |
30 |
| - sudo('%s/bin/pip install -r requirements.txt' % python_env, user='pyconkr') |
31 |
| - sudo('%s/bin/python manage.py compilemessages' % python_env, user='pyconkr') |
32 |
| - sudo('%s/bin/python manage.py migrate' % python_env, user='pyconkr') |
33 |
| - sudo('%s/bin/python manage.py collectstatic --noinput' % python_env, user='pyconkr') |
| 23 | + run('git fetch --all -p') |
| 24 | + run('git reset --hard ' + sha1) |
| 25 | + run('bower install') |
| 26 | + run('%s/bin/pip install -r requirements.txt' % python_env) |
| 27 | + run('%s/bin/python manage.py compilemessages' % python_env) |
| 28 | + run('%s/bin/python manage.py migrate' % python_env) |
| 29 | + run('%s/bin/python manage.py collectstatic --noinput' % python_env) |
34 | 30 | # worker reload
|
35 |
| - run('echo r > /var/run/pyconkr-2016-%s.fifo' % target) |
| 31 | + run('echo r > /var/run/pyconkr-2017-%s.fifo' % target) |
36 | 32 |
|
37 |
| -def flatpages_mig(direction='www'): |
38 |
| - dev_env = '/home/pyconkr/.pyenv/versions/pyconkr-2016-dev/bin/python' |
39 |
| - www_env = '/home/pyconkr/.pyenv/versions/pyconkr-2016/bin/python' |
40 |
| - from_env, to_env = (dev_env, www_env) if direction=='www' else (www_env, dev_env) |
41 |
| - dev_dir = '/home/pyconkr/dev.pycon.kr/pyconkr-2016' |
42 |
| - www_dir = '/home/pyconkr/www.pycon.kr/pyconkr-2016' |
43 |
| - from_dir, to_dir = (dev_dir, www_dir) if direction=='www' else (www_dir, dev_dir) |
44 |
| - with settings(cd(from_dir), |
45 |
| - shell_env(DJANGO_SETTINGS_MODULE='pyconkr.settings_prod') |
46 |
| - ): |
47 |
| - sudo('{python} manage.py dumpdata --indent 2 flatpages -o {fixture_to}'.format( |
48 |
| - fixture_to=os.path.join(to_dir, 'pyconkr', 'fixtures', 'flatpages.json'), |
49 |
| - python=from_env)) |
50 |
| - with settings(cd(to_dir), |
51 |
| - shell_env(DJANGO_SETTINGS_MODULE='pyconkr.settings_prod') |
52 |
| - ): |
53 |
| - sudo('{python} manage.py loaddata flatpages'.format( |
54 |
| - python=to_env)) |
0 commit comments