387 env = os.environ.copy()
388 env[
"DQM2_SOCKET"] = json_handler.fn
394 libc = ctypes.CDLL(
"libc.so.6")
396 libc.prctl(PR_SET_PDEATHSIG, signal.SIGKILL)
398 log(
"Failed to setup PR_SET_PDEATHSIG.")
401 p = subprocess.Popen(args.pargs, preexec_fn=preexec, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=
True, env=env)
402 CURRENT_PROC.append(p)
407 relpath = os.path.dirname(__file__)
408 sys.path.append(relpath)
409 from ztee
import GZipLog
411 zlog_ = GZipLog(log_file=args.zlog)
412 es.update_doc({
"stdlog_gzip": args.zlog })
414 log(
"Open gzip log file: %s" % args.zlog)
417 log(
"Failed to setup zlog file: " + str(e))
419 es.update_doc({
"pid": p.pid })
423 log_handler =
FDOutputListener(fd=p.stdout.fileno(), es=es, zlog=zlog, close_socket=json_handler)
424 log_handler.handle_line(
"-- starting process: %s --\n" % str(args.pargs))
428 asyncore.loop(timeout=5)
429 except select.error, e:
432 log(
"Select error (we will terminate): " + str(e))
437 log_handler.handle_line(
"\n-- process exit: %s --\n" % str(r))
440 es.update_doc({
"exit_code": r })
443 CURRENT_PROC.remove(p)