- # enter vserver context
- arg_subst = { 'runlevel': runlevel }
- cmd_args = [cmd[0]] + map(lambda x: x % arg_subst, cmd[1:])
- # add vserver name as the last command argument
- cmd_args += [self.name]
- cmd_file = "/vservers/" + self.name + cmd[0]
- self.log(cmd_file)
- if os.path.isfile(cmd_file):
- self.log("executing '%s'" % " ".join(cmd_args))
- self.chroot_call(subprocess.call, " ".join(cmd_args), shell=True)
- else:
- self.log("WARNING: could not run %s on %s" % (cmd[0], self.name))
- except:
- self.log(traceback.format_exc())
-
- # we get here due to an exception in the top-level child process
+ logname='/vservers/%s/var/log/%s'%(self.name,cmd_name)
+ log_fd=os.open(logname,os.O_WRONLY | os.O_CREAT | os.O_APPEND, 0600)
+ self.log_in_file(log_fd,"Running %r into %s"%(cmd,logname))
+ self.chroot_call(subprocess.call,cmd,
+ stdout=log_fd,stderr=subprocess.STDOUT,
+ close_fds=True)
+ except: self.log(traceback.format_exc())
+ finally: os.close(log_fd)
+
+ # we get here due to an exception in the grandson process