Repository navigation
Expand file tree
/
Copy pathinfobase-server
More file actions
executable file
·61 lines (43 loc) · 1.43 KB
/
Copy pathinfobase-server
File metadata and controls
executable file
·61 lines (43 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#! /usr/bin/env python
"""Script to run infobase.
USAGE:
* Run Infobase http server at port 7070.
$ python ./scripts/infobase-server infobase.yaml 7070
* Run Infobase as fastcgi server at port 7070
$ python ./scripts/infobase-server infobase.yaml fastcgi 7070
"""
import sys
import os
import _init_path
import web
def setup_env():
# make sure PYTHON_EGG_CACHE is writable
os.environ['PYTHON_EGG_CACHE'] = "/tmp/.python-eggs"
# required when run as fastcgi
os.environ['REAL_SCRIPT_NAME'] = ""
def main(args):
if len(args) < 1 or args[0] in ['-h', '--help']:
print >> sys.stderr, "USAGE: %s configfile [port]" % (sys.argv[0])
sys.exit(1)
from infogami.infobase import server
server.start(*args)
def start_gunicorn_server():
"""Starts the infobase server using gunicorn server.
"""
from gunicorn.app.base import Application
configfile = sys.argv.pop(1)
class WSGIServer(Application):
def init(self, parser, opts, args):
pass
def load(self):
from infogami.infobase import server
server.load_config(configfile)
return server.app.wsgifunc()
WSGIServer("%prog infobase.yml --gunicorn [options]").run()
if __name__ == "__main__":
setup_env()
if "--gunicorn" in sys.argv:
sys.argv.pop(sys.argv.index("--gunicorn"))
start_gunicorn_server()
else:
main(sys.argv[1:])