1

I have two simple WSGI apps running on top of mod_wsgi and apache2 (worker) on a test development server. There is no mod_python on this machine.

The WSGI configuration is as follows

    WSGIDaemonProcess tops stack-size=524288 maximum-requests=5
    WSGIScriptAlias /tops /home/ubuntu/tops-cloud/tops.wsgi

    <Directory /home/ubuntu/tops-cloud>
            WSGIProcessGroup tops
            WSGIApplicationGroup %{GLOBAL}
            Order deny,allow
            Allow from all
    </Directory>


    WSGIDaemonProcess flaskal maximum-requests=5
    WSGIScriptAlias /c14 /home/ubuntu/c14/flaskal/flaskal.wsgi

    <Directory /home/ubuntu/c14/flaskal>
            WSGIProcessGroup flaskal
            WSGIApplicationGroup %{GLOBAL}
            Order deny,allow
            Allow from all
    </Directory>

If I make changes to the configuration (e.g. number of maximum requests, etc), I need to restart the web server, so I would expect that a simple sudo service apache2 restart does what I need.

Instead, it never ends "waiting", like this:

$ sudo service apache2 restart
 * Restarting web server apache2
... waiting ..................................................

until I just do CTRL-C. At that point, the only way to resume a working server is to kill the process and restart it, not very convenient. The same happens with the stop command.

The error logs at the "debug" level show the following lines after a failed restart

[Wed Nov 14 21:55:19 2012] [notice] caught SIGTERM, shutting down
[Wed Nov 14 21:55:19 2012] [info] mod_wsgi (pid=9047): Shutdown requested 'tops'.
[Wed Nov 14 21:55:19 2012] [info] mod_wsgi (pid=9047): Stopping process 'tops'.
[Wed Nov 14 21:55:19 2012] [info] mod_wsgi (pid=9047): Destroying interpreters.
[Wed Nov 14 21:55:19 2012] [info] mod_wsgi (pid=9047): Cleanup interpreter ''.
[Wed Nov 14 21:55:19 2012] [info] mod_wsgi (pid=9047): Terminating Python.
[Wed Nov 14 21:55:19 2012] [info] mod_wsgi (pid=8920): Shutdown requested 'flaskal'.
[Wed Nov 14 21:55:19 2012] [info] mod_wsgi (pid=8920): Stopping process 'flaskal'.
[Wed Nov 14 21:55:19 2012] [info] mod_wsgi (pid=8920): Destroying interpreters.
[Wed Nov 14 21:55:19 2012] [info] mod_wsgi (pid=8920): Cleanup interpreter ''.
[Wed Nov 14 21:55:19 2012] [info] mod_wsgi (pid=8920): Terminating Python.
[Wed Nov 14 21:55:19 2012] [info] mod_wsgi (pid=8920): Python has shutdown.
[Wed Nov 14 21:55:19 2012] [info] mod_wsgi (pid=9047): Python has shutdown.

If I then try to restart again (with the process still running), I get the following error:

 * Restarting web server apache2                                                                                                            (98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
Action 'start' failed.
The Apache error log may have more information.

Unfortunately the Apache error log doesn't have anything.

When apache2 is running properly, both apps work without any problem.

steko
  • 111
  • 6
  • Set LogLevel in Apache to at least 'info' if not 'debug' and then look at what the logs say about where it is up to. This will especially help if mod_wsgi in use as it will output extra logging at those levels. Also post your specific mod_wsgi configuration, plus indicate if using mod_python at the same time. – Graham Dumpleton Nov 14 '12 at 21:33
  • 1
    BTW, you don't need to restart the whole of Apache to reload the Python code changes. Touch the WSGI script file if using daemon mode. See http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode – Graham Dumpleton Nov 16 '12 at 02:36
  • @GrahamDumpleton Yes I know about touching. I meant changes to the config. Fixed. Thanks. – steko Nov 16 '12 at 07:50
  • @steko Do you have right permissions for `logs` files? – grosshat Nov 16 '12 at 07:57
  • @grosshat log files get written, e.g.`-rw-r----- 1 root adm 818 Nov 22 15:33 error.log` What are the "right" permissions? – steko Nov 22 '12 at 15:42
  • @steko It depends on the user/group that is writing to. So the user/group that is running the server. – grosshat Nov 22 '12 at 16:29

1 Answers1

0

In some cases a log entry will not be written to disk (if logs don't exist or its permissions are wrong). The best way to diagnose an error is to try to start Apache with the following command strace -Ff apachectl start.

Gaia
  • 1,855
  • 5
  • 34
  • 60