mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
forward-port the noshell branch from 3.x
This commit is contained in:
parent
509c801436
commit
7b03dd3da4
@ -120,47 +120,23 @@ class Server:
|
||||
console.info("Launching Server {} with command {}".format(self.name, self.server_command))
|
||||
|
||||
if os.name == "nt":
|
||||
logger.info("Windows Detected - launching cmd")
|
||||
logger.info("Windows Detected")
|
||||
self.server_command = self.server_command.replace('\\', '/')
|
||||
logging.info("Opening CMD prompt")
|
||||
self.process = pexpect.popen_spawn.PopenSpawn('cmd \r\n', timeout=None, encoding=None)
|
||||
|
||||
drive_letter = self.server_path[:1]
|
||||
|
||||
if drive_letter.lower() != "c":
|
||||
logger.info("Server is not on the C drive, changing drive letter to {}:".format(drive_letter))
|
||||
self.process.send("{}:\r\n".format(drive_letter))
|
||||
|
||||
logging.info("changing directories to {}".format(self.server_path.replace('\\', '/')))
|
||||
self.process.send('cd {} \r\n'.format(self.server_path.replace('\\', '/')))
|
||||
logging.info("Sending command {} to CMD".format(self.server_command))
|
||||
self.process.send(self.server_command + "\r\n")
|
||||
|
||||
self.is_crashed = False
|
||||
else:
|
||||
logger.info("Linux Detected - launching Bash")
|
||||
self.process = pexpect.popen_spawn.PopenSpawn('/bin/bash \n', timeout=None, encoding=None)
|
||||
logger.info("Linux Detected")
|
||||
|
||||
logger.info("Changing directory to {}".format(self.server_path))
|
||||
self.process.send('cd {} \n'.format(self.server_path))
|
||||
|
||||
logger.info("Sending server start command: {} to shell".format(self.server_command))
|
||||
self.process.send(self.server_command + '\n')
|
||||
self.is_crashed = False
|
||||
logger.info("Starting server in {p} with command: {c}".format(p=self.server_path, c=self.server_command))
|
||||
self.is_crashed = False
|
||||
|
||||
ts = time.time()
|
||||
self.start_time = str(datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S'))
|
||||
|
||||
if psutil.pid_exists(self.process.pid):
|
||||
parent = psutil.Process(self.process.pid)
|
||||
time.sleep(.5)
|
||||
children = parent.children(recursive=True)
|
||||
for c in children:
|
||||
self.PID = c.pid
|
||||
logger.info("Server {} running with PID {}".format(self.name, self.PID))
|
||||
console.info("Server {} running with PID {}".format(self.name, self.PID))
|
||||
self.is_crashed = False
|
||||
stats.record_stats()
|
||||
self.PID = self.process.pod
|
||||
logger.info("Server {} running with PID {}".format(self.name, self.PID))
|
||||
console.info("Server {} running with PID {}".format(self.name, self.PID))
|
||||
self.is_crashed = False
|
||||
stats.record_stats()
|
||||
else:
|
||||
logger.warning("Server PID {} died right after starting - is this a server config issue?".format(self.PID))
|
||||
console.warning("Server PID {} died right after starting - is this a server config issue?".format(self.PID))
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"major": 4,
|
||||
"minor": 0,
|
||||
"sub": "Alpha 2"
|
||||
}
|
||||
"sub": "Alpha 2+noshell"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user