Skip to content

Commit

Permalink
#183 port open issue (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
anandtripathi5 authored May 15, 2022
1 parent 8d7feb9 commit b8fd373
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
9 changes: 9 additions & 0 deletions robyn/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def start(self, url="127.0.0.1", port=5000):
"""

if not self.dev:
processes = []
workers = self.workers
socket = SocketHeld(url, port)
for _ in range(self.processes):
Expand All @@ -122,8 +123,16 @@ def start(self, url="127.0.0.1", port=5000):
),
)
p.start()
processes.append(p)

print("Press Ctrl + C to stop \n")
try:
for process in processes:
process.join()
except KeyboardInterrupt:
print(f"\n{Colors.BOLD}{Colors.OKGREEN} Terminating server!! {Colors.ENDC}")
for process in processes:
process.kill()
else:
event_handler = EventHandler(self.file_path)
event_handler.start_server_first_time()
Expand Down
8 changes: 6 additions & 2 deletions robyn/processpool.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,9 @@ def spawn_process(
web_socket.methods["message"],
)

server.start(socket, workers)
asyncio.get_event_loop().run_forever()
try:
server.start(socket, workers)
loop = asyncio.get_event_loop()
loop.run_forever()
except KeyboardInterrupt:
loop.close()

0 comments on commit b8fd373

Please sign in to comment.