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 os
from datetime import datetime
import redis
@ -47,6 +49,20 @@ class Monitor(RedisBase):
else:
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
def _create_builder():
"""create buildx builder"""
@ -139,6 +155,7 @@ class Builder(RedisBase):
if __name__ == "__main__":
handler = Monitor()
handler.bootstrap()
handler.create_queue()
handler.check_stored()
try:
handler.watch()