32

I configured my development server this way:

Ubuntu, Apache, mod_wsgi, Python 2.6

I work on the server from another computer connected to it.

Most of the times the changes don't affect the application unless I restart Apache. In some cases the changes take effect without restarting the webserver, but after let's say 3 or 4 page loads the application might behave like it used to behave previous to the changes.

Until now I just reloaded everytime apache as I have the development server here with me, but HELL after a while got so annoying. How can I avoid this?

I can't work with the development server as I need an environment that is as close as possible as the production one.

Thanks

nemesisdesign
  • 8,159
  • 12
  • 58
  • 97
  • Just to confirm, in your last ¶ when you say you can't work with the development server, do you actually mean using `manage.py runserver`? – Jordan Reiter Nov 17 '10 at 16:19
  • Show your relevant configuration files. Mostly Id like to see the mod_wsgi script which kicks off your django app. – rapadura Nov 17 '10 at 15:35
  • This blog post may help you: http://blog.dscpl.com.au/2008/12/using-modwsgi-when-developing-django.html ...and this: http://modwsgi.readthedocs.io/en/develop/user-guides/reloading-source-code.html – Raz Nov 17 '10 at 15:41

3 Answers3

24

My suggestion is that you run the application in daemon mode. This way you won't be required to restart apache, just touch my_handler.wsgi and the daemon will know to restart the app. The apache httpd will not be only yours (in production) so it is fair not to restart it on every update.

vonPetrushev
  • 5,457
  • 6
  • 39
  • 51
7

No changes require you to RESTART. You simply need to reload using "sudo /etc/init.d/apache2 reload". Which I have aliased in my bashrc to 'a2reload'.

function a2reload (){
sudo /etc/init.d/apache2 reload
}
0

Apache loads Django environment when starting and keep running it even when source is changed.

I suggest you to use Django 'runserver' (which automatically restarts on changes) in heavy development sessions, unless you need some Apache-specific features (such as multi-thread).

Note also that changes in templates do not require the restart of the web server.

Don
  • 16,928
  • 12
  • 63
  • 101
  • 1
    The second link from Raz's post provides a script to automatically reload the project every time a file is changed that implies neither restarting apache, nor resorting to using runserver. – Antony Hatchkins Sep 03 '15 at 16:22
  • Sorry, I misread the post and gave an answer for Windows, which doesn't support daemon mode. – Don Sep 07 '15 at 07:51