Browse Source

Tweaks to launcher. Takes optional log_folder and epoch_duration as parameters; used in the experiment scripts

Sajin 1 year ago
parent
commit
e334d414bb
1 changed files with 28 additions and 8 deletions
  1. 28 8
      App/launch

+ 28 - 8
App/launch

@@ -19,23 +19,39 @@ PUBKEYS = "pubkeys.yaml"
 # The TEEMS binary
 TEEMS = "./teems"
 
-def launch(node, manifest, config, cmd):
+def launch(node, manifest, config, cmd, log_folder, epoch_time):
     manifestdata = manifest[node]
     cmdline = ''
     if 'launchprefix' in manifestdata:
         cmdline = manifestdata['launchprefix'] + ' '
     cmdline += TEEMS + " -k %s -n %s" % (manifestdata['sprvfile'], node)
+
+    if(epoch_time):
+        cmdline+= ' -e ' + str(epoch_time)
+
     if 'args' in manifestdata:
         cmdline += ' ' + manifestdata['args']
+
+    log_name = None
+    stdout_file = subprocess.PIPE
+    if(log_folder):
+        log_name = log_folder + node + ".log"
+        stdout_file = open(log_name, "a+")
+
+    print(cmdline)
     proc = subprocess.Popen(shlex.split(cmdline) + cmd,
-        stdin=subprocess.PIPE, stdout=subprocess.PIPE,
+        stdin=subprocess.PIPE, stdout=stdout_file,
         stderr=subprocess.STDOUT, bufsize=0)
     proc.stdin.write(config.encode('utf-8'))
-    while True:
-        line = proc.stdout.readline()
-        if not line:
-            break
-        print(node + ": " + line.decode('utf-8'), end='', flush=True)
+
+    if(log_folder == None):
+        while True:
+            line = proc.stdout.readline()
+            if not line:
+                break
+            print(node + ": " + line.decode('utf-8'), end='', flush=True)
+    else:
+        stdout_file.close()
 
 
 if __name__ == "__main__":
@@ -58,6 +74,10 @@ if __name__ == "__main__":
         help='override max number of outgoing public messages per user per epoch')
     aparse.add_argument('-c', default=None,
         help='override max number of incoming public messages per user per epoch')
+    aparse.add_argument('-l', default=None,
+        help='log folder to store logs of each server in an experiment')
+    aparse.add_argument('-e', default=None,
+        help='Set epoch interval time in seconds')
     aparse.add_argument('-n', nargs='*', help='nodes to include')
     aparse.add_argument('cmd', nargs='*', help='experiment to run')
     args = aparse.parse_args()
@@ -91,7 +111,7 @@ if __name__ == "__main__":
         if node == "params":
             continue
         thread = threading.Thread(target=launch,
-            args=(node, manifest, config, args.cmd))
+            args=(node, manifest, config, args.cmd, args.l, args.e))
         thread.start()
         threadlist.append(thread)