package FS::Conf;
-use vars qw($base_dir @config_items @base_items @card_types $DEBUG);
use strict;
+use vars qw($base_dir @config_items @base_items @card_types $DEBUG $conf_cache);
use Carp;
use IO::File;
use File::Basename;
foreach my $a (@a) {
$hashref->{agentnum} = $a;
foreach my $l (@l) {
- $hashref->{locale} = $l;
- $cv = FS::Record::qsearchs('conf', $hashref);
- return $cv if $cv;
+ my $key = join(':',$name, $a, $l);
+ if (! exists $conf_cache->{$key}){
+ $hashref->{locale} = $l;
+ # $conf_cache is reset in FS::UID during myconnect, so the cache is reset per connection
+ $conf_cache->{$key} = FS::Record::qsearchs('conf', $hashref);
+ }
+ return $conf_cache->{$key} if $conf_cache->{$key};
}
}
return undef;
$error = $new->insert;
}
+ if (! $error) {
+ # clean the object cache
+ my $key = join(':',$name, $agentnum, $self->{locale});
+ $conf_cache->{ $key } = $new;
+ }
+
die "error setting configuration value: $error \n"
if $error;
use strict;
use constant DEBUG => 0; # Enable much runtime information.
-use constant MAX_PROCESSES => 10; # Total server process count.
+use constant MAX_PROCESSES => 4; # Total server process count. XXX conf to increase per-different daemon for busy sites using this (currently the only things using this are freeside-xmlrpcd and freeside-selfservice-xmlrpcd)
#use constant TESTING_CHURN => 0; # Randomly test process respawning.
use vars qw( @EXPORT_OK $FREESIDE_LOG $SERVER_PORT $user $handle_request );
)
or die "DBI->connect error: $DBI::errstr\n";
+ require FS::Conf;
+ $FS::Conf::conf_cache = undef;
+
if ( $schema ) {
use DBIx::DBSchema::_util qw(_load_driver ); #quelle hack
my $driver = _load_driver($handle);
$ENV{HOME} = (getpwuid($>))[7]; #for ssh
warn "connecting to database\n" if $DEBUG;
-$@ = 'not connected';
-while ( $@ ) {
- eval { adminsuidsetup $user; };
- if ( $@ ) {
- warn $@;
- warn "sleeping for reconnect...\n";
- sleep 5;
- }
-}
+#$@ = 'not connected';
+#while ( $@ ) {
+# eval { adminsuidsetup $user; };
+# if ( $@ ) {
+# warn $@;
+# warn "sleeping for reconnect...\n";
+# sleep 5;
+# }
+#}
+adminsuidsetup $user;
my $log = FS::Log->new('queue');
logfile( "%%%FREESIDE_LOG%%%/queuelog.". $FS::UID::datasrc );