'Start the user\'s spawner
depending from the value of JupyterHub.allow_named_servers
if False:
JupyterHub expects only one single-server per user
url of the server will be /user/:name
if True:
JupyterHub expects more than one single-server per user
url of the server will be /user/:name/:server_name'

@gen.coroutine
def spawn(self, server_name='', options=None):

    db = self.db
    if (self.allow_named_servers and (not server_name)):
        server_name = default_server_name(self)
    base_url = (url_path_join(self.base_url, server_name) + '/')
    orm_server = orm.Server(base_url=base_url)
    db.add(orm_server)
    api_token = self.new_api_token()
    db.commit()
    spawner = self.spawners[server_name]
    spawner.server = server = Server(orm_server=orm_server)
    assert (spawner.orm_spawner.server is orm_server)
    spawner.user_options = (options or {})
    spawner.clear_state()
    spawner.api_token = api_token
    spawner.admin_access = self.settings.get('admin_access', False)
    client_id = ('user-%s' % self.escaped_name)
    if server_name:
        client_id = ('%s-%s' % (client_id, server_name))
    spawner.oauth_client_id = client_id
    oauth_provider = self.settings.get('oauth_provider')
    if oauth_provider:
        client_store = oauth_provider.client_authenticator.client_store
        try:
            oauth_client = client_store.fetch_by_client_id(client_id)
        except ClientNotFoundError:
            oauth_client = None
        if ((oauth_client is None) or (not spawner.will_resume)):
            client_store.add_client(client_id, api_token, url_path_join(self.url, 'oauth_callback'))
    db.commit()
    authenticator = self.authenticator
    if authenticator:
        (yield gen.maybe_future(authenticator.pre_spawn_start(self, spawner)))
    spawner._spawn_pending = True
    try:
        (yield gen.maybe_future(self.spawner.run_pre_spawn_hook()))
        f = spawner.start()
        db.commit()
        ip_port = (yield gen.with_timeout(timedelta(seconds=spawner.start_timeout), f))
        if ip_port:
            (server.ip, server.port) = ip_port
        else:
            self.log.warning('DEPRECATION:    Spawner.start    should    return    (ip,    port)    in    JupyterHub    >=    0.7')
        if (spawner.api_token != api_token):
            orm_token = orm.APIToken.find(self.db, api_token)
            if (orm_token is not None):
                self.db.delete(orm_token)
                self.db.commit()
    except Exception as e:
        if isinstance(e, gen.TimeoutError):
            self.log.warning("{user}'s    server    failed    to    start    in    {s}    seconds,    giving    up".format(user=self.name, s=spawner.start_timeout))
            e.reason = 'timeout'
        else:
            self.log.error("Unhandled    error    starting    {user}'s    server:    {error}".format(user=self.name, error=e))
            e.reason = 'error'
        try:
            (yield self.stop())
        except Exception:
            self.log.error("Failed    to    cleanup    {user}'s    server    that    failed    to    start".format(user=self.name), exc_info=True)
        raise e
    spawner.start_polling()
    if (self.state is None):
        self.state = {}
    spawner.orm_spawner.state = spawner.get_state()
    self.last_activity = spawner.orm_spawner.last_activity = datetime.utcnow()
    db.commit()
    spawner._waiting_for_response = True
    try:
        resp = (yield server.wait_up(http=True, timeout=spawner.http_timeout))
    except Exception as e:
        if isinstance(e, TimeoutError):
            self.log.warning("{user}'s    server    never    showed    up    at    {url}    after    {http_timeout}    seconds.    Giving    up".format(user=self.name, url=server.url, http_timeout=spawner.http_timeout))
            e.reason = 'timeout'
        else:
            e.reason = 'error'
            self.log.error("Unhandled    error    waiting    for    {user}'s    server    to    show    up    at    {url}:    {error}".format(user=self.name, url=server.url, error=e))
        try:
            (yield self.stop())
        except Exception:
            self.log.error("Failed    to    cleanup    {user}'s    server    that    failed    to    start".format(user=self.name), exc_info=True)
        raise e
    else:
        server_version = resp.headers.get('X-JupyterHub-Version')
        _check_version(__version__, server_version, self.log)
    finally:
        spawner._waiting_for_response = False
        spawner._spawn_pending = False
    return self
