[freeside-commits] freeside/FS/bin freeside-selfservice-server, 1.25, 1.26 freeside-torrus-srvderive, 1.40, 1.41
Ivan,,,
ivan at wavetail.420.am
Sun Apr 17 11:01:05 PDT 2011
Update of /home/cvs/cvsroot/freeside/FS/bin
In directory wavetail.420.am:/tmp/cvs-serv13576
Modified Files:
freeside-selfservice-server freeside-torrus-srvderive
Log Message:
try at a multiprocess torrus-srvderive to hopefully catch/keep up, RT#10574
Index: freeside-torrus-srvderive
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/bin/freeside-torrus-srvderive,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -w -d -r1.40 -r1.41
--- freeside-torrus-srvderive 14 Apr 2011 18:23:01 -0000 1.40
+++ freeside-torrus-srvderive 17 Apr 2011 18:01:03 -0000 1.41
@@ -1,6 +1,7 @@
#!/usr/bin/perl -w
use strict;
+use POSIX qw( :sys_wait_h );
use Sys::SigAction qw( set_sig_handler );
use Date::Parse;
use Date::Format;
@@ -10,6 +11,8 @@
use FS::torrus_srvderive;
our $DEBUG = 2;
+our $max_kids = 3;
+our %kids;
my $user = shift or die &usage;
$FS::Daemon::PID_NEWSTYLE = 1;
@@ -59,6 +62,7 @@
LIMIT 50
";
+our $kids = 0;
MAIN: while (1) {
@@ -66,6 +70,28 @@
SERVICEID: foreach my $torrus_srvderive ( qsearch('torrus_srvderive', {}) ) {
+ &reap_kids;
+ if ( $kids >= $max_kids ) {
+ sleep 10;
+ redo;
+ }
+
+ defined( my $pid = fork ) or do {
+ #warn "WARNING: can't fork: $!\n";
+ #next; #don't increment the kid counter
+ die "can't fork: $!\n";
+ };
+
+ if ( $pid ) {
+ $kids++;
+ $kids{$pid} = 1;
+ } else { #kid time
+
+ #get new db handle
+ $FS::UID::dbh->{InactiveDestroy} = 1;
+
+ forksuidsetup($user);
+
my $serviceid = $torrus_srvderive->serviceid;
my @serviceids = $torrus_srvderive->component_serviceids;
@@ -195,6 +221,10 @@
}
warn "done with $serviceid\n" if $DEBUG;
+ exit;
+ #end-of-kid
+ }
+
} #foreach my $torrus_srvderive
dbh->commit or die dbh->errstr;
@@ -212,6 +242,15 @@
die "Usage:\n\n freeside-cdrrewrited user\n";
}
+sub reap_kids {
+ foreach my $pid ( keys %kids ) {
+ my $kid = waitpid($pid, WNOHANG);
+ if ( $kid > 0 ) {
+ $kids--;
+ delete $kids{$kid};
+ }
+ }
+}
=head1 NAME
Index: freeside-selfservice-server
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/bin/freeside-selfservice-server,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -w -d -r1.25 -r1.26
--- freeside-selfservice-server 21 Jan 2010 01:25:22 -0000 1.25
+++ freeside-selfservice-server 17 Apr 2011 18:01:03 -0000 1.26
@@ -110,26 +110,29 @@
lock_write;
nstore_fd( { _token => '_keepalive' }, $writer );
- foreach my $agent ( qsearch( 'agent', { disabled => '' } ) ) {
- my $config = qsearchs( 'conf', { name => 'selfservice-bulk_ftp_dir',
- agentnum => $agent->agentnum,
- } )
- or next;
- my $session =
- FS::ClientAPI->dispatch( 'Agent/agent_login',
- { username => $agent->username,
- password => $agent->_password,
- }
- );
+#commenting izoom stuff out until we can move it to a branch (or just remove)
+# foreach my $agent ( qsearch( 'agent', { disabled => '' } ) ) {
+# my $config = qsearchs( 'conf', { name => 'selfservice-bulk_ftp_dir',
+# agentnum => $agent->agentnum,
+# } )
+# or next;
+#
+# my $session =
+# FS::ClientAPI->dispatch( 'Agent/agent_login',
+# { username => $agent->username,
+# password => $agent->_password,
+# }
+# );
+#
+# nstore_fd( { _token => '_ftp_scan',
+# dir => $config->value,
+# session_id => $session->{session_id},
+# },
+# $writer
+# );
+# }
- nstore_fd( { _token => '_ftp_scan',
- dir => $config->value,
- session_id => $session->{session_id},
- },
- $writer
- );
- }
unlock_write;
}
next;
More information about the freeside-commits
mailing list