]> glassweightruler.freedombox.rocks Git - waydroid.git/blobdiff - tools/actions/container_manager.py
container_manager: Add fail exit to make sure container is started
[waydroid.git] / tools / actions / container_manager.py
index 994dceab4fcee7da96815183a5fcb74b68b36689..ce04180b1414f1fdf478c888bd27b93effc184e1 100644 (file)
@@ -126,7 +126,7 @@ def start(args):
 
         # Sensors
         tools.helpers.run.root(
-            args, ["waydroid-sensord", args.HWBINDER_DRIVER], output="background")
+            args, ["waydroid-sensord", "/dev/" + args.HWBINDER_DRIVER], output="background")
 
         # Mount rootfs
         helpers.images.mount_rootfs(args, cfg["waydroid"]["images_path"])
@@ -151,6 +151,15 @@ def start(args):
         
         helpers.lxc.start(args)
         session_cfg["session"]["state"] = helpers.lxc.status(args)
+        timeout = 10
+        while session_cfg["session"]["state"] != "RUNNING" and timeout > 0:
+            session_cfg["session"]["state"] = helpers.lxc.status(args)
+            logging.info(
+                "waiting {} seconds for container to start...".format(timeout))
+            timeout = timeout - 1
+            time.sleep(1)
+        if session_cfg["session"]["state"] != "RUNNING":
+            raise OSError("container failed to start")
         tools.config.save_session(session_cfg)
 
         if not hasattr(args, 'hardwareLoop'):
@@ -198,7 +207,7 @@ def stop(args):
             command = ["pidof", "waydroid-sensord"]
             pid = tools.helpers.run.root(args, command, check=False, output_return=True)
             if pid:
-                command = ["killall", pid]
+                command = ["kill", "-9", pid]
                 tools.helpers.run.root(args, command, check=False)
 
     else: