12
12
import getpass
13
13
import urllib .request
14
14
15
+ LUCENE_SERVER_BASE_VERSION = '0.1.1'
16
+
15
17
# killall java; ssh 10.17.4.12 killall java; rm -rf /c/taxis; ssh 10.17.4.12 "rm -rf /l/taxis"; python3 -u scripts/indexTaxis.py -rebuild -ip 10.17.4.92 -installPath /c/taxis -replica 10.17.4.12:/l/taxis
16
18
17
19
# TODO
18
20
# - index lat/lon as geopoint!
19
21
20
22
LOCALHOST = '127.0.0.1'
21
23
24
+ IS_INSTALLED = os .path .exists ('lib/luceneserver-%s.jar' % LUCENE_SERVER_BASE_VERSION ) or \
25
+ os .path .exists ('lib/luceneserver-%s-SNAPSHOT.jar' % LUCENE_SERVER_BASE_VERSION )
26
+
22
27
DEFAULT_PORT = 4000
23
28
24
29
PACKAGE_FILE = os .path .abspath ('build/luceneserver-0.1.0-SNAPSHOT.zip' )
@@ -45,24 +50,29 @@ def close(self):
45
50
self .socket .close ()
46
51
47
52
def launchServer (host , installDir , port , ip = None ):
48
- zipFileName = os .path .split (PACKAGE_FILE )[1 ]
49
53
50
- # copy install bits over
51
- if host != LOCALHOST :
52
- run ('scp %s %s@%s:/tmp' % (PACKAGE_FILE , USER_NAME , host ))
53
- # unzip it
54
- run ('ssh %s@%s "mkdir -p %s; cd %s; unzip /tmp/%s"' % (USER_NAME , host , installDir , installDir , zipFileName ))
54
+ if IS_INSTALLED :
55
+ cwd = '.'
55
56
else :
56
- os .makedirs (installDir )
57
- run ('cd %s; unzip %s' % (installDir , PACKAGE_FILE ))
58
57
59
- serverDirName = zipFileName [:- 4 ]
58
+ zipFileName = os .path .split (PACKAGE_FILE )[1 ]
59
+ # copy install bits over
60
+ if host != LOCALHOST :
61
+ run ('scp %s %s@%s:/tmp' % (PACKAGE_FILE , USER_NAME , host ))
62
+ # unzip it
63
+ run ('ssh %s@%s "mkdir -p %s; cd %s; unzip /tmp/%s"' % (USER_NAME , host , installDir , installDir , zipFileName ))
64
+ else :
65
+ os .makedirs (installDir )
66
+ run ('cd %s; unzip %s' % (installDir , PACKAGE_FILE ))
67
+
68
+ serverDirName = zipFileName [:- 4 ]
69
+ cwd = '%s/%s' % (installDir , serverDirName )
60
70
61
71
if host != LOCALHOST :
62
- command = r'ssh %s@%s "cd %s/%s ; java -Xms4g -Xmx4g -cp lib/\* org.apache.lucene.server.Server -stateDir %s/state -ipPort %s:%s"' % (USER_NAME , host , installDir , serverDirName , installDir , host , port )
72
+ command = r'ssh %s@%s "cd %s; java -Xms4g -Xmx4g -cp lib/\* org.apache.lucene.server.Server -stateDir %s/state -ipPort %s:%s"' % (USER_NAME , host , cwd , installDir , host , port )
63
73
else :
64
- #command = r'cd %s/%s ; java -XX:MaxInlineSize=0 -agentlib:yjpagent=sampling -Xms4g -Xmx4g -cp lib/\* org.apache.lucene.server.Server -stateDir %s/state -ipPort %s:%s' % (installDir, serverDirName , installDir, host, port)
65
- command = r'cd %s/%s ; java -Xms4g -Xmx4g -cp lib/\* org.apache.lucene.server.Server -stateDir %s/state -ipPort %s:%s' % (installDir , serverDirName , installDir , host , port )
74
+ #command = r'cd %s; java -XX:MaxInlineSize=0 -agentlib:yjpagent=sampling -Xms4g -Xmx4g -cp lib/\* org.apache.lucene.server.Server -stateDir %s/state -ipPort %s:%s' % (cwd , installDir, host, port)
75
+ command = r'cd %s; java -Xms4g -Xmx4g -cp lib/\* org.apache.lucene.server.Server -stateDir %s/state -ipPort %s:%s' % (cwd , installDir , host , port )
66
76
67
77
if ip is not None :
68
78
command += ' -ipPort %s:%s' % (ip , port )
@@ -147,27 +157,35 @@ def getFlag(option):
147
157
148
158
def main ():
149
159
150
- if not os .path .exists ('src/java/org/apache/lucene/server/Server.java' ):
151
- print ('\n ERROR: please run this from the luceneserver working directory\n ' )
160
+ if not os .path .exists ('src/java/org/apache/lucene/server/Server.java' ) and not IS_INSTALLED :
161
+ print ('\n ERROR: please run this from the luceneserver working directory (git clone) or an installation \n ' )
152
162
sys .exit (1 )
153
163
154
- if getFlag ('-rebuild' ) or not os .path .exists ('build/luceneserver-0.1.0-SNAPSHOT.zip' ):
164
+ if IS_INSTALLED :
165
+ if getFlag ('-rebuild' ):
166
+ raise RuntimeError ('cannot rebuild from a binary installation' )
167
+ primaryInstallPath = '.'
168
+ elif getFlag ('-rebuild' ) or not os .path .exists ('build/luceneserver-%s-SNAPSHOT.zip' % LUCENE_SERVER_BASE_VERSION ):
155
169
print ('Building server release artifact...' )
156
170
run ('python3 -u build.py package' )
157
171
158
- primaryInstallPath = getArg ('-installPath' )
159
- if primaryInstallPath is None :
160
- primaryInstallPath = os .path .abspath ('install' )
172
+ primaryInstallPath = getArg ('-installPath' )
173
+ if primaryInstallPath is None :
174
+ primaryInstallPath = os .path .abspath ('install' )
175
+
176
+ if os .path .exists (primaryInstallPath ):
177
+ raise RuntimeError ('primary install path %s already exists; please remove it and rerun' % primaryInstallPath )
161
178
162
- if os .path .exists (primaryInstallPath ):
163
- raise RuntimeError ('primary install path %s already exists; please remove it and rerun' % primaryInstallPath )
179
+ os .makedirs (primaryInstallPath )
164
180
165
181
replicas = []
166
182
primaryIP = getArg ('-ip' )
167
183
168
184
while True :
169
185
s = getArg ('-replica' )
170
186
if s is not None :
187
+ if IS_INSTALLED :
188
+ raise RuntimeError ('-replica does not yet work when installed; try running from a git clone instead' )
171
189
if primaryIP is None :
172
190
raise RuntimeError ('you must specify -ip if there are any -replica' )
173
191
tup = s .split (':' )
@@ -185,7 +203,6 @@ def main():
185
203
if 'no such file or directory' not in s .lower ():
186
204
raise RuntimeError ('path %s on replica %s already exists; please remove it and rerun' % (installPath , host ))
187
205
188
- os .makedirs (primaryInstallPath )
189
206
for host , port , path in replicas :
190
207
print ('mkdir %s on %s' % (path , host ))
191
208
run ('ssh %s@%s mkdir -p %s' % (USER_NAME , host , path ))
0 commit comments