def init_webapp(self):
self.web_app = NotebookWebApplication(<EOL>self, self.kernel_manager, self.notebook_manager, <EOL>self.cluster_manager, self.log,<EOL>self.base_project_url, self.webapp_settings<EOL>)<EOL>if self.certfile:<EOL><INDENT>ssl_options = dict(certfile=self.certfile)<EOL>if self.keyfile:<EOL><INDENT>ssl_options['<STR_LIT>'] = self.keyfile<EOL><DEDENT><DEDENT>else:<EOL><INDENT>ssl_options = None<EOL><DEDENT>self.web_app.password = self.password<EOL>self.http_server = httpserver.HTTPServer(self.web_app, ssl_options=ssl_options)<EOL>if ssl_options is None and not self.ip and not (self.read_only and not self.password):<EOL><INDENT>self.log.critical('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>success = None<EOL>for port in random_ports(self.port, self.port_retries+<NUM_LIT:1>):<EOL><INDENT>try:<EOL><INDENT>self.http_server.listen(port, self.ip)<EOL><DEDENT>except socket.error as e:<EOL><INDENT>if e.errno != errno.EADDRINUSE:<EOL><INDENT>raise<EOL><DEDENT>self.log.info('<STR_LIT>' % port)<EOL><DEDENT>else:<EOL><INDENT>self.port = port<EOL>success = True<EOL>break<EOL><DEDENT><DEDENT>if not success:<EOL><INDENT>self.log.critical('<STR_LIT>'<EOL>'<STR_LIT>')<EOL>self.exit(<NUM_LIT:1>)<EOL><DEDENT>
initialize tornado webapp and httpserver