Skip to content

Commit

Permalink
Merge pull request #138 from gyorilab/gunicorn
Browse files Browse the repository at this point in the history
Allow for 'classic' gunicorn running
  • Loading branch information
bgyori authored May 1, 2024
2 parents 39a167d + 5f317f0 commit 0326482
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 14 deletions.
26 changes: 16 additions & 10 deletions gilda/app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import argparse
"""
Run the grounding app.
Run as module:
`python -m gilda.app --host <host> --port <port> --terms <terms>`
Run with gunicorn:
`gunicorn -w <worker count> -b <host>:<port> -t <timeout> gilda.app:gilda_app`
In case a non-standard set of terms is to be used, set the `GILDA_TERMS`
environment variable to the path to the terms file.
"""

import os
from .app import get_app


def main():
parser = argparse.ArgumentParser(
description='Run the grounding app.')
parser.add_argument('--host', default='0.0.0.0')
parser.add_argument('--port', default=8001, type=int)
parser.add_argument('--terms')
args = parser.parse_args()
app = get_app(terms=args.terms)
app.run(host=args.host, port=args.port, threaded=False)
terms = os.environ.get('GILDA_TERMS')
gilda_app = get_app(terms=terms)
23 changes: 21 additions & 2 deletions gilda/app/__main__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
from . import main
"""
Runs the Gilda grounding app as a module. Usage:
`python -m gilda.app --host <host> --port <port> --terms <terms>`
"""

import argparse
from .app import get_app


def parse_args():
parser = argparse.ArgumentParser(
description='Run the grounding app.')
parser.add_argument('--host', default='0.0.0.0')
parser.add_argument('--port', default=8001, type=int)
parser.add_argument('--terms')
args = parser.parse_args()
return args


if __name__ == '__main__':
main()
args = parse_args()
app = get_app(args.terms)
app.run(args.host, args.port, threaded=False)
4 changes: 2 additions & 2 deletions gilda/app/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ <h2 style="margin-top: 10px; margin-bottom: 10px;">Gilda Grounding Service</h2>
Gilda is developed by the <a href="https://gyorilab.github.io"
target="_blank">Gyori Lab for Computational Biomedicine</a>
at <a href="https://www.northeastern.edu" target="_blank">Northeastern University</a>.
Its development was funded by DARPA grants W911NF-15-1-0544 and
W911NF-20-1-0255.
Its development is funded by DARPA grants W911NF-15-1-0544,
W911NF-20-1-0255, and HR00112220036.
Point of contact: <a href="mailto:b.gyori@northeastern.edu">Benjamin M. Gyori</a>.
</p>
</div>
Expand Down

0 comments on commit 0326482

Please sign in to comment.