|
@@ -79,18 +79,20 @@ class Daemon(Lockable):
|
|
p = Popen(cmd,creationflags=CREATE_NEW_CONSOLE,startupinfo=si)
|
|
p = Popen(cmd,creationflags=CREATE_NEW_CONSOLE,startupinfo=si)
|
|
p.wait()
|
|
p.wait()
|
|
|
|
|
|
- def exec_cmd(self,cmd,is_daemon=False):
|
|
|
|
|
|
+ def exec_cmd(self,cmd,is_daemon=False,check_retcode=False):
|
|
out = (PIPE,None)[is_daemon and self.opt.no_daemonize]
|
|
out = (PIPE,None)[is_daemon and self.opt.no_daemonize]
|
|
try:
|
|
try:
|
|
cp = run(cmd,check=False,stdout=out,stderr=out)
|
|
cp = run(cmd,check=False,stdout=out,stderr=out)
|
|
except OSError as e:
|
|
except OSError as e:
|
|
die( 'MMGenCalledProcessError', f'Error starting executable: {type(e).__name__} [Errno {e.errno}]' )
|
|
die( 'MMGenCalledProcessError', f'Error starting executable: {type(e).__name__} [Errno {e.errno}]' )
|
|
set_vt100()
|
|
set_vt100()
|
|
|
|
+ if check_retcode and cp.returncode:
|
|
|
|
+ die(1,str(cp))
|
|
if self.debug:
|
|
if self.debug:
|
|
print(cp)
|
|
print(cp)
|
|
return cp
|
|
return cp
|
|
|
|
|
|
- def run_cmd(self,cmd,silent=False,is_daemon=False):
|
|
|
|
|
|
+ def run_cmd(self,cmd,silent=False,is_daemon=False,check_retcode=False):
|
|
|
|
|
|
if self.debug:
|
|
if self.debug:
|
|
msg('\n\n')
|
|
msg('\n\n')
|
|
@@ -104,7 +106,7 @@ class Daemon(Lockable):
|
|
if self.use_threads and is_daemon and not self.opt.no_daemonize:
|
|
if self.use_threads and is_daemon and not self.opt.no_daemonize:
|
|
ret = self.exec_cmd_thread(cmd)
|
|
ret = self.exec_cmd_thread(cmd)
|
|
else:
|
|
else:
|
|
- ret = self.exec_cmd(cmd,is_daemon)
|
|
|
|
|
|
+ ret = self.exec_cmd(cmd,is_daemon,check_retcode)
|
|
|
|
|
|
if isinstance(ret,CompletedProcess):
|
|
if isinstance(ret,CompletedProcess):
|
|
if ret.stdout and (self.debug or not silent):
|
|
if ret.stdout and (self.debug or not silent):
|
|
@@ -192,7 +194,7 @@ class Daemon(Lockable):
|
|
|
|
|
|
if not silent:
|
|
if not silent:
|
|
msg(f'Starting {self.desc} on port {self.bind_port}')
|
|
msg(f'Starting {self.desc} on port {self.bind_port}')
|
|
- ret = self.run_cmd(self.start_cmd,silent=True,is_daemon=True)
|
|
|
|
|
|
+ ret = self.run_cmd(self.start_cmd,silent=True,is_daemon=True,check_retcode=True)
|
|
|
|
|
|
if self.wait:
|
|
if self.wait:
|
|
self.wait_for_state('ready')
|
|
self.wait_for_state('ready')
|