Edgewall Software
Modify

Opened 18 years ago

Closed 16 years ago

Last modified 16 years ago

#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)

4552-handle-signals-r7411.patch (1.2 KB ) - added by Remy Blank <remy.blank@…> 16 years ago.
Patch against 0.11-stable adding a signal handler to ensure the pidfile is removed

Download all attachments as: .zip

Change History (9)

comment:1 by anonymous, 18 years ago

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

comment:2 by Christian Boos, 18 years ago

Component: generaltracd
Milestone: 0.10.4
Priority: highestnormal
Severity: criticalmajor

in reply to:  2 comment:3 by stephane, 18 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 Remy Blank <remy.blank@…>, 16 years ago

Cc: remy.blank@… 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 Remy Blank <remy.blank@…>, 16 years ago

Patch against 0.11-stable adding a signal handler to ensure the pidfile is removed

comment:5 by Remy Blank <remy.blank@…>, 16 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:6 by Jonas Borgström, 16 years ago

Milestone: 0.10.60.11.2

Looks good to me.

comment:7 by Remy Blank, 16 years ago

Resolution: fixed
Status: newclosed

Patch applied to 0.11-stable in [7461] and merged to trunk in [7462].

Closing, as the original issue could not be reproduced.

comment:8 by Christian Boos, 16 years ago

Owner: changed from Jonas Borgström to Remy Blank

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Remy Blank.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Remy Blank to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.