#4552 closed defect (fixed)
Login do not works when Trac is daemonized
| Reported by: | anonymous | Owned by: | Remy Blank |
|---|---|---|---|
| Priority: | normal | Milestone: | 0.11.2 |
| Component: | web frontend/tracd | Version: | 0.10.3 |
| Severity: | major | Keywords: | patch |
| Cc: | remy.blank@… | Branch: | |
| Release Notes: | |||
| API Changes: | |||
| Internal Changes: | |||
Description
When I trying to daemonize Trac, Login on the web-interface do not works. Blank page in response.
This is a log:
2007-01-17 12:47:15,635 Trac[main] ERROR: [Errno 5] Input/output error
Traceback (most recent call last):
File "/usr/local/lib/python2.4/site-packages/trac/web/main.py", line 387, in dispatch_request
dispatcher.dispatch(req)
File "/usr/local/lib/python2.4/site-packages/trac/web/main.py", line 244, in dispatch
req.display(template, content_type or 'text/html')
File "/usr/local/lib/python2.4/site-packages/trac/web/api.py", line 368, in display
self.write(data)
File "/usr/local/lib/python2.4/site-packages/trac/web/api.py", line 460, in write
self._write(data)
File "/usr/local/lib/python2.4/site-packages/trac/web/wsgi.py", line 195, in _write
self.handler.send_response(int(status[:3]))
File "/usr/local/lib/python2.4/BaseHTTPServer.py", line 357, in send_response
self.log_request(code)
File "/usr/local/lib/python2.4/BaseHTTPServer.py", line 394, in log_request
self.requestline, str(code), str(size))
File "/usr/local/lib/python2.4/BaseHTTPServer.py", line 427, in log_message
sys.stderr.write("%s - - [%s] %s\n" %
IOError: [Errno 5] Input/output error
2007-01-17 12:47:31,107 Trac[main] ERROR: [Errno 5] Input/output error
Traceback (most recent call last):
File "/usr/local/lib/python2.4/site-packages/trac/web/main.py", line 387, in dispatch_request
dispatcher.dispatch(req)
File "/usr/local/lib/python2.4/site-packages/trac/web/main.py", line 237, in dispatch
resp = chosen_handler.process_request(req)
File "/usr/local/lib/python2.4/site-packages/trac/web/auth.py", line 103, in process_request
self._redirect_back(req)
File "/usr/local/lib/python2.4/site-packages/trac/web/auth.py", line 198, in _redirect_back
req.redirect(referer or req.abs_href())
File "/usr/local/lib/python2.4/site-packages/trac/web/api.py", line 340, in redirect
self.write('Redirecting...')
File "/usr/local/lib/python2.4/site-packages/trac/web/api.py", line 460, in write
self._write(data)
File "/usr/local/lib/python2.4/site-packages/trac/web/wsgi.py", line 195, in _write
self.handler.send_response(int(status[:3]))
File "/usr/local/lib/python2.4/BaseHTTPServer.py", line 357, in send_response
self.log_request(code)
File "/usr/local/lib/python2.4/BaseHTTPServer.py", line 394, in log_request
self.requestline, str(code), str(size))
File "/usr/local/lib/python2.4/BaseHTTPServer.py", line 427, in log_message
sys.stderr.write("%s - - [%s] %s\n" %
IOError: [Errno 5] Input/output error
Attachments (1)
Change History (9)
comment:1 by , 19 years ago
follow-up: 3 comment:2 by , 19 years ago
| Component: | general → tracd |
|---|---|
| Milestone: | → 0.10.4 |
| Priority: | highest → normal |
| Severity: | critical → major |
comment:3 by , 19 years ago
Replying to cboos:
I have a daemon in Kubutu 6.06. The only problem I have is that tracd doesn't delele its pidfile, so a next boot it will not start (because it thinks its already started).
I stop it with the following code, is there some way that tracd delete its pidfile at end?
d_stop() {
start-stop-daemon --stop -c www-data -g www-data \
--quiet --pidfile $PIDFILE \
--name $NAME \
|| echo -n " not running"
}
comment:4 by , 17 years ago
| Cc: | added |
|---|
The original problem seems to be a failure to write to stderr when daemonized. I cannot reproduce the problem, and looking at the code reveals that stderr is redirected to /dev/null when daemonized. I wish the original reporter had entered an e-mail address so that we could ask for more details.
However, the comment from stephane above is correct: the pidfile is not removed when tracd is killed with a signal, despite the remove_pidfile() exit handler that is installed in trac.util.daemon.daemonize(). Indeed, the Python documentation for the atexit module reveals the following:
Note: the functions registered via this module are not called when the program is killed by a signal, when a Python fatal internal error is detected, or when os._exit() is called.
I would suggest installing a signal handler in daemonize() and either invoking the atexit handlers by calling sys.exitfunc or just removing the pidfile. I'm not sure what signals should be handled, though: HUP, USR1, USR2, …?
If this seems like a good idea, I could submit a patch.
by , 17 years ago
| Attachment: | 4552-handle-signals-r7411.patch added |
|---|
Patch against 0.11-stable adding a signal handler to ensure the pidfile is removed
comment:5 by , 17 years ago
| Keywords: | patch added |
|---|
I cannot reproduce the OP's symptoms, even without specifying --pidfile. I guess this could be closed as invalid.
The problem reported by stephane is real, though. The pidfile is only removed if the daemon is killed with a SIGINT. The traditional signal used for this purpose is SIGTERM. In trac.web._fcgi.py, the signals handled are SIGHUP, SIGINT and SIGTERM.
The patch above adds a signal handler for SIGHUP and SIGTERM that exits the process through sys.exit(), therefore ensuring that atexit handlers are called and the pidfile is removed. It is not necessary to handle SIGINT, as it generates a KeyboardInterrupt exception.
comment:7 by , 17 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
comment:8 by , 17 years ago
| Owner: | changed from to |
|---|



—pidfile should be presented and everything will be OK :)