X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2Fbin%2Ffreeside-queued;h=36871b295f24d9216e19d52d9d79adc5e7174de8;hp=4786132c62837152f59c14de6aa1c15ea00577f0;hb=6de06472ab43534bd889e531ae060bbd4c935518;hpb=ae02d1178c6859f7a0a5e4a22c685de5f0477568 diff --git a/FS/bin/freeside-queued b/FS/bin/freeside-queued index 4786132c6..36871b295 100644 --- a/FS/bin/freeside-queued +++ b/FS/bin/freeside-queued @@ -38,16 +38,15 @@ drop_root(); $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; -# } -#} -adminsuidsetup $user; +$@ = 'not connected'; +while ( $@ ) { + eval { adminsuidsetup $user; }; + if ( $@ ) { + warn $@; + warn "sleeping for reconnect...\n"; + sleep 5; + } +} my $log = FS::Log->new('queue'); logfile( "%%%FREESIDE_LOG%%%/queuelog.". $FS::UID::datasrc ); @@ -220,7 +219,11 @@ while (1) { $log->info('starting job ('.$ljob->job.')'); warn 'running "&'. $ljob->job. '('. join(', ', @args). ")\n" if $DEBUG; local $FS::UID::AutoCommit = 0; # so that we can clean up failures - eval $eval; #throw away return value? suppose so + do { + # switch user only if a job user is available + local $FS::CurrentUser::CurrentUser = $ljob->access_user || $FS::CurrentUser::CurrentUser; + eval $eval; #throw away return value? suppose so + }; if ( $@ ) { dbh->rollback; my %hash = $ljob->hash;