Friday, December 2, 2011

Re: How to deploy new code to the Production Server?

On 2/12/2011 10:00, Andre Lopes wrote:
> Hi,
>
> I'm new to Django. I need to setup Git to deploy a Django website to
> the production server. My question here is to know what is the best
> way of doing this.
>
> By now I only have a Master branch. My problem here is that
> Development environment is not equal to the Production environment.
> How can I have the two environments(Development and Production) in
> Git? Should I use two new Branches(Development and Production). Please
> give me a clue on this.
>
> Other question... when I finish to upload/push the code to the
> Production server I need to restart the Gunicorn(serves Django
> website). How can I do this?
>
> And the most important question... Should I use Git to do this or I
> have better options?
>
> Best Regards,
>

To actually answer your question more completely, we would need to know
more on your development and production environment, in other words,
what tools are you using.

In my setup, git contains only the project code, no distinction here
to development or production environment.
I use virtualenv and pip to setup my environment. Installing on production
can be as simple as doing a "pip freeze > requirements.txt" to get all
the installed packages and installing them on the server is
possible via "pip install -r requirments.txt".

I manage gunicorn with supervisord. It's a great tool.
If you don't have supervisord or another tool to manage the gunicorn instances,
you'll need to stop the gunicorn processes manually (kill if working on Linuix)
and start them again. (gunicorn_django -c <configfile>)
You really should be looking at a tool to manage them.

Fabric is a tool that can help you automate some of these tedious tasks.

In short:
- If not done yet, have a look at virtualenv and pip and use them to setup
your environment on your development and production machine. On the production
machine you can setup the exact same environment by using the requirements
from the pip freeze command as explained above.
- Develop, commit to git (only code)

- On the server, go into the virtualenv, pull in the code
- Restart the gunicorn processes preferably via supervisord or another tool

- Have a look at Fabric to automate these steps

Regards,
Benedict

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment