Skip to content

Commit

Permalink
fix: Make uwhoisd multiprocess
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafiot committed Nov 6, 2023
1 parent ebf51f6 commit c713065
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions bin/uwhoisd_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from typing import Optional

import tornado
from tornado.ioloop import IOLoop, PeriodicCallback
from tornado.netutil import bind_sockets

Expand Down Expand Up @@ -47,17 +48,22 @@ def __init__(self, loglevel: Optional[int]=None):
async def _to_run_forever_async(self):
self.logger.info("Listen on %s:%d", self.uwhois.iface, self.uwhois.port)
sockets = bind_sockets(self.uwhois.port, self.uwhois.iface)
server = WhoisListener(self.uwhois.whois, 15)
server.add_sockets(sockets)
tornado.process.fork_processes(0)

def callback() -> None:
if self.shutdown_requested():
pc.stop()
async def post_fork_main():
server = WhoisListener(self.uwhois.whois, 15)
server.add_sockets(sockets)

pc = ShutdownCallback(callback, 1000)
pc.start()
def callback() -> None:
if self.shutdown_requested():
pc.stop()

await asyncio.Event().wait()
pc = ShutdownCallback(callback, 1000)
pc.start()

await asyncio.Event().wait()

asyncio.run(post_fork_main())


def main():
Expand Down

0 comments on commit c713065

Please sign in to comment.