chiark / gitweb /
Actual locking and conflict handling
[ypp-sc-tools.web-live.git] / yarrg / commod-email-processor
index d2f0e819f6ef8c0f41626424fe13beb624d4f088..ec4f222dcedb25abba947181d5d6a554b2ba9aab 100755 (executable)
@@ -49,6 +49,12 @@ use strict (qw(vars));
 use POSIX;
 use MIME::Parser;
 
+BEGIN {
+    my $selfdir= $0;
+    $selfdir =~ s,/+[^/]*$,,;
+    chdir("$selfdir") or die "$selfdir $!";
+}
+
 use Commods;
 use CommodsDatabase;
 
@@ -111,7 +117,9 @@ sub main () {
     db_setocean($md{'ocean'});
     my $dbfn= db_filename();
     (stat $dbfn) or die "stat database $dbfn failed $!\n";
+    db_writer();
     db_connect();
+    db_onconflict(sub { print STDERR "temporary failure: @_\n"; exit 75; });
 
     my ($islandid) = $dbh->selectrow_array(
               "SELECT islands.islandid