forked from foursquare/twofishes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserve.py
executable file
·37 lines (26 loc) · 1.07 KB
/
serve.py
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
#!/usr/bin/python
import os
import sys
from optparse import OptionParser
usage = "usage: %prog [options] hfile_directory"
parser = OptionParser(usage = usage)
parser.add_option("-p", "--port", dest="port", default=8080, type='int',
help="port")
parser.add_option("--preload", dest="preload", default=False, action='store_true',
help="preload index to prevent coldstart, increases startup time")
parser.add_option("--nopreload", dest="preload", default=False, action='store_false',
help="don't preload index to prevent coldstart, decrease startup time, increases intial latency")
parser.add_option("-r", "--rebel", dest="rebel", default=False, action='store_true',
help="rebel")
(options, args) = parser.parse_args()
if len(args) != 1:
parser.print_usage()
sys.exit(1)
basepath = os.path.abspath(args[0])
sbt = './sbt'
if options.rebel:
sbt = './sbt-rebel'
args = ' --preload %s ' % options.preload
cmd = '%s "server/run-main com.foursquare.twofishes.GeocodeFinagleServer %s --port %d --hfile_basepath %s"' % (sbt, args, options.port, basepath)
print(cmd)
os.system(cmd)