Browse Source

Improve the runworker script so it accepts task module and queue name

This is most useful if you want for example to run the tasks in the
pagure.lib.tasks_service module and with the queue load_json.

Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
Pierre-Yves Chibon 4 years ago
parent
commit
51ed35d4b7
1 changed files with 17 additions and 1 deletions
  1. 17 1
      runworker.py

+ 17 - 1
runworker.py

@@ -22,6 +22,19 @@ parser.add_argument(
     default=False,
     help="Expand the level of data returned.",
 )
+parser.add_argument(
+    "--queue",
+    dest="queue",
+    default=None,
+    help="Name of the queue to run the worker against.",
+)
+
+parser.add_argument(
+    "--tasks",
+    dest="tasks",
+    default="pagure.lib.tasks",
+    help="Class used by the workers.",
+)
 parser.add_argument(
     "--noinfo",
     dest="noinfo",
@@ -40,7 +53,10 @@ if args.config:
         config = os.path.join(here, config)
     env["PAGURE_CONFIG"] = config
 
-cmd = [sys.executable, "-m", "celery", "worker", "-A", "pagure.lib.tasks"]
+cmd = [sys.executable, "-m", "celery", "worker", "-A", args.tasks]
+
+if args.queue:
+    cmd.extend(["-Q", args.queue])
 
 if args.debug:
     cmd.append("--loglevel=debug")