Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# Copyright (c) 2014, Facebook, Inc. All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. An additional grant # of patent rights can be found in the PATENTS file in the same directory. #
"""Configure and run the Tornado IO Loop in a sparts task"""
raise SkipTask("No TornadoTasks found or enabled")
"""Base class for tasks that require the tornado IO Loop.
Implicitly configures the tornado IO Loop task as a dependency.
The ioloop can be accessed via `self.ioloop`"""
def ioloop(self): return self.ioloop_task.ioloop
"""A loopless task that implements an HTTP server using Tornado.
It is loopless because it depends on tornado's separate IOLoop task. You will need to subclass this to do something more useful."""
#latency = samples(windows=[60, 3600], # types=[SampleType.AVG, SampleType.MIN, SampleType.MAX])
help='Address to bind server to [%(default)s]') help='Port to run server on [%(default)s]') help='Default path to use for local file socket ' '[%(default)s]') help='Group to create unix files as [%(default)s]')
"""Override this to register custom handlers / routes.""" ('/', HelloWorldHandler), ]
self.getApplicationConfig(), log_function=self.tornadoRequestLog)
assert self.host == self.DEFAULT_HOST, \ "Do not specify host *and* sock (%s, %s)" % \ (self.host, self.sock) assert int(self.port) == self.DEFAULT_PORT, \ "Do not specify port *and* sock (%s, %s)" % \ (self.port, self.DEFAULT_PORT)
gid, mode = -1, 0o600 if self.group != '': e = grp.getgrnam(self.group) gid, mode = e.gr_gid, 0o660
sock = tornado.netutil.bind_unix_socket(self.sock, mode=mode) if gid != -1: os.chown(self.sock, -1, gid) self.server.add_sockets([sock]) else:
self.name, sockaddr[0], sockaddr[1])
def bound_v4_addrs(self): return [a[0] for a in self.bound_addrs if len(a) == 2]
def bound_v6_addrs(self): return [a[0] for a in self.bound_addrs if len(a) == 4]
"""A sample twisted web handler for use in the default http server task""" |