##// END OF EJS Templates
exc_tracker: allow setting custom store via .ini file...
marcink -
r3019:e2100892 stable
parent child Browse files
Show More
@@ -292,6 +292,10 b' supervisor.group_id = dev'
292 ## Display extended labs settings
292 ## Display extended labs settings
293 labs_settings_active = true
293 labs_settings_active = true
294
294
295 ## custom exception store path, defaults to TMPDIR
296 exception_store_path =
297
298
295 ####################################
299 ####################################
296 ### CELERY CONFIG ####
300 ### CELERY CONFIG ####
297 ####################################
301 ####################################
@@ -267,6 +267,10 b' supervisor.group_id = prod'
267 ## Display extended labs settings
267 ## Display extended labs settings
268 labs_settings_active = true
268 labs_settings_active = true
269
269
270 ## custom exception store path, defaults to TMPDIR
271 exception_store_path =
272
273
270 ####################################
274 ####################################
271 ### CELERY CONFIG ####
275 ### CELERY CONFIG ####
272 ####################################
276 ####################################
@@ -73,10 +73,16 b' class ExceptionsTrackerView(BaseAppView)'
73
73
74 if read_metadata:
74 if read_metadata:
75 full_path = os.path.join(exc_store_path, fname)
75 full_path = os.path.join(exc_store_path, fname)
76 if not os.path.isfile(full_path):
77 continue
78 try:
76 # we can read our metadata
79 # we can read our metadata
77 with open(full_path, 'rb') as f:
80 with open(full_path, 'rb') as f:
78 exc_metadata = exc_tracking.exc_unserialize(f.read())
81 exc_metadata = exc_tracking.exc_unserialize(f.read())
79 exc.update(exc_metadata)
82 exc.update(exc_metadata)
83 except Exception:
84 log.exception('Failed to read exc data from:{}'.format(full_path))
85 pass
80
86
81 # convert our timestamp to a date obj, for nicer representation
87 # convert our timestamp to a date obj, for nicer representation
82 exc['exc_utc_date'] = time_to_utcdatetime(exc['exc_timestamp'])
88 exc['exc_utc_date'] = time_to_utcdatetime(exc['exc_timestamp'])
@@ -436,6 +436,7 b' def _sanitize_vcs_settings(settings):'
436
436
437
437
438 def _sanitize_cache_settings(settings):
438 def _sanitize_cache_settings(settings):
439
439 default_cache_dir = os.path.join(tempfile.gettempdir(), 'rc_cache')
440 default_cache_dir = os.path.join(tempfile.gettempdir(), 'rc_cache')
440
441
441 # save default, cache dir, and use it for all backends later.
442 # save default, cache dir, and use it for all backends later.
@@ -448,6 +449,12 b' def _sanitize_cache_settings(settings):'
448 if not os.path.isdir(default_cache_dir):
449 if not os.path.isdir(default_cache_dir):
449 os.makedirs(default_cache_dir, mode=0755)
450 os.makedirs(default_cache_dir, mode=0755)
450
451
452 # exception store cache
453 _string_setting(
454 settings,
455 'exception_store_path',
456 default_cache_dir, lower=False)
457
451 # cache_perms
458 # cache_perms
452 _string_setting(
459 _string_setting(
453 settings,
460 settings,
@@ -31,6 +31,7 b' log = logging.getLogger(__name__)'
31
31
32 # NOTE: Any changes should be synced with exc_tracking at vcsserver.lib.exc_tracking
32 # NOTE: Any changes should be synced with exc_tracking at vcsserver.lib.exc_tracking
33 global_prefix = 'rhodecode'
33 global_prefix = 'rhodecode'
34 exc_store_dir_name = 'rc_exception_store_v1'
34
35
35
36
36 def exc_serialize(exc_id, tb, exc_type):
37 def exc_serialize(exc_id, tb, exc_type):
@@ -54,13 +55,10 b' def get_exc_store():'
54 """
55 """
55 Get and create exception store if it's not existing
56 Get and create exception store if it's not existing
56 """
57 """
57 exc_store_dir = 'rc_exception_store_v1'
58 import rhodecode as app
58 # fallback
59 _exc_store_path = os.path.join(tempfile.gettempdir(), exc_store_dir)
60
59
61 exc_store_dir = '' # TODO: need a persistent cross instance store here
60 exc_store_dir = app.CONFIG.get('exception_store_path', '') or tempfile.gettempdir()
62 if exc_store_dir:
61 _exc_store_path = os.path.join(exc_store_dir, exc_store_dir_name)
63 _exc_store_path = os.path.join(exc_store_dir, exc_store_dir)
64
62
65 _exc_store_path = os.path.abspath(_exc_store_path)
63 _exc_store_path = os.path.abspath(_exc_store_path)
66 if not os.path.isdir(_exc_store_path):
64 if not os.path.isdir(_exc_store_path):
General Comments 0
You need to be logged in to leave comments. Login now