-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
def pre_load_schemas(): | ||
""" | ||
Can be called in https://docs.gunicorn.org/en/stable/settings.html#pre-fork | ||
to pre-load the all sites schema's on all workers. | ||
""" | ||
from frappe.utils import get_sites | ||
from frappe import init_site, init, connect, get_installed_apps, destroy | ||
with init_site(): | ||
sites = get_sites() | ||
|
||
for site in sites: | ||
import frappe | ||
frappe.local.initialised = False | ||
init(site=site) | ||
connect(site) | ||
if "frappe_graphql" not in get_installed_apps(): | ||
continue | ||
try: | ||
from frappe_graphql import get_schema | ||
get_schema() | ||
except Exception: | ||
print(f"Failed to build schema for site {site}") | ||
finally: | ||
destroy() |