fixing fs-migrate-part_svc
authorivan <ivan>
Tue, 11 Sep 2001 00:07:30 +0000 (00:07 +0000)
committerivan <ivan>
Tue, 11 Sep 2001 00:07:30 +0000 (00:07 +0000)
updateing fs-setup for job queues
freeside-init for starting freeside-queued

bin/freeside-init [new file with mode: 0755]
bin/fs-migrate-part_svc
bin/fs-setup

diff --git a/bin/freeside-init b/bin/freeside-init
new file mode 100755 (executable)
index 0000000..fe12931
--- /dev/null
@@ -0,0 +1,60 @@
+#! /bin/sh
+#
+# start the freeside job queue daemon
+
+#PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+DAEMON=/usr/local/bin/freeside-queued
+NAME=freeside-queued
+DESC="freeside job queue daemon"
+USER="ivan"
+
+test -f $DAEMON || exit 0
+
+set -e
+
+case "$1" in
+  start)
+       echo -n "Starting $DESC: "
+#      start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid -b -m\
+#              --exec $DAEMON
+       $DAEMON $USER &
+       echo "$NAME."
+       ;;
+  stop)
+       echo -n "Stopping $DESC: "
+       start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
+               --exec $DAEMON
+       echo "$NAME."
+        rm /var/run/$NAME.pid
+       ;;
+  #reload)
+       #
+       #       If the daemon can reload its config files on the fly
+       #       for example by sending it SIGHUP, do it here.
+       #
+       #       If the daemon responds to changes in its config file
+       #       directly anyway, make this a do-nothing entry.
+       #
+       # echo "Reloading $DESC configuration files."
+       # start-stop-daemon --stop --signal 1 --quiet --pidfile \
+       #       /var/run/$NAME.pid --exec $DAEMON
+  #;;
+  restart|force-reload)
+       #
+       #       If the "reload" option is implemented, move the "force-reload"
+       #       option to the "reload" entry above. If not, "force-reload" is
+       #       just the same as "restart".
+       #
+        $0 stop
+       sleep 1
+        $0 start
+       ;;
+  *)
+       N=/etc/init.d/$NAME
+       # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
+       echo "Usage: $N {start|stop|restart|force-reload}" >&2
+       exit 1
+       ;;
+esac
+
+exit 0
index 96332f7..b0f3ac5 100755 (executable)
@@ -2,38 +2,39 @@
 
 use strict;
 use FS::UID qw(adminsuidsetup);
-use FS::Record qw(qsearchs);
-use FS::part_svc
+use FS::Record qw(qsearch fields);
+use FS::part_svc;
 
 my $user = shift or die &usage;
 my $dbh = adminsuidsetup $user;
 
 my $oldAutoCommit = $FS::UID::AutoCommit;
-local $FS::UID::AutoCommit = 0
+local $FS::UID::AutoCommit = 0;
 
 foreach my $part_svc ( qsearch('part_svc', {} ) ) {
   foreach my $field (
-    grep { defined($part_svc->getfield($part_svc->svcdb.'__'.$field.'_flag') ) }
-      fields($self->svcdb)
+    grep { defined($part_svc->getfield($part_svc->svcdb.'__'.$_.'_flag') ) }
+      fields($part_svc->svcdb)
   ) {
-    my $flag = $self->getfield($part_svc->svcdb.'__'.$field.'_flag');
+    my $flag = $part_svc->getfield($part_svc->svcdb.'__'.$field.'_flag');
     if ( uc($flag) =~ /^([DF])$/ ) {
-      $part_svc_column->setfield('columnflag', $1);
-      $part_svc_column->setfield('columnvalue',
-        $self->getfield($part_svc->svcdb.'__'.$field)
-      );
-      $error = $part_svc_column->insert;
-    } else {
-      $error = $part_svc_column->delete;
+      my $part_svc_column = new FS::part_svc_column {
+        'svcpart' => $part_svc->svcpart,
+        'columnname' => $field,
+        'columnflag' => $1,
+        'columnvalue' => $part_svc->getfield($part_svc->svcdb.'__'.$field),
+      };
+      my $error = $part_svc_column->insert;
+      if ( $error ) {
+        $dbh->rollback if $oldAutoCommit;
+        die $error;
+      }
     }
-    if ( $error ) {
-      $dbh->rollback if $oldAutoCommit;
-      die $error;
-    }
-
   }
 }
 
+$dbh->commit or die $dbh->errstr;
+
 sub usage {
   die "Usage:\n  fs-migrate-part_svc user\n"; 
 }
index 03b5a04..9534eb2 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -Tw
 #
-# $Id: fs-setup,v 1.56 2001-09-08 00:28:49 khoff Exp $
+# $Id: fs-setup,v 1.57 2001-09-11 00:07:30 ivan Exp $
 
 #to delay loading dbdef until we're ready
 BEGIN { $FS::Record::setup_hack = 1; }
@@ -768,6 +768,28 @@ sub tables_hash_hack {
       'index'       => [ [ 'portnum' ] ],
     },
 
+    'queue' => {
+      'columns' => [
+        'jobnum', 'int', '', '',
+        'job', 'varchar', '', '',
+        '_date', 'int', '', '',
+        'status', 'varchar', '', $char_d,
+      ],
+      'primary_key' => 'jobnum',
+      'unique'      => [],
+      'index'       => [],
+    },
+
+    'queue_arg' => {
+      'columns' => [
+        'argnum', 'int', '', '',
+        'jobnum', 'int', '', '',
+        'arg', 'varchar', 'NULL', '',
+      ],
+      'primary_key' => 'argnum',
+      'unique'      => [],
+      'index'       => [ [ 'jobnum' ] ],
+    },
   );
 
   %tables;