Skip to content

Commit

Permalink
set memory limit back to where it used to be. Make demand import conf…
Browse files Browse the repository at this point in the history
…igurable with an environment variable.

Turn on WSGILazyInitialization as the docs recommend that due to memory issues
  • Loading branch information
hahn-kev committed Dec 15, 2023
1 parent f4d2c9a commit fc398df
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
6 changes: 4 additions & 2 deletions deployment/base/hg-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ spec:
# https://kubernetes.io/docs/concepts/configuration/manage-resources-containers
resources:
requests:
memory: 260Mi
memory: 400Mi
limits:
memory: 260Mi
memory: 400Mi
env:
- name: CUSTOM_PORT
value: "8088"
Expand All @@ -65,6 +65,8 @@ spec:
configMapKeyRef:
name: app-config
key: hg-otel-enabled
- name: ENABLE_DEMAND_IMPORT
value: "false"
ports:
- containerPort: 8088

Expand Down
2 changes: 1 addition & 1 deletion hgweb/hg.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so
WSGIPythonOptimize 0
WSGILazyInitialization Off
WSGILazyInitialization On
WSGISocketPrefix logs/wsgi
LogLevel debug
ServerName localhost
Expand Down
10 changes: 9 additions & 1 deletion hgweb/hgweb.wsgi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os
import sys
# An example WSGI for use with mod_wsgi, edit as necessary
# See https://mercurial-scm.org/wiki/modwsgi for more information
# mod_wsgi docs: https://modwsgi.readthedocs.io/en/master/
Expand All @@ -13,7 +15,13 @@ config = b"/var/hg/hgweb.hgrc"
#import cgitb; cgitb.enable()

# enable demandloading to reduce startup time
from mercurial import demandimport; demandimport.enable()
from mercurial import demandimport;

# enable demandloading to reduce startup time
if os.getenv('ENABLE_DEMAND_IMPORT', 'false').lower() in ['1', 'true', 'yes']:
demandimport.enable()
else:
demandimport.disable()

from mercurial.hgweb import hgweb
application = hgweb(config)

0 comments on commit fc398df

Please sign in to comment.