termopro,
I have automated my deployments mostly separate from my
version control.
The other team members and I write, test, commit, and push our
code changes to our Git repo. I then pull, review, test, update
the version number, commit, tag, and push to Git.
Then I use a shell script (on Mac, but would work on Unix/Linux
also) to push the tagged commit to TEST and later to PROD.
My script does things like:
- Get the latest files from Git before, and back to master after:
% git checkout mytag
...
% git checkout master
- Create folder of collected static files before, and delete after:
% mkdir -pv collected_static/mytag
% python manage.py collectstatic --clear --noinput
...
% rm -rfv collected_static
- Delete all local *.pyc files:
% find . -name \*.pyc -exec rm -v "{}" ";"
- Insert PROD password into local settings file (PROD pushes
only) before, and remove after:
% sed -i .old -e "s/PUT_PROD_PASSWORD_HERE/`cat prod_pw`/g" settings.py
...
% mv -v settings.py.old settings.py
- Show a warning banner at the Web site to say it is going down
briefly, and clear the banner after:
% ssh -t myserver.mydomain.com cp -v
/var/www/django/myapp/templates/myapp/site_alert_maintenance.html
site_alert.html
% sleep 60
...
% ssh -t myserver.mydomain.com cp -v
/var/www/django/myapp/templates/myapp/site_alert_none.html site_alert.html
- Push the local files to the TEST or PROD server:
% rsync -v --progress -i -l --rsh=ssh -r --del myapp
myserver.mydomain.com:/var/www/django
- Run all migrations on the server
% ssh -t myserver.mydomain.com python manage.py migrate --all
- Stop the Apache server, delete all remote *.pyc files, and
restart the server:
% ssh -t myserver.mydomain.com sudo /etc/init.d/httpd stop
% ssh -t myserver.mydomain.com sudo find /var/www/django/myapp -name
\*.pyc -exec rm -v "{}" ";"
% ssh -t myserver.mydomain.com sudo /etc/init.d/httpd start
Plus a few other actions that are specific to our app, and lots
or informational messages, prompts, confirmations, etc. Also,
some of these steps are combined into a remote script that
runs on the server to reduce the number of "ssh -t sudo"
commands I would otherwise have to do. But, that's the gist
of it.
Hope this helps!
--Fred
------------------------------------------------------------------------
Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/
Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.
------------------------------------------------------------------------
On 11/19/14 5:22 AM, termopro wrote:
I have created a Django 1.7 project and would like to deploy it. I am
reading about how to do it right and i have some questions.
If i understand correctly deployment should contain the following steps:
1) Initial remote machine set up:
* a) install os / server / database / cache ...
* b) install Django and required modules
* c) update database with real data
2) Upload code/ database changes to remote machine:
* a) upload changed Django project
* b) upload changes in Database tables (model migrations)
Most tutorials/articles about deployment do not cover 1.c and 2.b.
Also the tasks 1.b. and 2.a. are solved using revision control tools
(Git/Mercurial)
So i'd like to know:
*
1) How do i install Django project or it's updates without
revision control tools ? Should i simply upload my project using
FTP/SSH ? Is there a good way to automate it ?
*
2) How do i automate the task of uploading required database
changes (like model migrations) ?
--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to django-users+unsubscr...@googlegroups.com
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com
<mailto:django-users@googlegroups.com>.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/e9fb8f5a-2bd9-47d5-80c7-07a3aa82bd25%40googlegroups.com
<https://groups.google.com/d/msgid/django-users/e9fb8f5a-2bd9-47d5-80c7-07a3aa82bd25%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/546E7B4A.3030303%40bristle.com.
For more options, visit https://groups.google.com/d/optout.