call create_queue in builder too

This commit is contained in:
simon 2022-12-19 15:14:56 +07:00
parent 6451e1c51f
commit fcceab3150
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4

View File

@ -4,6 +4,8 @@ import json
import subprocess import subprocess
import os import os
from datetime import datetime
import redis import redis
@ -47,6 +49,20 @@ class Monitor(RedisBase):
else: else:
print("tubearchivist builder already created") print("tubearchivist builder already created")
def create_queue(self):
"""set initial json object for queue"""
if self.conn.execute_command(f"EXISTS {self.TASK_KEY}"):
print(f"{self.TASK_KEY} already exists")
return
message = {
"created": int(datetime.now().strftime("%s")),
"tasks": {}
}
self.conn.execute_command(
"JSON.SET", self.TASK_KEY, ".", json.dumps(message)
)
@staticmethod @staticmethod
def _create_builder(): def _create_builder():
"""create buildx builder""" """create buildx builder"""
@ -139,6 +155,7 @@ class Builder(RedisBase):
if __name__ == "__main__": if __name__ == "__main__":
handler = Monitor() handler = Monitor()
handler.bootstrap() handler.bootstrap()
handler.create_queue()
handler.check_stored() handler.check_stored()
try: try:
handler.watch() handler.watch()