don't pass -Xmx1024 -Xms1024 when the machine has <1G RAM
This commit is contained in:
parent
0d8342f104
commit
332df2c1d8
@ -341,8 +341,25 @@ class MCServerChunkGenerator(object):
|
|||||||
tempWorld.unloadRegions()
|
tempWorld.unloadRegions()
|
||||||
|
|
||||||
proc = self.runServer(tempDir)
|
proc = self.runServer(tempDir)
|
||||||
for p in self.waitForServerIter(proc): yield p
|
while proc.poll() is None:
|
||||||
|
line = proc.stderr.readline()
|
||||||
|
yield line.strip()
|
||||||
|
|
||||||
|
if "[INFO] Done" in line:
|
||||||
|
proc.stdin.write("stop\n")
|
||||||
|
proc.wait()
|
||||||
|
break
|
||||||
|
if "FAILED TO BIND" in line:
|
||||||
|
proc.kill()
|
||||||
|
proc.wait()
|
||||||
|
raise RuntimeError, "Server failed to bind to port!"
|
||||||
|
|
||||||
|
stdout, _ = proc.communicate()
|
||||||
|
|
||||||
|
if "Could not reserve enough space" in stdout and not MCServerChunkGenerator.lowMemory:
|
||||||
|
MCServerChunkGenerator.lowMemory = True
|
||||||
|
for i in self.generateAtPositionIter(tempWorld, tempDir, cx, cz):
|
||||||
|
yield i
|
||||||
|
|
||||||
(tempWorld.parentWorld or tempWorld).loadLevelDat() #reload version number
|
(tempWorld.parentWorld or tempWorld).loadLevelDat() #reload version number
|
||||||
|
|
||||||
@ -372,8 +389,6 @@ class MCServerChunkGenerator(object):
|
|||||||
tempChunk.compress()
|
tempChunk.compress()
|
||||||
tempChunk.unload()
|
tempChunk.unload()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def generateChunkInLevel(self, level, cx, cz):
|
def generateChunkInLevel(self, level, cx, cz):
|
||||||
assert isinstance(level, MCInfdevOldLevel)
|
assert isinstance(level, MCInfdevOldLevel)
|
||||||
|
|
||||||
@ -423,30 +438,17 @@ class MCServerChunkGenerator(object):
|
|||||||
level.saveInPlace()
|
level.saveInPlace()
|
||||||
|
|
||||||
|
|
||||||
def waitForServer(self, proc):
|
|
||||||
return exhaust(self.waitForServerIter(proc))
|
|
||||||
def waitForServerIter(self, proc):
|
|
||||||
""" wait for the server to finish starting up, then stop it. """
|
|
||||||
while proc.poll() is None:
|
|
||||||
line = proc.stderr.readline()
|
|
||||||
yield line.strip()
|
|
||||||
|
|
||||||
if "[INFO] Done" in line:
|
|
||||||
proc.stdin.write("stop\n")
|
|
||||||
proc.wait()
|
|
||||||
break
|
|
||||||
if "FAILED TO BIND" in line:
|
|
||||||
proc.kill()
|
|
||||||
proc.wait()
|
|
||||||
raise RuntimeError, "Server Died!"
|
|
||||||
|
|
||||||
def runServer(self, startingDir):
|
def runServer(self, startingDir):
|
||||||
return self._runServer(startingDir, self.serverJarFile)
|
return self._runServer(startingDir, self.serverJarFile)
|
||||||
|
|
||||||
|
lowMemory = False
|
||||||
@classmethod
|
@classmethod
|
||||||
def _runServer(cls, startingDir, jarfile):
|
def _runServer(cls, startingDir, jarfile):
|
||||||
print "Starting server {0} in {1}".format(jarfile, startingDir)
|
print "Starting server {0} in {1}".format(jarfile, startingDir)
|
||||||
proc = subprocess.Popen([cls.javaExe, "-Djava.awt.headless=true", "-Xmx1024M", "-Xms1024M", "-jar", jarfile],
|
if cls.lowMemory: memflags = []
|
||||||
|
else: memflags = ["-Xmx1024M", "-Xms1024M", ]
|
||||||
|
|
||||||
|
proc = subprocess.Popen([cls.javaExe, "-Djava.awt.headless=true"] + memflags + ["-jar", jarfile],
|
||||||
executable=cls.javaExe,
|
executable=cls.javaExe,
|
||||||
cwd=startingDir,
|
cwd=startingDir,
|
||||||
stdin=subprocess.PIPE,
|
stdin=subprocess.PIPE,
|
||||||
|
Reference in New Issue
Block a user