391 env = os.environ.copy()
392 env[
"DQM2_SOCKET"] = json_handler.fn
398 libc = ctypes.CDLL(
"libc.so.6")
400 libc.prctl(PR_SET_PDEATHSIG, signal.SIGKILL)
402 log(
"Failed to setup PR_SET_PDEATHSIG.")
405 p = subprocess.Popen(args.pargs, preexec_fn=preexec, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=
True, env=env)
406 CURRENT_PROC.append(p)
411 relpath = os.path.dirname(__file__)
412 sys.path.append(relpath)
413 from ztee
import GZipLog
415 zlog_ = GZipLog(log_file=args.zlog)
416 es.update_doc({
"stdlog_gzip": args.zlog })
418 log(
"Open gzip log file: %s" % args.zlog)
420 except Exception
as e:
421 log(
"Failed to setup zlog file: " +
str(e))
423 es.update_doc({
"pid": p.pid })
424 es.update_doc({
"monitoring_pid": os.getpid() })
425 es.update_doc({
"monitoring_socket": json_handler.fn })
429 log_handler =
FDOutputListener(fd=p.stdout.fileno(), es=es, zlog=zlog, close_socket=json_handler)
430 log_handler.handle_line(
"-- starting process: %s --\n" %
str(args.pargs))
434 asyncore.loop(timeout=5)
435 except select.error
as e:
438 log(
"Select error (we will terminate): " +
str(e))
443 log_handler.handle_line(
"\n-- process exit: %s --\n" %
str(r))
446 es.update_doc({
"exit_code": r })
449 CURRENT_PROC.remove(p)
def launch_monitoring(args)