Index: trunk/ippToPsps/jython/load.py
===================================================================
--- trunk/ippToPsps/jython/load.py	(revision 33293)
+++ trunk/ippToPsps/jython/load.py	(revision 33294)
@@ -5,8 +5,8 @@
 #
 
+import signal
 import time
 import sys
 import os
-import socket
 import logging.config
 
@@ -115,4 +115,7 @@
         batch.run()
 
+        # check that we should continue
+        checkClientStatus()
+
         ippToPspsDb.lockBatchTable()
 
@@ -123,4 +126,39 @@
 
     ippToPspsDb.unlockTables()
+
+'''
+Handler for Ctrl-C signal
+'''
+def signal_handler(signal, frame):
+
+    exitProgram("Ctrl-C")
+
+'''
+Cleanly exits program, prints to log the way it exited
+'''
+def exitProgram(exiType):
+
+    logger.infoPair("Program exited", exiType)
+    ippToPspsDb.removeClient(logger.host, logger.pid)
+    sys.exit(0)
+
+
+'''
+Checks if we should pause or kill loading, otherwise updates the clients table with current time
+'''
+def checkClientStatus():
+
+    ippToPspsDb.updateClient(logger.host, logger.pid)
+
+    if ippToPspsDb.isKilled(logger.host, logger.pid): exitProgram("killed")
+
+    PAUSEPERIOD = 60
+    while ippToPspsDb.isPaused(logger.host, logger.pid):
+
+        ippToPspsDb.updateClient(logger.host, logger.pid)
+        if ippToPspsDb.isKilled(logger.host, logger.pid): exitProgram("killed while paused")
+        logger.infoPair("Program paused for", "%d secs" % PAUSEPERIOD)
+        time.sleep(PAUSEPERIOD)
+
 
 '''
@@ -139,6 +177,5 @@
 # open config file
 config = Config(CONFIGPATH)
-#logger = config.getLogger(sys.argv[0], 0, 1)
-logger = config.getLogger(sys.argv[0])
+logger = config.getLogger(sys.argv[0], 1, 1)
 
 # create various objects
@@ -148,9 +185,13 @@
 datastore = Datastore(logger, config, ippToPspsDb)
 
+checkClientStatus()
+
+# catch Ctrl-C signal
+signal.signal(signal.SIGINT, signal_handler)
+
 # check we connected ok
 if not gpc1Db.everythingOK: sys.exit(1)
 if not ippToPspsDb.everythingOK: sys.exit(1)
 
-# get values from the configutaion file
 POLLPERIOD = 600
 
@@ -178,4 +219,5 @@
    sys.exit(1)
 
+
 '''
 Main processing loop:
@@ -206,4 +248,6 @@
 
        while dec <= config.maxDec:
+
+           checkClientStatus()
 
            # for each batch type
@@ -228,5 +272,5 @@
 
                # do we pre-ingest stuff from DVO?
-               if smfsPerGB > 0:
+               if smfsPerGB > 40:
                    if not dvo.sync():
                        logger.errorPair("Could not sync DVO with MySQL", "skipping")
@@ -238,5 +282,5 @@
                logger.infoBool("Using pre-ingested DVO data?", useFullTables)
                processTheseItems(batchType, ids, useFullTables)
-               
+          
                # in the test mode, we quit after submitting one batch
                if config.test: break
@@ -253,3 +297,4 @@
     time.sleep(POLLPERIOD)
 
-
+exitProgram("end of program")
+
