Skip to content

Commit

Permalink
GH #755 - Log environment details.
Browse files Browse the repository at this point in the history
  • Loading branch information
dsuch committed Dec 9, 2023
1 parent a920fd0 commit 1543374
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions code/zato-common/src/zato/common/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ class OS_Env:
class EnvVariable:
Key_Prefix = 'Zato_Config'
Key_Missing_Suffix = '_Missing'
Log_Env_Details = 'Zato_Log_Env_Details'

# ################################################################################################################################
# ################################################################################################################################
Expand Down
25 changes: 23 additions & 2 deletions code/zato-server/src/zato/server/base/parallel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@
from zato.broker import BrokerMessageReceiver
from zato.broker.client import BrokerClient
from zato.bunch import Bunch
from zato.common.api import DATA_FORMAT, default_internal_modules, EnvFile, GENERIC, HotDeploy, IPC, KVDB as CommonKVDB, \
RATE_LIMIT, SERVER_STARTUP, SEC_DEF_TYPE, SERVER_UP_STATUS, ZatoKVDB as CommonZatoKVDB, ZATO_ODB_POOL_NAME
from zato.common.api import DATA_FORMAT, default_internal_modules, EnvFile, EnvVariable, GENERIC, HotDeploy, IPC, \
KVDB as CommonKVDB, RATE_LIMIT, SERVER_STARTUP, SEC_DEF_TYPE, SERVER_UP_STATUS, ZatoKVDB as CommonZatoKVDB, \
ZATO_ODB_POOL_NAME
from zato.common.audit import audit_pii
from zato.common.audit_log import AuditLog
from zato.common.bearer_token import BearerTokenManager
Expand Down Expand Up @@ -919,6 +920,23 @@ def handle_enmasse_auto_from(self) -> 'None':
# .. and run enmasse with each of them.
_ = commands.run_enmasse_async(file_path)

# ################################################################################################################################

def log_environment_details(self):

# First, we need to have the correct variable set ..
if asbool(os.environ.get(EnvVariable.Log_Env_Details)):

# .. now, we need to have the correct file available ..
path = ['~', 'env', 'details', 'all-zato-env-details.json']
path = os.path.join(path)
path = os.path.expanduser(path)

if os.path.exists(path):
with open(path) as f:
data = f.read()
self.logger.info(f'Environment details:\n{d}')

# ################################################################################################################################

@staticmethod
Expand Down Expand Up @@ -1223,6 +1241,9 @@ def start_server(parallel_server:'ParallelServer', zato_deployment_key:'str'='')
if self.deploy_auto_from:
self.handle_enmasse_auto_from()

# Optionally, if we appear to be a Docker quickstart environment, log all details about the environment.
self.log_environment_details()

logger.info('Started `%s@%s` (pid: %s)', server.name, server.cluster.name, self.pid)

# ################################################################################################################################
Expand Down

0 comments on commit 1543374

Please sign in to comment.