Commit 6ed48be8 authored by Michal Čihař's avatar Michal Čihař

Support for not doing hooks in background (for testing and debugging)

parent 3855cf92
...@@ -50,6 +50,14 @@ Time in seconds for how long the automatic lock for translation will be active. ...@@ -50,6 +50,14 @@ Time in seconds for how long the automatic lock for translation will be active.
.. seealso:: :ref:`locking` .. seealso:: :ref:`locking`
.. setting:: BACKGROUND_HOOKS
BACKGROUND_HOOKS
----------------
Whether to run hooks in background. This is generally recommended unless you
are debugging.
.. setting:: CHECK_LIST .. setting:: CHECK_LIST
CHECK_LIST CHECK_LIST
......
...@@ -306,6 +306,9 @@ EMAIL_SUBJECT_PREFIX = '[%s] ' % SITE_TITLE ...@@ -306,6 +306,9 @@ EMAIL_SUBJECT_PREFIX = '[%s] ' % SITE_TITLE
# Enable remote hooks # Enable remote hooks
ENABLE_HOOKS = True ENABLE_HOOKS = True
# Whether to run hooks in background
BACKGROUND_HOOKS = True
# Number of nearby messages to show in each direction # Number of nearby messages to show in each direction
NEARBY_MESSAGES = 5 NEARBY_MESSAGES = 5
......
...@@ -43,8 +43,11 @@ def update_subproject(request, project, subproject): ...@@ -43,8 +43,11 @@ def update_subproject(request, project, subproject):
if not appsettings.ENABLE_HOOKS: if not appsettings.ENABLE_HOOKS:
return HttpResponseNotAllowed([]) return HttpResponseNotAllowed([])
obj = get_object_or_404(SubProject, slug=subproject, project__slug=project) obj = get_object_or_404(SubProject, slug=subproject, project__slug=project)
thread = threading.Thread(target=obj.do_update) if appsettings.BACKGROUND_HOOKS:
thread.start() thread = threading.Thread(target=obj.do_update)
thread.start()
else:
obj.do_update()
return HttpResponse('update triggered') return HttpResponse('update triggered')
...@@ -56,8 +59,11 @@ def update_project(request, project): ...@@ -56,8 +59,11 @@ def update_project(request, project):
if not appsettings.ENABLE_HOOKS: if not appsettings.ENABLE_HOOKS:
return HttpResponseNotAllowed([]) return HttpResponseNotAllowed([])
obj = get_object_or_404(Project, slug=project) obj = get_object_or_404(Project, slug=project)
thread = threading.Thread(target=obj.do_update) if appsettings.BACKGROUND_HOOKS:
thread.start() thread = threading.Thread(target=obj.do_update)
thread.start()
else:
obj.do_update()
return HttpResponse('update triggered') return HttpResponse('update triggered')
...@@ -96,8 +102,11 @@ def git_service_hook(request, service): ...@@ -96,8 +102,11 @@ def git_service_hook(request, service):
) )
for obj in SubProject.objects.filter(repo=repo, branch=branch): for obj in SubProject.objects.filter(repo=repo, branch=branch):
logger.info('%s notification will update %s', obj) logger.info('%s notification will update %s', obj)
thread = threading.Thread(target=obj.do_update) if appsettings.BACKGROUND_HOOKS:
thread.start() thread = threading.Thread(target=obj.do_update)
thread.start()
else:
obj.do_update()
return HttpResponse('update triggered') return HttpResponse('update triggered')
......
...@@ -53,6 +53,9 @@ OFFER_HOSTING = get('OFFER_HOSTING', False) ...@@ -53,6 +53,9 @@ OFFER_HOSTING = get('OFFER_HOSTING', False)
# Enable remote hooks # Enable remote hooks
ENABLE_HOOKS = get('ENABLE_HOOKS', True) ENABLE_HOOKS = get('ENABLE_HOOKS', True)
# Whether to run hooks in background
BACKGROUND_HOOKS = get('BACKGROUND_HOOKS', True)
# Number of nearby messages to show in each direction # Number of nearby messages to show in each direction
NEARBY_MESSAGES = get('NEARBY_MESSAGES', 5) NEARBY_MESSAGES = get('NEARBY_MESSAGES', 5)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment