Discussion:
[tornado] Snippet for abstract namespace support for Tornado apps.
Shane Spencer
2018-09-26 23:30:36 UTC
Permalink
This seemed to work out well enough. Now if NGINX would just support these
without patching....

....

http_server = tornado.httpserver.HTTPServer(
application,
trusted_downstream=['127.0.0.1'],
xheaders=True,
)

if options.listen_unix_socket_abstract:

import socket

sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.setblocking(0)
sock.bind('\0' + options.listen_unix_socket_abstract)
sock.listen(tornado.netutil._DEFAULT_BACKLOG)

http_server.add_socket(sock)

elif options.listen_unix_socket:
sock = tornado.netutil.bind_unix_socket(
options.listen_unix_socket,
mode=0o666
)
http_server.add_socket(sock)
else:
http_server.listen(options.listen_port, address=options.listen_host)

....
<https://about.me/ShaneSpencer?promo=email_sig&utm_source=product&utm_medium=email_sig&utm_campaign=gmail_api&utm_content=thumb>
Shane Spencer
about.me/ShaneSpencer
<https://about.me/ShaneSpencer?promo=email_sig&utm_source=product&utm_medium=email_sig&utm_campaign=gmail_api&utm_content=thumb>
--
You received this message because you are subscribed to the Google Groups "Tornado Web Server" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-tornado+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
A. Jesse Jiryu Davis
2018-09-28 12:27:16 UTC
Permalink
That is a Linux feature that I barely even remember hearing about until
now, thanks for educating me =)
Post by Shane Spencer
This seemed to work out well enough. Now if NGINX would just support
these without patching....
....
http_server = tornado.httpserver.HTTPServer(
application,
trusted_downstream=['127.0.0.1'],
xheaders=True,
)
import socket
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.setblocking(0)
sock.bind('\0' + options.listen_unix_socket_abstract)
sock.listen(tornado.netutil._DEFAULT_BACKLOG)
http_server.add_socket(sock)
sock = tornado.netutil.bind_unix_socket(
options.listen_unix_socket,
mode=0o666
)
http_server.add_socket(sock)
http_server.listen(options.listen_port,
address=options.listen_host)
....
<https://about.me/ShaneSpencer?promo=email_sig&utm_source=product&utm_medium=email_sig&utm_campaign=gmail_api&utm_content=thumb>
Shane Spencer
about.me/ShaneSpencer
<https://about.me/ShaneSpencer?promo=email_sig&utm_source=product&utm_medium=email_sig&utm_campaign=gmail_api&utm_content=thumb>
--
You received this message because you are subscribed to the Google Groups
"Tornado Web Server" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Tornado Web Server" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-tornado+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...