[freeside-commits] freeside/FS/FS Conf.pm, 1.366, 1.367 Daemon.pm, 1.5, 1.6

Ivan,,, ivan at wavetail.420.am
Wed Jun 16 14:53:26 PDT 2010


Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv31147/FS/FS

Modified Files:
	Conf.pm Daemon.pm 
Log Message:
a local XML-RPC server for ncic: daemonize and respond to TERM, RT#7780

Index: Conf.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Conf.pm,v
retrieving revision 1.366
retrieving revision 1.367
diff -u -w -d -r1.366 -r1.367
--- Conf.pm	8 Jun 2010 22:24:59 -0000	1.366
+++ Conf.pm	16 Jun 2010 21:53:24 -0000	1.367
@@ -1645,6 +1645,7 @@
     'description' => 'Run billing for signup server signups immediately, and do not provision accounts which subsequently have a balance.',
     'type'        => 'checkbox',
   },
+
   {
     'key'         => 'signup_server-classnum2',
     'section'     => 'self-service',
@@ -1660,6 +1661,13 @@
   },
 
   {
+    'key'         => 'selfservice-xmlrpc',
+    'section'     => 'self-service',
+    'description' => 'Run a standalone self-service XML-RPC server on the backend (on port 8080).',
+    'type'        => 'checkbox',
+  },
+
+  {
     'key'         => 'backend-realtime',
     'section'     => 'billing',
     'description' => 'Run billing for backend signups immediately.',

Index: Daemon.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Daemon.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -w -d -r1.5 -r1.6
--- Daemon.pm	16 Jun 2010 19:41:24 -0000	1.5
+++ Daemon.pm	16 Jun 2010 21:53:24 -0000	1.6
@@ -6,6 +6,8 @@
 use Fcntl qw(:flock);
 use POSIX qw(setsid);
 use IO::File;
+use File::Basename;
+use File::Slurp qw(slurp);
 use Date::Format;
 
 #this is a simple refactoring of the stuff from freeside-queued, just to
@@ -20,11 +22,18 @@
 $pid_dir = '/var/run';
 
 $NOSIG = 0;
+$PID_NEWSTYLE = 0;
 
 sub daemonize1 {
   $me = shift;
 
-  $pid_file = "$pid_dir/$me";
+  $pid_file = $pid_dir;
+  if ( $PID_NEWSTYLE ) {
+    $pid_file .= '/freeside';
+    mkdir $pid_file unless -d $pid_file;
+    chown $FS::UID::freeside_uid, -1, $pid_file;
+  }
+  $pid_file .= "/$me";
   $pid_file .= '.'.shift if scalar(@_);
   $pid_file .= '.pid';
 
@@ -35,6 +44,7 @@
     print "$me started with pid $pid\n"; #logging to $log_file\n";
     exit unless $pid_file;
     my $pidfh = new IO::File ">$pid_file" or exit;
+    chown $FS::UID::freeside_uid, -1, $pid_file;
     print $pidfh "$pid\n";
     exit;
   }
@@ -82,14 +92,18 @@
 sub logfile { $logfile = shift; } #_logmsg('test'); }
 
 sub myexit {
-  unlink $pid_file if -e $pid_file;
+  chomp( my $pid = slurp($pid_file) );
+  unlink $pid_file if -e $pid_file && $$ == $pid;
   exit;  
 }
 
 sub _die {
   die @_ if $^S; # $^S = 1 during an eval(), don't break exception handling
   my $msg = shift;
-  unlink $pid_file if -e $pid_file;
+
+  chomp( my $pid = slurp($pid_file) );
+  unlink $pid_file if -e $pid_file && $$ == $pid;
+
   _logmsg($msg);
 }
 



More information about the freeside-commits mailing list