]> git.ipfire.org Git - ipfire.org.git/commitdiff
ipfire.org: Start async loop before running anything else
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 26 Oct 2023 08:14:20 +0000 (08:14 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 26 Oct 2023 08:14:20 +0000 (08:14 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/scripts/ipfire.org.in

index f74e0816c07624d60cafdcd786772808fc922898..fa81706126b8b0ae18a023c72e1d9894bafc9464 100644 (file)
@@ -1,32 +1,13 @@
 #!@PYTHON@
 
+import asyncio
 import sys
-import tornado.ioloop
 import tornado.options
 
 import ipfire
 
-class TaskRunner(object):
-       def __init__(self, *args, **kwargs):
-               self.backend = ipfire.Backend(*args, **kwargs)
-
-               # Create an IOLoop
-               self.ioloop = tornado.ioloop.IOLoop.current()
-
-       def run_task(self, name, *args, **kwargs):
-               """
-                       This method runs the task with the given name and
-                       arguments asynchronically and exits the program in
-                       case on a non-zero exit code
-               """
-               async def task():
-                       await self.backend.run_task(name, *args, **kwargs)
-
-               return self.ioloop.run_sync(task)
-
-
-def main():
-       z = TaskRunner("@configsdir@/@PACKAGE_NAME@.conf")
+async def main():
+       backend = ipfire.Backend("@configsdir@/@PACKAGE_NAME@.conf")
 
        if len(sys.argv) < 2:
                sys.stderr.write("Argument needed\n")
@@ -36,6 +17,6 @@ def main():
        args = tornado.options.parse_command_line()
 
        # Run the task
-       z.run_task(*args)
+       await backend.run_task(*args)
 
-main()
+asyncio.run(main())