Guest User

Untitled

a guest
Dec 11th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. from fabric import *
  2.  
  3. PROJECT_DIR = '$HOME/websites/catte-api/cat_api'
  4. PROJECT_NAME = 'cat-api'
  5. SERVER_NAME = 'cattesapi'
  6.  
  7. env.hosts = ['fridayd.me']
  8.  
  9. def pull():
  10. with cd(PROJECT_DIR):
  11. run('git pull')
  12.  
  13. def install_packages():
  14. with cd(PROJECT_DIR):
  15. with prefix('workon %s' % PROJECT_NAME):
  16. run('pip install -r requirements/project.txt')
  17.  
  18. def sync_database():
  19. with cd(PROJECT_DIR):
  20. with prefix('workon %s' % PROJECT_NAME):
  21. run('./manage.py syncdb --noinput')
  22.  
  23. def migrate_database():
  24. with cd(PROJECT_DIR):
  25. with prefix('workon %s' % PROJECT_NAME):
  26. run('./manage.py migrate --noinput')
  27.  
  28. def stop_server():
  29. sudo('supervisorctl stop %s' % SERVER_NAME)
  30.  
  31. def start_server():
  32. sudo('supervisorctl start %s' % SERVER_NAME)
  33.  
  34. def restart_apache():
  35. sudo('apache2ctl graceful')
  36.  
  37. def restart_server():
  38. stop_server()
  39. start_server()
  40. restart_apache()
  41.  
  42. def collect_static():
  43. with cd(PROJECT_DIR):
  44. with prefix('workon %s' % PROJECT_NAME):
  45. run('./manage.py collectstatic --noinput')
  46.  
  47. def deploy():
  48. with settings(hide('stdout'), warn_only=True):
  49. pull()
  50. install_packages()
  51. sync_database()
  52. migrate_database()
  53. collect_static()
  54. restart_server()
Add Comment
Please, Sign In to add comment