Created
October 27, 2016 14:30
-
-
Save Psycojoker/b9cedd245460e91cd263b846cecca275 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # un_projet_django.py | |
| import os | |
| from caprice import require, common, unix, file | |
| # require check if pkg is installed, otherwise installed it | |
| # can require a specific version | |
| postgresql = require('postgresql') | |
| nginx = require('nginx') | |
| supervisord = require('supervisord') | |
| git = require('git') | |
| virtualenv = require('virtualenv') | |
| user = unix.headless_user('un_projet_django') # user sans password s'il existe pas déjà | |
| postgresql.user('un_projet_django') # rajoute les droits à l'user unix pour postgresql | |
| postgresql.db('un_projet_django', user='un_projet_django') | |
| repo = git.clone('https://github.com/psycojoker/un_projet_django/', user.home) | |
| ve = virtualenv.make(repo.path) # autodetect requirements.txt | |
| ve.install("psycopg2", "gunicorn") | |
| if repo.modified: | |
| ve.python("manage.py syncdb --no-input") | |
| ve.python("manage.py makemigrations --no-input") | |
| ve.python("manage.py syncdb --no-input") | |
| ve.python("manage.py collectstatic --no-input") | |
| # DEBUG = False (faudrait un truc pour la clef à cookies) | |
| settings_local = file.simple(command.django.base_settings_local, location=repo.path.joinpath("un_project_django", "settings_local.py")) # path.py | |
| proxy.modified = nginx.proxy( | |
| port='8000', # default | |
| static_path=repo.path.joinpath('static_deploy'), | |
| ) | |
| if proxy.modified: | |
| nginx.reload() | |
| # filename auto generated from this python script name | |
| script = supervisord.script(name="un_projet_django", command="%s --workers=4" % ve.bin_path("gunicorn"), path=repo.path) | |
| if script.modified: | |
| supervisord.update() | |
| elif repo.modified or settings_local.modified: | |
| script.restart() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment