##// END OF EJS Templates
config: set default file-based sessions if not specified. This will prevent memory session to kick-in
super-admin -
r5185:0b667669 default
parent child Browse files
Show More
@@ -1,632 +1,637 b''
1 1 # Copyright (C) 2010-2023 RhodeCode GmbH
2 2 #
3 3 # This program is free software: you can redistribute it and/or modify
4 4 # it under the terms of the GNU Affero General Public License, version 3
5 5 # (only), as published by the Free Software Foundation.
6 6 #
7 7 # This program is distributed in the hope that it will be useful,
8 8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 10 # GNU General Public License for more details.
11 11 #
12 12 # You should have received a copy of the GNU Affero General Public License
13 13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14 14 #
15 15 # This program is dual-licensed. If you wish to learn more about the
16 16 # RhodeCode Enterprise Edition, including its added features, Support services,
17 17 # and proprietary license terms, please see https://rhodecode.com/licenses/
18 18
19 19 import os
20 20 import sys
21 21 import collections
22 22 import tempfile
23 23 import time
24 24 import logging.config
25 25
26 26 from paste.gzipper import make_gzip_middleware
27 27 import pyramid.events
28 28 from pyramid.wsgi import wsgiapp
29 29 from pyramid.authorization import ACLAuthorizationPolicy
30 30 from pyramid.config import Configurator
31 31 from pyramid.settings import asbool, aslist
32 32 from pyramid.httpexceptions import (
33 33 HTTPException, HTTPError, HTTPInternalServerError, HTTPFound, HTTPNotFound)
34 34 from pyramid.renderers import render_to_response
35 35
36 36 from rhodecode.model import meta
37 37 from rhodecode.config import patches
38 38 from rhodecode.config import utils as config_utils
39 39 from rhodecode.config.settings_maker import SettingsMaker
40 40 from rhodecode.config.environment import load_pyramid_environment
41 41
42 42 import rhodecode.events
43 43 from rhodecode.lib.middleware.vcs import VCSMiddleware
44 44 from rhodecode.lib.request import Request
45 45 from rhodecode.lib.vcs import VCSCommunicationError
46 46 from rhodecode.lib.exceptions import VCSServerUnavailable
47 47 from rhodecode.lib.middleware.appenlight import wrap_in_appenlight_if_enabled
48 48 from rhodecode.lib.middleware.https_fixup import HttpsFixup
49 49 from rhodecode.lib.plugins.utils import register_rhodecode_plugin
50 50 from rhodecode.lib.utils2 import AttributeDict
51 51 from rhodecode.lib.exc_tracking import store_exception, format_exc
52 52 from rhodecode.subscribers import (
53 53 scan_repositories_if_enabled, write_js_routes_if_enabled,
54 54 write_metadata_if_needed, write_usage_data)
55 55 from rhodecode.lib.statsd_client import StatsdClient
56 56
57 57 log = logging.getLogger(__name__)
58 58
59 59
60 60 def is_http_error(response):
61 61 # error which should have traceback
62 62 return response.status_code > 499
63 63
64 64
65 65 def should_load_all():
66 66 """
67 67 Returns if all application components should be loaded. In some cases it's
68 68 desired to skip apps loading for faster shell script execution
69 69 """
70 70 ssh_cmd = os.environ.get('RC_CMD_SSH_WRAPPER')
71 71 if ssh_cmd:
72 72 return False
73 73
74 74 return True
75 75
76 76
77 77 def make_pyramid_app(global_config, **settings):
78 78 """
79 79 Constructs the WSGI application based on Pyramid.
80 80
81 81 Specials:
82 82
83 83 * The application can also be integrated like a plugin via the call to
84 84 `includeme`. This is accompanied with the other utility functions which
85 85 are called. Changing this should be done with great care to not break
86 86 cases when these fragments are assembled from another place.
87 87
88 88 """
89 89 start_time = time.time()
90 90 log.info('Pyramid app config starting')
91 91
92 92 sanitize_settings_and_apply_defaults(global_config, settings)
93 93
94 94 # init and bootstrap StatsdClient
95 95 StatsdClient.setup(settings)
96 96
97 97 config = Configurator(settings=settings)
98 98 # Init our statsd at very start
99 99 config.registry.statsd = StatsdClient.statsd
100 100
101 101 # Apply compatibility patches
102 102 patches.inspect_getargspec()
103 103
104 104 load_pyramid_environment(global_config, settings)
105 105
106 106 # Static file view comes first
107 107 includeme_first(config)
108 108
109 109 includeme(config)
110 110
111 111 pyramid_app = config.make_wsgi_app()
112 112 pyramid_app = wrap_app_in_wsgi_middlewares(pyramid_app, config)
113 113 pyramid_app.config = config
114 114
115 115 celery_settings = get_celery_config(settings)
116 116 config.configure_celery(celery_settings)
117 117
118 118 # creating the app uses a connection - return it after we are done
119 119 meta.Session.remove()
120 120
121 121 total_time = time.time() - start_time
122 122 log.info('Pyramid app created and configured in %.2fs', total_time)
123 123 return pyramid_app
124 124
125 125
126 126 def get_celery_config(settings):
127 127 """
128 128 Converts basic ini configuration into celery 4.X options
129 129 """
130 130
131 131 def key_converter(key_name):
132 132 pref = 'celery.'
133 133 if key_name.startswith(pref):
134 134 return key_name[len(pref):].replace('.', '_').lower()
135 135
136 136 def type_converter(parsed_key, value):
137 137 # cast to int
138 138 if value.isdigit():
139 139 return int(value)
140 140
141 141 # cast to bool
142 142 if value.lower() in ['true', 'false', 'True', 'False']:
143 143 return value.lower() == 'true'
144 144 return value
145 145
146 146 celery_config = {}
147 147 for k, v in settings.items():
148 148 pref = 'celery.'
149 149 if k.startswith(pref):
150 150 celery_config[key_converter(k)] = type_converter(key_converter(k), v)
151 151
152 152 # TODO:rethink if we want to support celerybeat based file config, probably NOT
153 153 # beat_config = {}
154 154 # for section in parser.sections():
155 155 # if section.startswith('celerybeat:'):
156 156 # name = section.split(':', 1)[1]
157 157 # beat_config[name] = get_beat_config(parser, section)
158 158
159 159 # final compose of settings
160 160 celery_settings = {}
161 161
162 162 if celery_config:
163 163 celery_settings.update(celery_config)
164 164 # if beat_config:
165 165 # celery_settings.update({'beat_schedule': beat_config})
166 166
167 167 return celery_settings
168 168
169 169
170 170 def not_found_view(request):
171 171 """
172 172 This creates the view which should be registered as not-found-view to
173 173 pyramid.
174 174 """
175 175
176 176 if not getattr(request, 'vcs_call', None):
177 177 # handle like regular case with our error_handler
178 178 return error_handler(HTTPNotFound(), request)
179 179
180 180 # handle not found view as a vcs call
181 181 settings = request.registry.settings
182 182 ae_client = getattr(request, 'ae_client', None)
183 183 vcs_app = VCSMiddleware(
184 184 HTTPNotFound(), request.registry, settings,
185 185 appenlight_client=ae_client)
186 186
187 187 return wsgiapp(vcs_app)(None, request)
188 188
189 189
190 190 def error_handler(exception, request):
191 191 import rhodecode
192 192 from rhodecode.lib import helpers
193 193
194 194 rhodecode_title = rhodecode.CONFIG.get('rhodecode_title') or 'RhodeCode'
195 195
196 196 base_response = HTTPInternalServerError()
197 197 # prefer original exception for the response since it may have headers set
198 198 if isinstance(exception, HTTPException):
199 199 base_response = exception
200 200 elif isinstance(exception, VCSCommunicationError):
201 201 base_response = VCSServerUnavailable()
202 202
203 203 if is_http_error(base_response):
204 204 traceback_info = format_exc(request.exc_info)
205 205 log.error(
206 206 'error occurred handling this request for path: %s, \n%s',
207 207 request.path, traceback_info)
208 208
209 209 error_explanation = base_response.explanation or str(base_response)
210 210 if base_response.status_code == 404:
211 211 error_explanation += " Optionally you don't have permission to access this page."
212 212 c = AttributeDict()
213 213 c.error_message = base_response.status
214 214 c.error_explanation = error_explanation
215 215 c.visual = AttributeDict()
216 216
217 217 c.visual.rhodecode_support_url = (
218 218 request.registry.settings.get('rhodecode_support_url') or
219 219 request.route_url('rhodecode_support')
220 220 )
221 221 c.redirect_time = 0
222 222 c.rhodecode_name = rhodecode_title
223 223 if not c.rhodecode_name:
224 224 c.rhodecode_name = 'Rhodecode'
225 225
226 226 c.causes = []
227 227 if is_http_error(base_response):
228 228 c.causes.append('Server is overloaded.')
229 229 c.causes.append('Server database connection is lost.')
230 230 c.causes.append('Server expected unhandled error.')
231 231
232 232 if hasattr(base_response, 'causes'):
233 233 c.causes = base_response.causes
234 234
235 235 c.messages = helpers.flash.pop_messages(request=request)
236 236 exc_info = sys.exc_info()
237 237 c.exception_id = id(exc_info)
238 238 c.show_exception_id = isinstance(base_response, VCSServerUnavailable) \
239 239 or base_response.status_code > 499
240 240 c.exception_id_url = request.route_url(
241 241 'admin_settings_exception_tracker_show', exception_id=c.exception_id)
242 242
243 243 debug_mode = rhodecode.ConfigGet().get_bool('debug')
244 244 if c.show_exception_id:
245 245 store_exception(c.exception_id, exc_info)
246 246 c.exception_debug = debug_mode
247 247 c.exception_config_ini = rhodecode.CONFIG.get('__file__')
248 248
249 249 if debug_mode:
250 250 try:
251 251 from rich.traceback import install
252 252 install(show_locals=True)
253 253 log.debug('Installing rich tracebacks...')
254 254 except ImportError:
255 255 pass
256 256
257 257 response = render_to_response(
258 258 '/errors/error_document.mako', {'c': c, 'h': helpers}, request=request,
259 259 response=base_response)
260 260
261 261 response.headers["X-RC-Exception-Id"] = str(c.exception_id)
262 262
263 263 statsd = request.registry.statsd
264 264 if statsd and base_response.status_code > 499:
265 265 exc_type = f"{exception.__class__.__module__}.{exception.__class__.__name__}"
266 266 statsd.incr('rhodecode_exception_total',
267 267 tags=["exc_source:web",
268 268 f"http_code:{base_response.status_code}",
269 269 f"type:{exc_type}"])
270 270
271 271 return response
272 272
273 273
274 274 def includeme_first(config):
275 275 # redirect automatic browser favicon.ico requests to correct place
276 276 def favicon_redirect(context, request):
277 277 return HTTPFound(
278 278 request.static_path('rhodecode:public/images/favicon.ico'))
279 279
280 280 config.add_view(favicon_redirect, route_name='favicon')
281 281 config.add_route('favicon', '/favicon.ico')
282 282
283 283 def robots_redirect(context, request):
284 284 return HTTPFound(
285 285 request.static_path('rhodecode:public/robots.txt'))
286 286
287 287 config.add_view(robots_redirect, route_name='robots')
288 288 config.add_route('robots', '/robots.txt')
289 289
290 290 config.add_static_view(
291 291 '_static/deform', 'deform:static')
292 292 config.add_static_view(
293 293 '_static/rhodecode', path='rhodecode:public', cache_max_age=3600 * 24)
294 294
295 295
296 296 ce_auth_resources = [
297 297 'rhodecode.authentication.plugins.auth_crowd',
298 298 'rhodecode.authentication.plugins.auth_headers',
299 299 'rhodecode.authentication.plugins.auth_jasig_cas',
300 300 'rhodecode.authentication.plugins.auth_ldap',
301 301 'rhodecode.authentication.plugins.auth_pam',
302 302 'rhodecode.authentication.plugins.auth_rhodecode',
303 303 'rhodecode.authentication.plugins.auth_token',
304 304 ]
305 305
306 306
307 307 def includeme(config, auth_resources=None):
308 308 from rhodecode.lib.celerylib.loader import configure_celery
309 309 log.debug('Initializing main includeme from %s', os.path.basename(__file__))
310 310 settings = config.registry.settings
311 311 config.set_request_factory(Request)
312 312
313 313 # plugin information
314 314 config.registry.rhodecode_plugins = collections.OrderedDict()
315 315
316 316 config.add_directive(
317 317 'register_rhodecode_plugin', register_rhodecode_plugin)
318 318
319 319 config.add_directive('configure_celery', configure_celery)
320 320
321 321 if settings.get('appenlight', False):
322 322 config.include('appenlight_client.ext.pyramid_tween')
323 323
324 324 load_all = should_load_all()
325 325
326 326 # Includes which are required. The application would fail without them.
327 327 config.include('pyramid_mako')
328 328 config.include('rhodecode.lib.rc_beaker')
329 329 config.include('rhodecode.lib.rc_cache')
330 330 config.include('rhodecode.lib.rc_cache.archive_cache')
331 331
332 332 config.include('rhodecode.apps._base.navigation')
333 333 config.include('rhodecode.apps._base.subscribers')
334 334 config.include('rhodecode.tweens')
335 335 config.include('rhodecode.authentication')
336 336
337 337 if load_all:
338 338
339 339 # load CE authentication plugins
340 340
341 341 if auth_resources:
342 342 ce_auth_resources.extend(auth_resources)
343 343
344 344 for resource in ce_auth_resources:
345 345 config.include(resource)
346 346
347 347 # Auto discover authentication plugins and include their configuration.
348 348 if asbool(settings.get('auth_plugin.import_legacy_plugins', 'true')):
349 349 from rhodecode.authentication import discover_legacy_plugins
350 350 discover_legacy_plugins(config)
351 351
352 352 # apps
353 353 if load_all:
354 354 log.debug('Starting config.include() calls')
355 355 config.include('rhodecode.api.includeme')
356 356 config.include('rhodecode.apps._base.includeme')
357 357 config.include('rhodecode.apps._base.navigation.includeme')
358 358 config.include('rhodecode.apps._base.subscribers.includeme')
359 359 config.include('rhodecode.apps.hovercards.includeme')
360 360 config.include('rhodecode.apps.ops.includeme')
361 361 config.include('rhodecode.apps.channelstream.includeme')
362 362 config.include('rhodecode.apps.file_store.includeme')
363 363 config.include('rhodecode.apps.admin.includeme')
364 364 config.include('rhodecode.apps.login.includeme')
365 365 config.include('rhodecode.apps.home.includeme')
366 366 config.include('rhodecode.apps.journal.includeme')
367 367
368 368 config.include('rhodecode.apps.repository.includeme')
369 369 config.include('rhodecode.apps.repo_group.includeme')
370 370 config.include('rhodecode.apps.user_group.includeme')
371 371 config.include('rhodecode.apps.search.includeme')
372 372 config.include('rhodecode.apps.user_profile.includeme')
373 373 config.include('rhodecode.apps.user_group_profile.includeme')
374 374 config.include('rhodecode.apps.my_account.includeme')
375 375 config.include('rhodecode.apps.gist.includeme')
376 376
377 377 config.include('rhodecode.apps.svn_support.includeme')
378 378 config.include('rhodecode.apps.ssh_support.includeme')
379 379 config.include('rhodecode.apps.debug_style')
380 380
381 381 if load_all:
382 382 config.include('rhodecode.integrations.includeme')
383 383 config.include('rhodecode.integrations.routes.includeme')
384 384
385 385 config.add_route('rhodecode_support', 'https://rhodecode.com/help/', static=True)
386 386 settings['default_locale_name'] = settings.get('lang', 'en')
387 387 config.add_translation_dirs('rhodecode:i18n/')
388 388
389 389 # Add subscribers.
390 390 if load_all:
391 391 log.debug('Adding subscribers....')
392 392 config.add_subscriber(scan_repositories_if_enabled,
393 393 pyramid.events.ApplicationCreated)
394 394 config.add_subscriber(write_metadata_if_needed,
395 395 pyramid.events.ApplicationCreated)
396 396 config.add_subscriber(write_usage_data,
397 397 pyramid.events.ApplicationCreated)
398 398 config.add_subscriber(write_js_routes_if_enabled,
399 399 pyramid.events.ApplicationCreated)
400 400
401 401
402 402 # Set the default renderer for HTML templates to mako.
403 403 config.add_mako_renderer('.html')
404 404
405 405 config.add_renderer(
406 406 name='json_ext',
407 407 factory='rhodecode.lib.ext_json_renderer.pyramid_ext_json')
408 408
409 409 config.add_renderer(
410 410 name='string_html',
411 411 factory='rhodecode.lib.string_renderer.html')
412 412
413 413 # include RhodeCode plugins
414 414 includes = aslist(settings.get('rhodecode.includes', []))
415 415 log.debug('processing rhodecode.includes data...')
416 416 for inc in includes:
417 417 config.include(inc)
418 418
419 419 # custom not found view, if our pyramid app doesn't know how to handle
420 420 # the request pass it to potential VCS handling ap
421 421 config.add_notfound_view(not_found_view)
422 422 if not settings.get('debugtoolbar.enabled', False):
423 423 # disabled debugtoolbar handle all exceptions via the error_handlers
424 424 config.add_view(error_handler, context=Exception)
425 425
426 426 # all errors including 403/404/50X
427 427 config.add_view(error_handler, context=HTTPError)
428 428
429 429
430 430 def wrap_app_in_wsgi_middlewares(pyramid_app, config):
431 431 """
432 432 Apply outer WSGI middlewares around the application.
433 433 """
434 434 registry = config.registry
435 435 settings = registry.settings
436 436
437 437 # enable https redirects based on HTTP_X_URL_SCHEME set by proxy
438 438 pyramid_app = HttpsFixup(pyramid_app, settings)
439 439
440 440 pyramid_app, _ae_client = wrap_in_appenlight_if_enabled(
441 441 pyramid_app, settings)
442 442 registry.ae_client = _ae_client
443 443
444 444 if settings['gzip_responses']:
445 445 pyramid_app = make_gzip_middleware(
446 446 pyramid_app, settings, compress_level=1)
447 447
448 448 # this should be the outer most middleware in the wsgi stack since
449 449 # middleware like Routes make database calls
450 450 def pyramid_app_with_cleanup(environ, start_response):
451 451 start = time.time()
452 452 try:
453 453 return pyramid_app(environ, start_response)
454 454 finally:
455 455 # Dispose current database session and rollback uncommitted
456 456 # transactions.
457 457 meta.Session.remove()
458 458
459 459 # In a single threaded mode server, on non sqlite db we should have
460 460 # '0 Current Checked out connections' at the end of a request,
461 461 # if not, then something, somewhere is leaving a connection open
462 462 pool = meta.get_engine().pool
463 463 log.debug('sa pool status: %s', pool.status())
464 464 total = time.time() - start
465 465 log.debug('Request processing finalized: %.4fs', total)
466 466
467 467 return pyramid_app_with_cleanup
468 468
469 469
470 470 def sanitize_settings_and_apply_defaults(global_config, settings):
471 471 """
472 472 Applies settings defaults and does all type conversion.
473 473
474 474 We would move all settings parsing and preparation into this place, so that
475 475 we have only one place left which deals with this part. The remaining parts
476 476 of the application would start to rely fully on well prepared settings.
477 477
478 478 This piece would later be split up per topic to avoid a big fat monster
479 479 function.
480 480 """
481 jn = os.path.join
481 482
482 483 global_settings_maker = SettingsMaker(global_config)
483 484 global_settings_maker.make_setting('debug', default=False, parser='bool')
484 485 debug_enabled = asbool(global_config.get('debug'))
485 486
486 487 settings_maker = SettingsMaker(settings)
487 488
488 489 settings_maker.make_setting(
489 490 'logging.autoconfigure',
490 491 default=False,
491 492 parser='bool')
492 493
493 logging_conf = os.path.join(os.path.dirname(global_config.get('__file__')), 'logging.ini')
494 logging_conf = jn(os.path.dirname(global_config.get('__file__')), 'logging.ini')
494 495 settings_maker.enable_logging(logging_conf, level='INFO' if debug_enabled else 'DEBUG')
495 496
496 497 # Default includes, possible to change as a user
497 498 pyramid_includes = settings_maker.make_setting('pyramid.includes', [], parser='list:newline')
498 499 log.debug(
499 500 "Using the following pyramid.includes: %s",
500 501 pyramid_includes)
501 502
502 503 settings_maker.make_setting('rhodecode.edition', 'Community Edition')
503 504 settings_maker.make_setting('rhodecode.edition_id', 'CE')
504 505
505 506 if 'mako.default_filters' not in settings:
506 507 # set custom default filters if we don't have it defined
507 508 settings['mako.imports'] = 'from rhodecode.lib.base import h_filter'
508 509 settings['mako.default_filters'] = 'h_filter'
509 510
510 511 if 'mako.directories' not in settings:
511 512 mako_directories = settings.setdefault('mako.directories', [
512 513 # Base templates of the original application
513 514 'rhodecode:templates',
514 515 ])
515 516 log.debug(
516 517 "Using the following Mako template directories: %s",
517 518 mako_directories)
518 519
519 520 # NOTE(marcink): fix redis requirement for schema of connection since 3.X
520 521 if 'beaker.session.type' in settings and settings['beaker.session.type'] == 'ext:redis':
521 522 raw_url = settings['beaker.session.url']
522 523 if not raw_url.startswith(('redis://', 'rediss://', 'unix://')):
523 524 settings['beaker.session.url'] = 'redis://' + raw_url
524 525
525 526 settings_maker.make_setting('__file__', global_config.get('__file__'))
526 527
527 528 # TODO: johbo: Re-think this, usually the call to config.include
528 529 # should allow to pass in a prefix.
529 530 settings_maker.make_setting('rhodecode.api.url', '/_admin/api')
530 531
531 532 # Sanitize generic settings.
532 533 settings_maker.make_setting('default_encoding', 'UTF-8', parser='list')
533 534 settings_maker.make_setting('is_test', False, parser='bool')
534 535 settings_maker.make_setting('gzip_responses', False, parser='bool')
535 536
536 537 # statsd
537 538 settings_maker.make_setting('statsd.enabled', False, parser='bool')
538 539 settings_maker.make_setting('statsd.statsd_host', 'statsd-exporter', parser='string')
539 540 settings_maker.make_setting('statsd.statsd_port', 9125, parser='int')
540 541 settings_maker.make_setting('statsd.statsd_prefix', '')
541 542 settings_maker.make_setting('statsd.statsd_ipv6', False, parser='bool')
542 543
543 544 settings_maker.make_setting('vcs.svn.compatible_version', '')
544 545 settings_maker.make_setting('vcs.hooks.protocol', 'http')
545 546 settings_maker.make_setting('vcs.hooks.host', '*')
546 547 settings_maker.make_setting('vcs.scm_app_implementation', 'http')
547 548 settings_maker.make_setting('vcs.server', '')
548 549 settings_maker.make_setting('vcs.server.protocol', 'http')
549 550 settings_maker.make_setting('vcs.server.enable', 'true', parser='bool')
550 551 settings_maker.make_setting('startup.import_repos', 'false', parser='bool')
551 552 settings_maker.make_setting('vcs.hooks.direct_calls', 'false', parser='bool')
552 553 settings_maker.make_setting('vcs.start_server', 'false', parser='bool')
553 554 settings_maker.make_setting('vcs.backends', 'hg, git, svn', parser='list')
554 555 settings_maker.make_setting('vcs.connection_timeout', 3600, parser='int')
555 556
556 557 settings_maker.make_setting('vcs.methods.cache', True, parser='bool')
557 558
558 559 # Support legacy values of vcs.scm_app_implementation. Legacy
559 560 # configurations may use 'rhodecode.lib.middleware.utils.scm_app_http', or
560 561 # disabled since 4.13 'vcsserver.scm_app' which is now mapped to 'http'.
561 562 scm_app_impl = settings['vcs.scm_app_implementation']
562 563 if scm_app_impl in ['rhodecode.lib.middleware.utils.scm_app_http', 'vcsserver.scm_app']:
563 564 settings['vcs.scm_app_implementation'] = 'http'
564 565
565 566 settings_maker.make_setting('appenlight', False, parser='bool')
566 567
567 568 temp_store = tempfile.gettempdir()
568 tmp_cache_dir = os.path.join(temp_store, 'rc_cache')
569 tmp_cache_dir = jn(temp_store, 'rc_cache')
569 570
570 571 # save default, cache dir, and use it for all backends later.
571 572 default_cache_dir = settings_maker.make_setting(
572 573 'cache_dir',
573 574 default=tmp_cache_dir, default_when_empty=True,
574 575 parser='dir:ensured')
575 576
576 577 # exception store cache
577 578 settings_maker.make_setting(
578 579 'exception_tracker.store_path',
579 default=os.path.join(default_cache_dir, 'exc_store'), default_when_empty=True,
580 default=jn(default_cache_dir, 'exc_store'), default_when_empty=True,
580 581 parser='dir:ensured'
581 582 )
582 583
583 584 settings_maker.make_setting(
584 585 'celerybeat-schedule.path',
585 default=os.path.join(default_cache_dir, 'celerybeat_schedule', 'celerybeat-schedule.db'), default_when_empty=True,
586 default=jn(default_cache_dir, 'celerybeat_schedule', 'celerybeat-schedule.db'), default_when_empty=True,
586 587 parser='file:ensured'
587 588 )
588 589
589 590 settings_maker.make_setting('exception_tracker.send_email', False, parser='bool')
590 591 settings_maker.make_setting('exception_tracker.email_prefix', '[RHODECODE ERROR]', default_when_empty=True)
591 592
593 # sessions, ensure file since no-value is memory
594 settings_maker.make_setting('beaker.session.type', 'file')
595 settings_maker.make_setting('beaker.session.data_dir', jn(default_cache_dir, 'session_data'))
596
592 597 # cache_general
593 598 settings_maker.make_setting('rc_cache.cache_general.backend', 'dogpile.cache.rc.file_namespace')
594 599 settings_maker.make_setting('rc_cache.cache_general.expiration_time', 60 * 60 * 12, parser='int')
595 settings_maker.make_setting('rc_cache.cache_general.arguments.filename', os.path.join(default_cache_dir, 'rhodecode_cache_general.db'))
600 settings_maker.make_setting('rc_cache.cache_general.arguments.filename', jn(default_cache_dir, 'rhodecode_cache_general.db'))
596 601
597 602 # cache_perms
598 603 settings_maker.make_setting('rc_cache.cache_perms.backend', 'dogpile.cache.rc.file_namespace')
599 604 settings_maker.make_setting('rc_cache.cache_perms.expiration_time', 60 * 60, parser='int')
600 settings_maker.make_setting('rc_cache.cache_perms.arguments.filename', os.path.join(default_cache_dir, 'rhodecode_cache_perms_db'))
605 settings_maker.make_setting('rc_cache.cache_perms.arguments.filename', jn(default_cache_dir, 'rhodecode_cache_perms_db'))
601 606
602 607 # cache_repo
603 608 settings_maker.make_setting('rc_cache.cache_repo.backend', 'dogpile.cache.rc.file_namespace')
604 609 settings_maker.make_setting('rc_cache.cache_repo.expiration_time', 60 * 60 * 24 * 30, parser='int')
605 settings_maker.make_setting('rc_cache.cache_repo.arguments.filename', os.path.join(default_cache_dir, 'rhodecode_cache_repo_db'))
610 settings_maker.make_setting('rc_cache.cache_repo.arguments.filename', jn(default_cache_dir, 'rhodecode_cache_repo_db'))
606 611
607 612 # cache_license
608 613 settings_maker.make_setting('rc_cache.cache_license.backend', 'dogpile.cache.rc.file_namespace')
609 614 settings_maker.make_setting('rc_cache.cache_license.expiration_time', 60 * 5, parser='int')
610 settings_maker.make_setting('rc_cache.cache_license.arguments.filename', os.path.join(default_cache_dir, 'rhodecode_cache_license_db'))
615 settings_maker.make_setting('rc_cache.cache_license.arguments.filename', jn(default_cache_dir, 'rhodecode_cache_license_db'))
611 616
612 617 # cache_repo_longterm memory, 96H
613 618 settings_maker.make_setting('rc_cache.cache_repo_longterm.backend', 'dogpile.cache.rc.memory_lru')
614 619 settings_maker.make_setting('rc_cache.cache_repo_longterm.expiration_time', 345600, parser='int')
615 620 settings_maker.make_setting('rc_cache.cache_repo_longterm.max_size', 10000, parser='int')
616 621
617 622 # sql_cache_short
618 623 settings_maker.make_setting('rc_cache.sql_cache_short.backend', 'dogpile.cache.rc.memory_lru')
619 624 settings_maker.make_setting('rc_cache.sql_cache_short.expiration_time', 30, parser='int')
620 625 settings_maker.make_setting('rc_cache.sql_cache_short.max_size', 10000, parser='int')
621 626
622 627 # archive_cache
623 settings_maker.make_setting('archive_cache.store_dir', os.path.join(default_cache_dir, 'archive_cache'), default_when_empty=True,)
628 settings_maker.make_setting('archive_cache.store_dir', jn(default_cache_dir, 'archive_cache'), default_when_empty=True,)
624 629 settings_maker.make_setting('archive_cache.cache_size_gb', 10, parser='float')
625 630 settings_maker.make_setting('archive_cache.cache_shards', 10, parser='int')
626 631
627 632 settings_maker.env_expand()
628 633
629 634 # configure instance id
630 635 config_utils.set_instance_id(settings)
631 636
632 637 return settings
General Comments 0
You need to be logged in to leave comments. Login now