in ccmlib/node.py [0:0]
def __clean_win_pid(self):
start = common.now_ms()
if self.get_base_cassandra_version() >= 2.1:
# Spin for up to 15s waiting for .bat to write the pid file
pidfile = self.get_path() + "/cassandra.pid"
while (not os.path.isfile(pidfile)):
now = common.now_ms()
if (now - start > 15000):
raise Exception('Timed out waiting for pid file.')
else:
time.sleep(.001)
# Spin for up to 10s waiting for .bat to fill the pid file
start = common.now_ms()
while (os.stat(pidfile).st_size == 0):
now = common.now_ms()
if (now - start > 10000):
raise Exception('Timed out waiting for pid file to be filled.')
else:
time.sleep(.001)
else:
try:
# Spin for 500ms waiting for .bat to write the dirty_pid file
while (not os.path.isfile(self.get_path() + "/dirty_pid.tmp")):
now = common.now_ms()
if (now - start > 500):
raise Exception('Timed out waiting for dirty_pid file.')
else:
time.sleep(.001)
with open(self.get_path() + "/dirty_pid.tmp", 'r') as f:
found = False
process_regex = re.compile('ProcessId')
readStart = common.now_ms()
readEnd = common.now_ms()
while (found is False and readEnd - readStart < 500):
line = f.read()
if (line):
m = process_regex.search(line)
if (m):
found = True
linesub = line.split('=')
pidchunk = linesub[1].split(';')
win_pid = pidchunk[0].lstrip()
with open(self.get_path() + "/cassandra.pid", 'w') as pidfile:
found = True
pidfile.write(win_pid)
else:
time.sleep(.001)
readEnd = common.now_ms()
if not found:
raise Exception('Node: %s Failed to find pid in ' +
self.get_path() +
'/dirty_pid.tmp. Manually kill it and check logs - ccm will be out of sync.')
except Exception as e:
common.error("Problem starting " + self.name + " (" + str(e) + ")")
raise Exception('Error while parsing <node>/dirty_pid.tmp in path: ' + self.get_path())