def run(command, global_options, options, args): if not args: command.parser.error('Missing instance directory.') instance_dir = args[0] config = SafeConfigParser() settings_file = path.join(instance_dir, 'settings.ini') if not config.read([settings_file]): command.parser.error('Settings file "%s" not found.' % settings_file) address = config.get('misc', 'server_bind_ip') or '127.0.0.1' port = config.getint('misc', 'server_bind_port') or 8888 log('Starting...') try: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect( (address, port) ) log('ERROR: Address "%s:%s" already in use.' % (address, port)) sys.exit(1) except socket.error: pass finally: sock.close() log('GEvent WSGI server listening on %s:%s.' % (address, port)) log('Hit CTRL + C to stop.') run_server(instance_dir, address, port, options.access_log)
def run(self): run_server(self.working_dir, self.address, self.port)