Tornado - how to get error when a child process dies immediately?

26 Views Asked by At

I inherited an old Tornado project and am trying to update it. (I'm pointing out this context because it might not be set up according to current best practices.)

Right now, it calls tornado.process.fork_processes() and starts the loop, only to end up in an infinite cycle of:

 child 2 (pid 28921) exited with status 9, restarting
 child 1 (pid 28920) exited with status 9, restarting
 child 0 (pid 28919) exited with status 9, restarting

I've checked the official documentation, searched for other Q&As, and tried searching the github issues but can't find anything addressing my incredibly basic question: How do I see the error messages that are causing these child processes to die immediately?

1

There are 1 best solutions below

0
pawciobiel On

Usually tornado apps use things like enable_pretty_logging:

from tornado.log import enable_pretty_logging
from tornado.options import define, options, parse_command_line

so one can use command switch to enable logging and debug:--logging=debug --debug --port=3333

You could either create only one process by passing args: tornado.process.fork_processes(1, max_restarts=1) https://www.tornadoweb.org/en/stable/process.html#tornado.process.fork_processes

or comment out forking and start single server instead (depending on the version of tornado you use it may look similar to this):

def main():
    app = make_app()
    #sockets = bind_sockets(options.port)                                                                                              
    #tornado.process.fork_processes(0)                                                                                                 
    async def post_fork_main():
        server = HTTPServer(app)
        #server.add_sockets(sockets)                                                                                                   
        server.listen(options.port)
        await asyncio.Event().wait()
    asyncio.run(post_fork_main())

if __name__ == "__main__":
    parse_command_line()
    enable_pretty_logging(options)
    main()