]> git.treefish.org Git - photosort.git/blobdiff - src/photosort-daemon.py
fixing bunch cache dir passing
[photosort.git] / src / photosort-daemon.py
index 9bb7213dc66dfd395dc9c0ccae1c51f4b6976ff0..523d8cfedface2fe7719d25f2a558e1031dcfa1b 100755 (executable)
@@ -5,6 +5,7 @@ import json
 import logging
 import os
 import signal
+import sys
 import time
 
 from bunch import Bunch
@@ -30,19 +31,28 @@ logging.basicConfig(format='[%(asctime)s] %(levelname)s: %(message)s',
                     level=logging.getLevelName(args.log_lvl),
                     datefmt='%m/%d/%Y %H:%M:%S')
 
+status = 0
+
 with open(args.config_file) as f:
     cfg = json.load(f)
 
+bunch_idx = 1
 bunches = []
 for bunch_cfg in cfg['bunches']:
-    bunches.append( Bunch(bunch_cfg) )
-
+    bunches.append( Bunch(bunch_idx, cfg['cache_dir'], bunch_cfg) )
+    bunch_idx += 1
 
 for bunch in bunches:
     bunch.start()
 
 while not stop:
+    for bunch in bunches:
+        if not bunch.is_running():
+            stop = True
+            status = 1
     time.sleep(2.0)
 
 for bunch in bunches:
     bunch.stop()
+
+sys.exit(status)