Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using `waitress` to serve a Django app on multiple ports

I'm using waitress to serve my Django app. I need it to serve the app on two ports simultaneously, in the same thread. (Can't be on a separate process because I need to be able to run it in my debugger in development.)

How can I do that?

like image 236
Ram Rachum Avatar asked Nov 01 '22 19:11

Ram Rachum


1 Answers

The latest version of waitress is now able to listen on multiple sockets, including IPv4 and IPv6.

Instead of passing in a host/port combination you now provide waitress with a space delineated list, and it will create as many sockets as required.

from waitress import serve
serve(wsgiapp, listen='0.0.0.0:8080 [::]:9090 *:6543')
like image 110
Rebecca Macdonald Avatar answered Nov 15 '22 03:11

Rebecca Macdonald