Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
    
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
    
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 code.google.com/p/modwsgi/wiki/ReloadingSourceCode –  Graham Dumpleton Nov 16 '12 at 2:36
    
@GrahamDumpleton Yes I know about touching. I meant changes to the config. Fixed. Thanks. –  steko Nov 16 '12 at 7:50
    
@steko Do you have right permissions for logs files? –  grosshat Nov 16 '12 at 7: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
show 1 more comment

1 Answer

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.

share|improve this answer
    
I'm sorry but this is quite generic as an answer. –  steko Dec 1 '12 at 14:19
    
if you start apache with strace -Ff apachectl start you will likely be able to find out what the problem is. –  Gaia Dec 2 '12 at 21:33
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.