def start(self):
if self.child_process:
return # already started
self.prestart()
logger = open(os.path.join(self.base_dir, '%s.log' % self.name), 'wt')
try:
command = self.get_server_commandline()
flags = 0
if os.name == 'nt':
flags |= subprocess.CREATE_NEW_PROCESS_GROUP
custom_env = os.environ.copy()
custom_env["HOME"] = self.home
kwargs = {'env': custom_env, 'creationflags': flags}
if not self.debug:
kwargs.update({'stdout': logger, 'stderr': logger})
self.child_process = subprocess.Popen(command, **kwargs)
except Exception as exc:
raise RuntimeError('failed to launch %s: %r' % (self.name, exc))
else:
try:
self.wait_booting()
self.poststart()
except:
self.stop()
raise
finally:
logger.close()
评论列表
文章目录