[kforge-dev] Auto apache reload

Martin Fuzzey mfuzzey at gmail.com
Sat Mar 1 11:03:12 UTC 2008


does automatic apache config reload via sudo work reliably?

I am having problems with most of the time getting logs like :
 Failed to reload apache with [sudo /etc/init.d/apache2 reload]:
Reloading web server config...6364

As the log message shows the command is in fact exectued (as the
output is displayed) so its not a sudo config problem.

Investigating a bit more it seems the apache2 init script is stopping
in the log_end_msg 0 call in the reload command (which just displays
the final ok message)

If I add a 2> /tmp.e.log to this I get this interesting trace :
/lib/lsb/init-functions: line 268: echo: write error: Broken pipe

If I comment out the actual call to apache2ctl in /etc/init.d/apache2
reload all works "fine" (without actually reloading the config

It seems to me that the situation is something like this
1) User performs action via web interface the reloads apache
2) kforge python code forks init.d/apache2 via sudo with stdout and
stderr redirected to python
3) Apache is reloaded (in graceful mode)
4) This somehow breaks the pipe between python and the init script
5) The init script gives an error code attempting to write "ok"

It seems to be a case of sawing off the branch you're sitting on
(reloading apache from an apache launched script...) though I thought
the "graceful" option should have handled this.

I think it may work occasionally....

A simple workaround is to add "> /dev/null" to the reload_apache
command in the kforge configuration file but of course this loses the
stdout logs.

This maybe a timing related issue (race condition) and my setup is
likely to be pretty atypical as I'm running etch in a qemu VM for

Another strange thing is that I seem to be having variable behaviour
seen by the user when this occurs. In my case I am creating a svn
Sometimes the repository is not created but no message is displayed to
show this (and obviously the links are broken) when this occurs the
logs show:
[2008-02-29 15:48:52,582] Request to ServiceCreateView:
[2008-02-29 15:48:52,795] OK admin GET ServiceCreateView
[2008-02-29 15:49:01,553] Request to ServiceCreateView:
[2008-02-29 15:49:01,766] OK admin POST ServiceCreateView
[2008-02-29 15:49:02,295] Written new apache config to path:
[2008-02-29 15:49:03,810] Failed to reload apache with [sudo
/etc/init.d/apache2 reload]: Reloading web server config...6364
[2008-02-29 15:49:03,827] Created Service: '1'

Othertimes the repository _is_ created :
[2008-03-01 09:59:05,929] Request to ServiceListView: /project/test1/services/
[2008-03-01 09:59:06,139] OK admin GET ServiceListView /project/test1/services/
[2008-03-01 09:59:14,796] Request to ServiceCreateView:
[2008-03-01 09:59:14,982] OK admin GET ServiceCreateView
[2008-03-01 09:59:22,787] Request to ServiceCreateView:
[2008-03-01 09:59:22,972] OK admin POST ServiceCreateView
[2008-03-01 09:59:23,536] Written new apache config to path:
[2008-03-01 09:59:25,056] Failed to reload apache with [sudo
/etc/init.d/apache2 reload]: Reloading web server config...1913
[2008-03-01 09:59:25,365] SvnPlugin: Created service <Service  id=11
name='code7' plugin='svn' project='test1' state='active'
state='active'> on path: /var/l
[2008-03-01 09:59:25,372] Created Service: '11'

I am having trouble understanding how this part works due to my
current ignorance of the codebase :(
The svn repository itself is created in the svn plugin onServiceCreate
message and I think the apache config is done by apacheconfig plugin
onServiceCreate (which does a rebuild and reload) but what's the link
betweed the two? Furthermore ApacheConfigBuilder.reloadConfig()
returns True/False but I can't find anywhere that this is actually

A few pointers here would be helpful :)



More information about the kforge-dev mailing list