def setup(executor):
<EOL>def signal_handler(signal_to_handle, frame):<EOL><INDENT>Log.info('<STR_LIT>', signal_to_handle)<EOL>executor.stop_state_manager_watches()<EOL>sys.exit(signal_to_handle)<EOL><DEDENT>def cleanup():<EOL><INDENT>"""<STR_LIT>"""<EOL>Log.info('<STR_LIT>')<EOL>for pid in list(executor.processes_to_monitor.keys()):<EOL><INDENT>os.kill(pid, signal.SIGTERM)<EOL><DEDENT>time.sleep(<NUM_LIT:5>)<EOL>os.killpg(<NUM_LIT:0>, signal.SIGTERM)<EOL><DEDENT>shardid = executor.shard<EOL>log.configure(logfile='<STR_LIT>' % shardid)<EOL>pid = os.getpid()<EOL>sid = os.getsid(pid)<EOL>if pid != sid:<EOL><INDENT>Log.info('<STR_LIT>')<EOL>os.setpgrp() <EOL><DEDENT>Log.info('<STR_LIT>')<EOL>signal.signal(signal.SIGTERM, signal_handler)<EOL>Log.info('<STR_LIT>')<EOL>atexit.register(cleanup)<EOL>
Set up log, process and signal handlers