Explorar o código

Auto-detect all services to execute

Yentl Van Tendeloo %!s(int64=8) %!d(string=hai) anos
pai
achega
66d4c48277
Modificáronse 2 ficheiros con 22 adicións e 18 borrados
  1. 21 17
      scripts/run_local_modelverse.py
  2. 1 1
      wrappers/modelverse_SCCD.py

+ 21 - 17
scripts/run_local_modelverse.py

@@ -8,36 +8,40 @@ if len(sys.argv) < 2:
 else:
 else:
     port = sys.argv[1]
     port = sys.argv[1]
 
 
-# Start up the HUTN compilation service already
 try:
 try:
-    hutn = subprocess.Popen([sys.executable, "services/HUTN/main.py", "127.0.0.1:%s" % port])
-    json = subprocess.Popen([sys.executable, "services/JSON/main.py", "127.0.0.1:%s" % port])
-
+    # Compile all SCCD models first
     os.chdir("wrappers")
     os.chdir("wrappers")
     subprocess.check_call([sys.executable, "-m", "sccd.compiler.sccdc", "-p", "threads", "modelverse_SCCD.xml"])
     subprocess.check_call([sys.executable, "-m", "sccd.compiler.sccdc", "-p", "threads", "modelverse_SCCD.xml"])
 
 
     os.chdir("../hybrid_server")
     os.chdir("../hybrid_server")
     subprocess.check_call([sys.executable, "-m", "sccd.compiler.sccdc", "-p", "threads", "server.xml"])
     subprocess.check_call([sys.executable, "-m", "sccd.compiler.sccdc", "-p", "threads", "server.xml"])
 
 
-    program_to_execute = [sys.executable, "run_mvk_server.py", port]
+    os.chdir("..")
 
 
-    # Alternative execution modes
-    #program_to_execute = [sys.executable, "-m", "cProfile", "-s", "tottime", "run_mvk_server.py", port]
-    #program_to_execute = [sys.executable, "run_mvk_server.py", port, "--kernel=interpreter"]
-    #program_to_execute = [sys.executable, "run_mvk_server.py", port, "--kernel=fast-jit"]
+    # Start up all services with auto-detection
+    import glob
+    service_paths = glob.glob("services/*/main.py")
+    services = []
+    for service_path in service_paths:
+        print("[SERVICE] loaded " + service_path)
+        service = subprocess.Popen([sys.executable, service_path, "127.0.0.1:%s" % port])
+        services.append(service)
 
 
+    os.chdir("hybrid_server")
+    program_to_execute = [sys.executable, "run_mvk_server.py", port]
     server = subprocess.Popen(program_to_execute)
     server = subprocess.Popen(program_to_execute)
+
     server.wait()
     server.wait()
 finally:
 finally:
+    # Stop the server
     try:
     try:
         server.terminate()
         server.terminate()
     except:
     except:
         pass
         pass
-    try:
-        hutn.terminate()
-    except:
-        pass
-    try:
-        json.terminate()
-    except:
-        pass
+
+    # Terminate all services as well
+    for service in services:
+        try:
+            service.terminate()
+        except:
+            pass

+ 1 - 1
wrappers/modelverse_SCCD.py

@@ -1,7 +1,7 @@
 """
 """
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
 
-Date:   Thu Nov  9 11:12:35 2017
+Date:   Thu Nov  9 11:20:24 2017
 
 
 Model author: Yentl Van Tendeloo
 Model author: Yentl Van Tendeloo
 Model name:   MvK Server
 Model name:   MvK Server