Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Updating Django App on server

I am relatively new to Python/Django and have successfully deployed my first app. I want to update it now with some new changes, but I am not sure what the proper process is. My setup is ubuntu/nginx/gunicorn/postgres.

At the moment I am taking the following steps:

  1. Stop nginx: sudo service nginx stop
  2. Stop gunicorn: sudo service gunicorn stop
  3. Backup the db? (not implemented - cant find it on the server)
  4. Git Pull
  5. python manage.py migrate
  6. python manage.py collectstatic
  7. restart gunicorn: sudo service gunicorn start
  8. restart nginx: sudo service nginx restart

This is working, but I would appreciate some guidance if this is the complete, most accurate and safest way to do this please?

like image 959
RunLoop Avatar asked Jul 21 '15 06:07

RunLoop


1 Answers

One lazy (yet recommended and professional) way of going about app updates is running automation script, like Fabric or Ansible.

However, if you wish to proceed the manual way (which is tedious), you might do something like:

  • Pull from git
  • Run migrations python manage.py migrate (This should ensure changes you made locally to your models reflect in production DB)
  • Run static collections to ensure new statics are reflected in server /static/ folder like so: python manage.py collectstatic
  • Then, restart your Django Server not Nginx. So something like: sudo service your_django_server_running_instance restart

On digitalOcean for instance (when used One-Click Install), your django server running instance is likely called gunicorn

Then you might want to look into automating your postgresql db as well

like image 104
KhoPhi Avatar answered Sep 19 '22 22:09

KhoPhi