exc_tracker: allow setting custom store via .ini file
- use safer exc read when listing exceptions.
This commit is contained in:
parent
eed089baa7
commit
19d4c6901b
5 changed files with 29 additions and 10 deletions
|
|
@ -292,6 +292,10 @@ supervisor.group_id = dev
|
|||
## Display extended labs settings
|
||||
labs_settings_active = true
|
||||
|
||||
## custom exception store path, defaults to TMPDIR
|
||||
exception_store_path =
|
||||
|
||||
|
||||
####################################
|
||||
### CELERY CONFIG ####
|
||||
####################################
|
||||
|
|
|
|||
|
|
@ -267,6 +267,10 @@ supervisor.group_id = prod
|
|||
## Display extended labs settings
|
||||
labs_settings_active = true
|
||||
|
||||
## custom exception store path, defaults to TMPDIR
|
||||
exception_store_path =
|
||||
|
||||
|
||||
####################################
|
||||
### CELERY CONFIG ####
|
||||
####################################
|
||||
|
|
|
|||
|
|
@ -73,10 +73,16 @@ class ExceptionsTrackerView(BaseAppView):
|
|||
|
||||
if read_metadata:
|
||||
full_path = os.path.join(exc_store_path, fname)
|
||||
# we can read our metadata
|
||||
with open(full_path, 'rb') as f:
|
||||
exc_metadata = exc_tracking.exc_unserialize(f.read())
|
||||
exc.update(exc_metadata)
|
||||
if not os.path.isfile(full_path):
|
||||
continue
|
||||
try:
|
||||
# we can read our metadata
|
||||
with open(full_path, 'rb') as f:
|
||||
exc_metadata = exc_tracking.exc_unserialize(f.read())
|
||||
exc.update(exc_metadata)
|
||||
except Exception:
|
||||
log.exception('Failed to read exc data from:{}'.format(full_path))
|
||||
pass
|
||||
|
||||
# convert our timestamp to a date obj, for nicer representation
|
||||
exc['exc_utc_date'] = time_to_utcdatetime(exc['exc_timestamp'])
|
||||
|
|
|
|||
|
|
@ -436,6 +436,7 @@ def _sanitize_vcs_settings(settings):
|
|||
|
||||
|
||||
def _sanitize_cache_settings(settings):
|
||||
|
||||
default_cache_dir = os.path.join(tempfile.gettempdir(), 'rc_cache')
|
||||
|
||||
# save default, cache dir, and use it for all backends later.
|
||||
|
|
@ -448,6 +449,12 @@ def _sanitize_cache_settings(settings):
|
|||
if not os.path.isdir(default_cache_dir):
|
||||
os.makedirs(default_cache_dir, mode=0755)
|
||||
|
||||
# exception store cache
|
||||
_string_setting(
|
||||
settings,
|
||||
'exception_store_path',
|
||||
default_cache_dir, lower=False)
|
||||
|
||||
# cache_perms
|
||||
_string_setting(
|
||||
settings,
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ log = logging.getLogger(__name__)
|
|||
|
||||
# NOTE: Any changes should be synced with exc_tracking at vcsserver.lib.exc_tracking
|
||||
global_prefix = 'rhodecode'
|
||||
exc_store_dir_name = 'rc_exception_store_v1'
|
||||
|
||||
|
||||
def exc_serialize(exc_id, tb, exc_type):
|
||||
|
|
@ -54,13 +55,10 @@ def get_exc_store():
|
|||
"""
|
||||
Get and create exception store if it's not existing
|
||||
"""
|
||||
exc_store_dir = 'rc_exception_store_v1'
|
||||
# fallback
|
||||
_exc_store_path = os.path.join(tempfile.gettempdir(), exc_store_dir)
|
||||
import rhodecode as app
|
||||
|
||||
exc_store_dir = '' # TODO: need a persistent cross instance store here
|
||||
if exc_store_dir:
|
||||
_exc_store_path = os.path.join(exc_store_dir, exc_store_dir)
|
||||
exc_store_dir = app.CONFIG.get('exception_store_path', '') or tempfile.gettempdir()
|
||||
_exc_store_path = os.path.join(exc_store_dir, exc_store_dir_name)
|
||||
|
||||
_exc_store_path = os.path.abspath(_exc_store_path)
|
||||
if not os.path.isdir(_exc_store_path):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue