Edgewall Software
Modify

Opened 18 years ago

Closed 18 years ago

#2498 closed defect (fixed)

Logging error with initenv

Reported by: Manuzhai Owned by: daniel
Priority: normal Milestone: 0.10
Component: admin/console Version: devel
Severity: normal Keywords:
Cc: manuzhai@… Branch:
Release Notes:
API Changes:
Internal Changes:

Description

When there is a central trac.ini (in /etc) that enables logging to a file in the environment, initenv fails because it cannot find the file. Makes some sense, since it's looking for a directory that still has to be written, probably.

Failed to create environment. [Errno 2] No such file or directory: '/var/trac/life/log/trac.log'
Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/trac/scripts/admin.py", line 570, in do_initenv
    options=options)
  File "/home/manuzhai/dev/trac/trac/env.py", line 78, in __init__
    self.setup_log()
  File "/home/manuzhai/dev/trac/trac/env.py", line 232, in setup_log
    self.log = logger_factory(logtype, logfile, loglevel, logid)
  File "/home/manuzhai/dev/trac/trac/log.py", line 26, in logger_factory
    hdlr = logging.FileHandler(logfile)
  File "/usr/lib/python2.4/logging/__init__.py", line 753, in __init__
    stream = open(filename, mode)
IOError: [Errno 2] No such file or directory: '/var/trac/life/log/trac.log'
Failed to initialize environment. 1
Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/trac/scripts/admin.py", line 574, in do_initenv
    sys.exit(1)
SystemExit: 1

Attachments (2)

patch-2498.diff (4.0 KB ) - added by Manuzhai 18 years ago.
Attempt at a fix.
patch-2498.2.diff (695 bytes ) - added by Manuzhai 18 years ago.
Fix #2498 by delaying the database initialization.

Download all attachments as: .zip

Change History (7)

comment:1 by Manuzhai, 18 years ago

Milestone: 0.10

This is still here! Just ran into it again today.

Assigning to 0.10, as it shouldn't be too hard.

comment:2 by anonymous, 18 years ago

Version: 0.9.2devel

comment:3 by Manuzhai, 18 years ago

I looked into this some more. I think I fixed the problem, but then trac-admin crashes with a seemingly unrelated exception, see below:

Creating and Initializing Project
Failed to create environment. local variable 'connector' referenced before assignment
Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/trac/scripts/admin.py", line 584, in do_initenv
    options=options)
  File "/usr/lib/python2.4/site-packages/trac/env.py", line 82, in __init__
    self.create(options)
  File "/usr/lib/python2.4/site-packages/trac/env.py", line 193, in create
    DatabaseManager(self).init_db()
  File "/usr/lib/python2.4/site-packages/trac/db/api.py", line 52, in init_db
    connector, args = self._get_connector()
  File "/usr/lib/python2.4/site-packages/trac/db/api.py", line 77, in _get_connector
    if not connector:
UnboundLocalError: local variable 'connector' referenced before assignment
Failed to initialize environment. 1
Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/trac/scripts/admin.py", line 588, in do_initenv
    sys.exit(1)
SystemExit: 1

I'll attach my "fix".

by Manuzhai, 18 years ago

Attachment: patch-2498.diff added

Attempt at a fix.

comment:4 by Manuzhai, 18 years ago

Okay, here's another one that actually works.

by Manuzhai, 18 years ago

Attachment: patch-2498.2.diff added

Fix #2498 by delaying the database initialization.

comment:5 by Matthew Good, 18 years ago

Resolution: fixed
Status: newclosed

The patch didn't quite work for me since some things were still looking for the log before it was initialized. Instead in [3277] I made sure the default config options are loaded for new environments before setting up logging.

Modify Ticket

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