use vars qw($VERSION $System $SystemUser $Nobody $Handle $Logger
$CORE_CONFIG_FILE
$SITE_CONFIG_FILE
- $VENDOR_CONFIG_FILE
$BasePath
$EtcPath
$VarPath
=item LoadConfig
Load RT's config file. First, go after the core config file.
-After that, try to load the vendor config.
After that, go after the site config.
=cut
=cut
sub Init {
- require RT::Handle;
+
#Get a database connection
- unless ($Handle && $Handle->dbh->ping) {
- $Handle = RT::Handle->new();
- }
- $Handle->Connect();
-
+ ConnectToDatabase();
+
#RT's system user is a genuine database user. its id lives here
$SystemUser = new RT::CurrentUser();
$SystemUser->LoadByName('RT_System');
InitLogging();
}
+
+=head2 ConnectToDatabase
+
+Get a database connection
+
+=cut
+
+sub ConnectToDatabase {
+ require RT::Handle;
+ unless ($Handle && $Handle->dbh && $Handle->dbh->ping) {
+ $Handle = RT::Handle->new();
+ }
+ $Handle->Connect();
+}
+
=head2 InitLogging
Create the RT::Logger object.
$RT::Logger=Log::Dispatch->new();
if ($RT::LogToFile) {
-
- unless (-d $RT::LogDir && -w $RT::LogDir) {
- # localizing here would be hard when we don't have a current user yet
- # die $self->loc("Log directory [_1] not found or couldn't be written.\n RT can't run.", $RT::LogDir);
- die ("Log directory $RT::LogDir not found or couldn't be written.\n RT can't run.");
- }
-
- my $filename;
+ my ($filename, $logdir);
if ($RT::LogToFileNamed =~ m![/\\]!) {
# looks like an absolute path.
$filename = $RT::LogToFileNamed;
+ ($logdir) = $RT::LogToFileNamed =~ m!^(.*[/\\])!;
}
else {
$filename = "$RT::LogDir/$RT::LogToFileNamed";
+ $logdir = $RT::LogDir;
}
+
+ unless ( -d $logdir && ( ( -f $filename && -w $filename ) || -w $logdir ) ) {
+ # localizing here would be hard when we don't have a current user yet
+ # die $self->loc("Log directory [_1] not found or couldn't be written.\n RT can't run.", $RT::LogDir);
+ die ("Log file $filename couldn't be written or created.\n RT can't run.");
+ }
+
require Log::Dispatch::File;
return "$p{message} ($filename:$line)\n"}
},
- stderr => 1
+ stderr => 1,
+ @RT::LogToSyslogConf
));
}
=head1 BUGS
+Please report them to rt-3.0-bugs@fsck.com, if you know what's broken and have at least some idea of what needs to be fixed.
+If you're not sure what's going on, report them rt-devel@lists.fsck.com.
+
=head1 SEE ALSO
+L<RT::StyleGuide>
+L<DBIx::SearchBuilder>
+
+
=begin testing