Edgewall Software
Modify

Opened 19 years ago

Closed 19 years ago

#1852 closed defect (fixed)

tracd fails when running as a daemon

Reported by: Matthew Good Owned by: Christian Boos
Priority: high Milestone: 0.9
Component: web frontend/tracd Version: devel
Severity: critical Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

Running tracd with the "-d" option starts it as a daemon process, but every request fails without a response. On the command line I see "Unhandled exception in thread started by" which also indicates that the process has not actually been fully daemonized (I know that there's a cookbook recipie on how to do this that I'll check tomorrow).

In trying to debug the problem I commented the lines that close stdin, stdout and stderr so that I could see more information, and it worked again, so it's likely to be a problem with trying to write to these closed streams.

Attachments (0)

Change History (4)

comment:1 by Yun Zheng Hu, 19 years ago

The code below will redirect the streams to /dev/null and it will work again. I'm not sure if this code is windows comptatible tho.

    try:
        if daemonize:
            pid=os.fork()
            if pid == 0:
                os.chdir(os.sep)
                os.setpgrp()
                # Redirect standard file descriptors
                sys.stdin = open('/dev/null', 'r')
                sys.stdout = open('/dev/null', 'w')
                sys.stderr = open('/dev/null', 'w')
            else:
                print 'tracd daemon running with pid: %d' % pid
                sys.exit(0)
        httpd.serve_forever()
    except OSError:
        sys.exit(1)

comment:2 by Christian Boos, 19 years ago

It wasn't windows compatible before either…

comment:3 by Christian Boos, 19 years ago

Owner: changed from Matthew Good to Christian Boos
Priority: normalhigh
Status: newassigned

Looks good.

comment:4 by Christian Boos, 19 years ago

Resolution: fixed
Status: assignedclosed

Patch applied in [2117]

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christian Boos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christian Boos 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.