def serve(*services): FLAGS(sys.argv) logging.basicConfig() if not services: services = [Service.create()] name = "_".join(x.binary for x in services) logging.debug(_("Serving %s"), name) logging.debug(_("Full set of FLAGS:")) for flag in FLAGS: flag_get = FLAGS.get(flag, None) logging.debug("%(flag)s : %(flag_get)s" % locals()) for x in services: x.start()
def serve(filename): logging.debug(_("Serving %s") % filename) name = os.path.basename(filename) OptionsClass = WrapTwistedOptions(TwistdServerOptions) options = OptionsClass() argv = options.parseOptions() FLAGS.python = filename FLAGS.no_save = True if not FLAGS.pidfile: FLAGS.pidfile = '%s.pid' % name elif FLAGS.pidfile.endswith('twistd.pid'): FLAGS.pidfile = FLAGS.pidfile.replace('twistd.pid', '%s.pid' % name) if not FLAGS.prefix: FLAGS.prefix = name elif FLAGS.prefix.endswith('twisted'): FLAGS.prefix = FLAGS.prefix.replace('twisted', name) action = 'start' if len(argv) > 1: action = argv.pop() if action == 'stop': stop(FLAGS.pidfile) sys.exit() elif action == 'restart': stop(FLAGS.pidfile) elif action == 'start': pass else: print 'usage: %s [options] [start|stop|restart]' % argv[0] sys.exit(1) logging.basicConfig() logging.debug(_("Full set of FLAGS:")) for flag in FLAGS: logging.debug("%s : %s" % (flag, FLAGS.get(flag, None))) logging.audit(_("Starting %s"), name) twistd.runApp(options)
if self.showAll: if current_case != self._last_case: self.stream.writeln(current_case) self._last_case = current_case self.stream.write( ' %s' % str(test.test._testMethodName).ljust(60)) self.stream.flush() class NovaTestRunner(core.TextTestRunner): def _makeResult(self): return NovaTestResult(self.stream, self.descriptions, self.verbosity, self.config) if __name__ == '__main__': logging.basicConfig() c = config.Config(stream=sys.stdout, env=os.environ, verbosity=3, plugins=core.DefaultPluginManager()) runner = NovaTestRunner(stream=c.stream, verbosity=c.verbosity, config=c) sys.exit(not core.run(config=c, testRunner=runner))
def __init__(self, threads=1000): logging.basicConfig() self.pool = eventlet.GreenPool(threads)