Skip to content

Commit

Permalink
fix: Allow both sync and async worker allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
adityahase committed Jun 25, 2024
1 parent fbbddfd commit 4eacc78
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions press/press/doctype/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1481,18 +1481,21 @@ def is_shared(self) -> bool:
)


def scale_workers():
def scale_workers(now=False):
servers = frappe.get_all("Server", {"status": "Active", "is_primary": True})
for server in servers:
try:
frappe.enqueue_doc(
"Server",
server.name,
method="auto_scale_workers",
job_id=f"auto_scale_workers:{server.name}",
deduplicate=True,
enqueue_after_commit=True,
)
if now:
frappe.get_doc("Server", server.name).auto_scale_workers()
else:
frappe.enqueue_doc(
"Server",
server.name,
method="auto_scale_workers",
job_id=f"auto_scale_workers:{server.name}",
deduplicate=True,
enqueue_after_commit=True,
)
frappe.db.commit()
except Exception:
log_error("Auto Scale Worker Error", server=server)
Expand Down

0 comments on commit 4eacc78

Please sign in to comment.