Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set AYON_SITE_ID environment variable on boot #88

Merged
merged 2 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion common/ayon_common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from uuid import UUID

import appdirs
from ayon_api.constants import SITE_ID_ENV_KEY

DATE_FMT = "%Y-%m-%d %H:%M:%S"
CLEANUP_INTERVAL = 2 # days
Expand Down Expand Up @@ -85,7 +86,7 @@ def get_local_site_id():
"""

# used for background syncing
site_id = os.environ.get("AYON_SITE_ID")
site_id = os.environ.get(SITE_ID_ENV_KEY)
if site_id:
return site_id

Expand Down
23 changes: 14 additions & 9 deletions start.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,14 +289,12 @@ def _print(message: str):
set_default_settings_variant,
get_addons_studio_settings,
)
from ayon_api.constants import SERVER_URL_ENV_KEY, SERVER_API_ENV_KEY
# Kept for backwards compatibility of older ayon-python-api in case older
# is used.
try:
from ayon_api.constants import DEFAULT_VARIANT_ENV_KEY
except ImportError:
DEFAULT_VARIANT_ENV_KEY = "AYON_DEFAULT_SETTINGS_VARIANT"

from ayon_api.constants import (
SERVER_URL_ENV_KEY,
SERVER_API_ENV_KEY,
DEFAULT_VARIANT_ENV_KEY,
SITE_ID_ENV_KEY,
)
from ayon_common import is_staging_enabled, is_dev_mode_enabled
from ayon_common.connection.credentials import (
ask_to_login_ui,
Expand All @@ -315,7 +313,10 @@ def _print(message: str):
UpdateWindowManager,
)

from ayon_common.utils import store_current_executable_info
from ayon_common.utils import (
store_current_executable_info,
get_local_site_id,
)
from ayon_common.startup import show_startup_error


Expand Down Expand Up @@ -644,6 +645,10 @@ def _start_distribution():
def boot():
"""Bootstrap AYON."""

# Setup site id in environment variable for all possible subprocesses
if SITE_ID_ENV_KEY not in os.environ:
os.environ[SITE_ID_ENV_KEY] = get_local_site_id()

_connect_to_ayon_server()
create_global_connection()
_start_distribution()
Expand Down