def run():
    app = Application(pages, **config)
    port = random.randrange(options.min_port, options.max_port)
    app.listen(port, address='0.0.0.0')
    signal.signal(signal.SIGCHLD, handle_sigchld)
    args = ['ab']
    args.extend(['-n', str(options.n)])
    concurrency_level = min(options.c, options.n)
    args.extend(['-c', str(concurrency_level)])
    if options.post_file is not None:
        args.extend(['-p', options.post_file])
        args.extend(['-T', 'application/json'])
    if options.email is not None:
        args.extend(['-H', 'Email:{}'.format(options.email)])
    if options.token is not None:
        args.extend(['-H', 'Token:{}'.format(options.token)])
    if options.keepalive:
        args.append('-k')
    if options.quiet:
        # just stops the progress messages printed to stderr
        args.append('-q')
    args.append('http://127.0.0.1:{}{}'.format(port, options.path))
    subprocess.Popen(args)
    IOLoop.instance().start()
    IOLoop.instance().close()
    del IOLoop._instance
    assert not IOLoop.initialized()
Exemple #2
0
    def setUpClass(cls):
        global testApp 
        global app

        app = Application(root=PostHandlingSiteRoot(), urls=None, globals=globals())
        middleware = []
        
        testApp = TestApp(app.wsgifunc(*middleware))
 def get_app(self):
     options.debug = False
     options.demo = True
     self.app = Application(self.session, options=options)
     return self.app
Exemple #4
0
 def setUpClass(cls):
     global testApp, app
     app = Application(root=None, urls=None, globals=globals())
     middleware = []
     testApp = TestApp(app.wsgifunc(*middleware))
import daemon
import logging
import logging.handlers
import os
import signal
import sys

#import tornado.httpserver
#import tornado.ioloop
import tornado.options

from webapp import Application

if __name__ == "__main__":
	app = Application(configfile="webapp.conf")

	context = daemon.DaemonContext(
		working_directory=os.getcwd(),
#		stdout=sys.stdout, stderr=sys.stderr, # XXX causes errors...
	)

	context.signal_map = {
		signal.SIGHUP  : app.reload,
		signal.SIGTERM : app.shutdown,
	}

#	with context:
#		app.run()

	app.run()