Edgewall Software
Modify

Opened 13 years ago

Closed 13 years ago

#10586 closed defect (duplicate)

tracd doesn't create PID file and crash if try to start with --pidfile option

Reported by: kvt@… Owned by: kvt
Priority: normal Milestone:
Component: general Version: 0.12-stable
Severity: major Keywords: pid, writing, tracd, pidfile
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

If try to start tracd with —pidfile option and PID-file is not exists you will see error message: "Error writing to pid file: …"

This problem occurs because in trac.util.daemon doesn't try create PID file if it not exist but try opening for read.

This problem can be fixed if make changes in trac/util/daemon.py (lines 26-44)

        pidfile = os.path.abspath(pidfile)
	if os.path.exists(pidfile):
	  with open(pidfile) as fileobj:
	    try:
	      pid = int(fileobj.read())
	    except ValueError:
	      sys.exit('Invalid PID in file %s' % pidfile)
	
	    try: # signal the process to see if it is still running
	      os.kill(pid, 0)
	      if not progname:
	      progname = os.path.basename(sys.argv[0])
	      sys.exit('%s is already running with pid %s' % (progname, pid))
	    except OSError, e:
	      if e.errno != errno.ESRCH:
	      raise
	else:
            fileobj = open(pidfile, 'w')
            fileobj.close()

see attachments

Attachments (1)

daemon.py (3.2 KB ) - added by kvt@… 13 years ago.
File with fix for ticket #10586

Download all attachments as: .zip

Change History (2)

by kvt@…, 13 years ago

Attachment: daemon.py added

File with fix for ticket #10586

comment:1 by Remy Blank, 13 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #10566.

Modify Ticket

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