mirror of
https://github.com/ansible/awx.git
synced 2026-02-23 14:05:59 -03:30
fill in postgres application_name on connection
* Tried to fill in application_name in awx/__init__.py but I think that is too late * Fill in database application_name with enough information to easily trace the connection from postgres back to the node and pid that initiated the connection. * Set application_name in django settings so that application_name is set _before_ the first postgres connection is established.
This commit is contained in:
@@ -8,5 +8,7 @@ class Command(MakeMigrations):
|
|||||||
def execute(self, *args, **options):
|
def execute(self, *args, **options):
|
||||||
settings = connections['default'].settings_dict.copy()
|
settings = connections['default'].settings_dict.copy()
|
||||||
settings['ENGINE'] = 'sqlite3'
|
settings['ENGINE'] = 'sqlite3'
|
||||||
|
if 'application_name' in settings['OPTIONS']:
|
||||||
|
del settings['OPTIONS']['application_name']
|
||||||
connections['default'] = DatabaseWrapper(settings)
|
connections['default'] = DatabaseWrapper(settings)
|
||||||
return MakeMigrations().execute(*args, **options)
|
return MakeMigrations().execute(*args, **options)
|
||||||
|
|||||||
@@ -184,3 +184,6 @@ else:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
AWX_CALLBACK_PROFILE = True
|
AWX_CALLBACK_PROFILE = True
|
||||||
|
|
||||||
|
if 'sqlite3' not in DATABASES['default']['ENGINE']: # noqa
|
||||||
|
DATABASES['default'].setdefault('OPTIONS', dict()).setdefault('application_name', f'{CLUSTER_HOST_ID}-{os.getpid()}-{" ".join(sys.argv)}'[:63]) # noqa
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ except IOError:
|
|||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
# The below runs AFTER all of the custom settings are imported.
|
||||||
|
|
||||||
CELERYBEAT_SCHEDULE.update({ # noqa
|
CELERYBEAT_SCHEDULE.update({ # noqa
|
||||||
'isolated_heartbeat': {
|
'isolated_heartbeat': {
|
||||||
@@ -110,3 +111,5 @@ CELERYBEAT_SCHEDULE.update({ # noqa
|
|||||||
'options': {'expires': AWX_ISOLATED_PERIODIC_CHECK * 2}, # noqa
|
'options': {'expires': AWX_ISOLATED_PERIODIC_CHECK * 2}, # noqa
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
DATABASES['default'].setdefault('OPTIONS', dict()).setdefault('application_name', f'{CLUSTER_HOST_ID}-{os.getpid()}-{" ".join(sys.argv)}'[:63]) # noqa
|
||||||
|
|||||||
Reference in New Issue
Block a user