Skip to content
This repository was archived by the owner on Jan 24, 2018. It is now read-only.

Commit

Permalink
Add docs for running the server
Browse files Browse the repository at this point in the history
Flake fixes
  • Loading branch information
david4096 committed Mar 9, 2017
1 parent e083beb commit 5fac2e3
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 18 deletions.
31 changes: 29 additions & 2 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,33 @@ Configuration
The GA4GH reference server `Configuration file`_. allows Flask and application
specific configuration values to be set.

-------------------
Starting the server
-------------------

The ``ga4gh_server`` command looks attempts to start a server for a given
configuration. Please see below for mandatory configuration settings, including
``DATA_SOURCE``.

.. argparse::
:module: ga4gh.server.cli.server
:func: getServerParser
:prog: ga4gh_server
:nodefault:


Gunicorn WSGI Server
====================

Using the ``-g`` option allows one to run the server in an experimental
mode behind the http://gunicorn.org/ WSGI HTTP Server. This allows multiple
workers to spawn to handle simultaneous requests. For some purposes, this will
allow an implementor to avoid the need to configure an Apache or nginx process.

This feature is experimental. Please post your issues to https://github.com/ga4gh/schemas/issues .
Currently, the logging facility and TLS mode are known to not work under
gunicorn.

------------------
Configuration file
------------------
Expand Down Expand Up @@ -41,9 +68,9 @@ information as follows:
Running the server with Flask debugging enable is insecure and should
never be used in a production environment.

++++++++++++++++++++

Configuration Values
++++++++++++++++++++
====================

DEFAULT_PAGE_SIZE
The default maximum number of values to fill into a page when responding
Expand Down
28 changes: 12 additions & 16 deletions ga4gh/server/cli/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@
from __future__ import unicode_literals

import requests
import multiprocessing
import gunicorn.app.base

import ga4gh.server.cli as cli
import ga4gh.server.frontend as frontend

import gunicorn.app.base

import multiprocessing


import ga4gh.common.cli as common_cli


Expand All @@ -35,8 +32,6 @@ def load(self):
return self.application




def addServerOptions(parser):
parser.add_argument(
"--port", "-P", default=8000, type=int,
Expand All @@ -63,21 +58,24 @@ def addServerOptions(parser):
cli.addVersionArgument(parser)
cli.addDisableUrllibWarningsArgument(parser)


def number_of_workers():
return (multiprocessing.cpu_count() * 2) + 1


def runGunicornServer(parsedArgs):
options = {
'bind': '%s:%s' % (parsedArgs.host, parsedArgs.port),
'workers': number_of_workers(),
}
StandaloneApplication(frontend.app, options).run()


def getServerParser():
parser = common_cli.createArgumentParser("GA4GH reference server")
addServerOptions(parser)
return parser

def number_of_workers():
return (multiprocessing.cpu_count() * 2) + 1


def server_main(args=None):
parser = getServerParser()
Expand All @@ -92,9 +90,7 @@ def server_main(args=None):
sslContext = None
if parsedArgs.tls or ("OIDC_PROVIDER" in frontend.app.config):
sslContext = "adhoc"
frontend.app.run(host = parsedArgs.host,
port = parsedArgs.port,
use_reloader = not parsedArgs.dont_use_reloader,
ssl_context = sslContext)


frontend.app.run(host=parsedArgs.host,
port=parsedArgs.port,
use_reloader=not parsedArgs.dont_use_reloader,
ssl_context=sslContext)

0 comments on commit 5fac2e3

Please sign in to comment.