improved server subprocess launch failure error handling

This commit is contained in:
Eric Froemling 2021-03-01 17:28:55 -06:00
parent d251aee045
commit a09232daa1
No known key found for this signature in database
GPG Key ID: 89C93F0F8D6D5A98

View File

@ -583,13 +583,20 @@ class ServerManagerApp:
binary_name = ('ballisticacore_headless.exe' binary_name = ('ballisticacore_headless.exe'
if os.name == 'nt' else './ballisticacore_headless') if os.name == 'nt' else './ballisticacore_headless')
assert self._ba_root_path is not None assert self._ba_root_path is not None
self._subprocess = None
try:
self._subprocess = subprocess.Popen( self._subprocess = subprocess.Popen(
[binary_name, '-cfgdir', self._ba_root_path], [binary_name, '-cfgdir', self._ba_root_path],
stdin=subprocess.PIPE, stdin=subprocess.PIPE,
cwd='dist') cwd='dist')
except Exception as exc:
print(f'Error launching server subprocess: {exc}',
file=sys.stderr,
flush=True)
# Do the thing. # Do the thing.
# No matter how this ends up, make sure the process is dead after. # No matter how this ends up, make sure the process is dead after.
if self._subprocess is not None:
try: try:
self._run_subprocess_until_exit() self._run_subprocess_until_exit()
finally: finally: