perf: rebuild website search index in background (#17974)
* perf: rebuild website search index in background * refactor: allow enqueueing jobs during migrate This was added a long time ago to handle missing redis during migrate. It is not the case right now as redis HAS to be availabe during migration. ref: https://github.com/frappe/frappe/pull/2988 * ci: pass correct build type * chore: warn about redis unavailability
This commit is contained in:
parent
86c6244a88
commit
fbee80f734
3 changed files with 13 additions and 7 deletions
2
.github/workflows/ui-tests.yml
vendored
2
.github/workflows/ui-tests.yml
vendored
|
|
@ -30,7 +30,7 @@ jobs:
|
|||
run: |
|
||||
python "${GITHUB_WORKSPACE}/.github/helper/roulette.py"
|
||||
env:
|
||||
TYPE: "server"
|
||||
TYPE: "ui"
|
||||
PR_NUMBER: ${{ github.event.number }}
|
||||
REPO_NAME: ${{ github.repository }}
|
||||
|
||||
|
|
|
|||
|
|
@ -89,8 +89,8 @@ class SiteMigration:
|
|||
json.dump(list(frappe.flags.touched_tables), f, sort_keys=True, indent=4)
|
||||
|
||||
if not self.skip_search_index:
|
||||
print(f"Building search index for {frappe.local.site}")
|
||||
build_index_for_all_routes()
|
||||
print(f"Queued rebuilding of search index for {frappe.local.site}")
|
||||
frappe.enqueue(build_index_for_all_routes, queue="long")
|
||||
|
||||
frappe.publish_realtime("version-update")
|
||||
frappe.flags.touched_tables.clear()
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import socket
|
|||
import time
|
||||
from collections import defaultdict
|
||||
from functools import lru_cache
|
||||
from typing import TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, Any
|
||||
from uuid import uuid4
|
||||
|
||||
import redis
|
||||
|
|
@ -55,7 +55,7 @@ def enqueue(
|
|||
*,
|
||||
at_front=False,
|
||||
**kwargs,
|
||||
) -> "Job":
|
||||
) -> "Job" | Any:
|
||||
"""
|
||||
Enqueue method to be executed using a background worker
|
||||
|
||||
|
|
@ -78,11 +78,17 @@ def enqueue(
|
|||
)
|
||||
)
|
||||
|
||||
call_directly = now or frappe.flags.in_migrate or (not is_async and not frappe.flags.in_test)
|
||||
call_directly = now or (not is_async and not frappe.flags.in_test)
|
||||
if call_directly:
|
||||
return frappe.call(method, **kwargs)
|
||||
|
||||
q = get_queue(queue, is_async=is_async)
|
||||
try:
|
||||
q = get_queue(queue, is_async=is_async)
|
||||
except ConnectionError:
|
||||
# If redis is not available for queueing execute the job directly
|
||||
print(f"Redis queue is unreachable: Executing {method} synchronously")
|
||||
return frappe.call(method, **kwargs)
|
||||
|
||||
if not timeout:
|
||||
timeout = get_queues_timeout().get(queue) or 300
|
||||
queue_args = {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue