本文整理汇总了Python中tornado.autoreload.start函数的典型用法代码示例。如果您正苦于以下问题:Python start函数的具体用法?Python start怎么用?Python start使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了start函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: runloop
def runloop(addr, port, xheaders, no_keep_alive, use_reloader):
router = SockJSRouter(Connection, '/updates')
handlers = [
(r'/', MainHandler),
(r'/static/(.*)', tornado.web.StaticFileHandler, {'path': os.path.join(FILE_ROOT, 'static/')}),
] + router.urls
tornado_app = tornado.web.Application(handlers)
# start tornado web server in single-threaded mode
# instead auto pre-fork mode with bind/start.
http_server = httpserver.HTTPServer(tornado_app, xheaders=xheaders, no_keep_alive=no_keep_alive)
http_server.listen(int(port), address=addr)
main_loop = tornado.ioloop.IOLoop.instance()
try:
print "Runing on :{port}".format(port=port)
main_loop.start()
except KeyboardInterrupt:
print "Stopped"
sys.exit(0)
if use_reloader:
# Use tornado reload to handle IOLoop restarting.
from tornado import autoreload
autoreload.start()
quit_command = (sys.platform == 'win32') and 'CTRL-BREAK' or 'CONTROL-C'
print quit_command + " to quit."
示例2: run
def run(self, args):
settings = self.get_settings()
for name in map(basename, glob(join('controllers', '*.py'))):
autoreload.watch(name)
Module.load(self.get_controller_import_path(name))
from shrine.routes import make_application
MESSAGE = "{} running at http://localhost:{}\n".format(
settings.PRODUCT_NAME,
settings.PORT,
)
application = make_application()
application.listen(settings.PORT)
self.log.bold_green(MESSAGE)
from shrine.log import logger
logger.setLevel(logging.WARNING)
try:
autoreload.start()
IOLoop.instance().start()
except KeyboardInterrupt:
self.log.bold_red_on_black("\rInterrupted by the User (Control-C)\n")
示例3: runloop
def runloop(addr, port, xheaders, no_keep_alive, use_reloader, daemonize=False):
router = SockJSRouter(Connection, '/updates')
handlers = router.urls + [
(r'/', TeaOrbitHandler),
(r'/static/(.*)', tornado.web.StaticFileHandler, {'path': os.path.join(FILE_ROOT, 'static/')}),
(r'/(?P<room_name>.*)', TeaOrbitHandler),
]
tornado_app = tornado.web.Application(handlers)
# start tornado web server in single-threaded mode
# instead auto pre-fork mode with bind/start.
http_server = httpserver.HTTPServer(tornado_app, xheaders=xheaders, no_keep_alive=no_keep_alive)
http_server.listen(int(port), address=addr)
main_loop = tornado.ioloop.IOLoop.instance()
if use_reloader:
# Use tornado reload to handle IOLoop restarting.
from tornado import autoreload
autoreload.start()
for (path, dirs, files) in os.walk(os.path.join(FILE_ROOT)):
for item in files:
tornado.autoreload.watch(os.path.join(path, item))
try:
print "*** listening on :{port}".format(port=port)
if daemonize is True:
log = open('tornado.log', 'a+')
ctx = daemon.DaemonContext(stdout=log, stderr=log, working_directory='.')
ctx.open()
main_loop.start()
except KeyboardInterrupt:
print "Stopped"
sys.exit(0)
示例4: run
def run(self, reload, logging, **kwargs):
config = self._commandor_res
if not config:
self.error("You need specify --config\n")
self.exit()
configure_logging(logging)
self.application = AggregatorApplication(config)
ioloop = tornado.ioloop.IOLoop.instance()
self.application.configure_app(ioloop)
if reload:
self.display("Autoreload enabled")
autoreload.start(io_loop=ioloop, check_time=100)
# Init signals handler
signal.signal(signal.SIGTERM, self.sig_handler)
# This will also catch KeyboardInterrupt exception
signal.signal(signal.SIGINT, self.sig_handler)
ioloop.start()
示例5: main
def main():
server = make_app()
server.listen(options.port, options.address)
print('listening on ' + str(options.address) + ':' + str(options.port))
autoreload.start()
autoreload.watch(config_path.web)
IOLoop.instance().start()
示例6: run
def run():
router = SockJSRouter(connections.PhotoStream, settings.SOCKET_STREAMER_URL)
handlers = router.urls
runtime_vars = dict()
runtime_vars["last_obj_count"] = None
runtime_vars.update(MultiuploaderImage.objects.aggregate(last_upload=Max('upload_date')))
def db_periodic_check(*a, **kw):
obj_count = MultiuploaderImage.objects.count()
if obj_count != runtime_vars["last_obj_count"]:
runtime_vars["last_obj_count"] = obj_count
if not runtime_vars["last_upload"] is None:
objs = MultiuploaderImage.objects.filter(upload_date__gt=runtime_vars["last_upload"])
runtime_vars.update(MultiuploaderImage.objects.aggregate(last_upload=Max('upload_date')))
for obj in objs:
for user in connections.PhotoStream.connected_users:
user.notify_new_entry(obj)
app = web.Application(handlers)
app.listen(int(settings.SOCKET_STREAMER_PORT), "0.0.0.0")
ioloop.PeriodicCallback(db_periodic_check, 1000).start()
autoreload.start(ioloop.IOLoop.instance())
print "socket streamer is (re)started"
try:
ioloop.IOLoop.instance().start()
except KeyboardInterrupt:
return
示例7: main
def main(self):
#settings passed to tornado app
tornado_settings = {
"template_path": settings.template_path,
"static_path": settings.static_path,
"cookie_secret": settings.cookie_secret,
"login_url": settings.login_url,
}
#init a logger
self.init_logging(settings.log)
#routes
routes = self.init_routes()
self._application = web.Application(routes,**tornado_settings)
http_server = httpserver.HTTPServer(self._application)
http_server.listen(settings.port)
Log.info("Ready and listening")
ioloop = tornado.ioloop.IOLoop().instance()
autoreload.start(ioloop)
try:
ioloop.start()
except KeyboardInterrupt:
pass
示例8: main
def main() -> None:
'''Runs server'''
# Parse options
define('production',
default = False,
help = 'run in production mode',
type = bool)
options.parse_command_line()
# Set server name
pname = settings.process_name if settings.process_name else None
if pname:
setproctitle(pname)
# Register IRC server
server = IRCServer(settings = ircdsettings)
for address, port in ircdsettings['listen']:
server.listen(port, address = address)
# Start profiling
if settings.profiling:
import yappi
yappi.start()
# Setup autoreload
autoreload.start()
# Run application
IOLoop.instance().start()
示例9: main
def main():
parse_command_line()
http_server = tornado.httpserver.HTTPServer(Application())
http_server.listen(options.port)
ioloop = tornado.ioloop.IOLoop().instance()
autoreload.start(ioloop)
ioloop.start()
示例10: startTornado
def startTornado():
global http_server
http_server = HTTPServer(WSGIContainer(create_app("settings.DevelopmentConfig")))
http_server.listen(80)
ioloop = IOLoop.instance()
autoreload.start(ioloop)
ioloop.start()
示例11: start_thememapper
def start_thememapper():
global nav
global mapper
#initialize the necessary classes
mapper = Mapper(get_settings())
nav = Navigation()
# Adds the ability to set config file and port through commandline
p = optparse.OptionParser()
p.add_option('--port', '-p', default=mapper.port,help='port thememapper should run at')
p.add_option('--diazo', '-d', default=False,action="store_true",dest="diazo",help='force diazo server to run')
p.add_option('--diazo_port', '-f', default=mapper.diazo_port,help='port diazo should run at')
options = p.parse_args()[0]
mapper.port = options.port
mapper.diazo_port = options.diazo_port
#start thememapper
print "Starting thememapper on http://0.0.0.0:" + mapper.port
HTTPServer(WSGIContainer(app)).listen(mapper.port)
if options.diazo or mapper.diazo_run == 'True':
try:
from thememapper.diazo import server
print "Starting diazo on http://0.0.0.0:" + mapper.diazo_port
HTTPServer(server.get_application(mapper)).listen(mapper.diazo_port)
except ImportError:
print "You will need to install thememapper.diazo before being able to use this function."
ioloop = IOLoop.instance()
autoreload.watch(os.path.join(os.path.dirname(__file__), 'settings.properties'))
autoreload.add_reload_hook(reload)
autoreload.start(ioloop)
ioloop.start()
示例12: enable_autoreload
def enable_autoreload(self, watch_dirs=list()):
for current_dir in watch_dirs:
if not os.path.isdir(current_dir):
continue
for (path, dirs, files) in os.walk(current_dir):
for item in files:
autoreload.watch(os.path.join(path, item))
autoreload.start(self.__io_loop)
示例13: main
def main():
server.git = git.bake(_cwd=server.settings.repo)
if options.listen_localhost_only:
server.listen(options.port, 'localhost')
else:
server.listen(options.port)
autoreload.start()
autoreload.watch(config_path.web)
IOLoop.instance().start()
示例14: start_diazo_server
def start_diazo_server(settings):
app = get_application(settings)
if app is not False:
print "Starting diazo on http://0.0.0.0:" + settings['diazo_port']
HTTPServer(app).listen(settings['diazo_port'])
ioloop = IOLoop.instance()
autoreload.add_reload_hook(reload)
autoreload.start(ioloop)
ioloop.start()
示例15: main
def main():
options.parse_command_line()
app = web.Application([
(r'/(.*?)', CacheHandler)
])
app.listen(int(getconfig('server_port')))
autoreload.start()
ioloop.IOLoop.instance().start()