'Start the onionshare server. This uses multiple threads to start the Tor onion
server and the web app.'

def start_server(self):

    common.log('OnionShareGui', 'start_server')
    self.set_server_active(True)
    self.app.set_stealth(self.settings.get('use_stealth'))
    self.downloads_container.hide()
    self.downloads.reset_downloads()
    web.download_count = 0
    web.error404_count = 0
    web.set_gui_mode()
    def start_onion_service(self):
        try:
            self.app.start_onion_service()
            self.starting_server_step2.emit()
        except (TorTooOld, TorErrorInvalidSetting, TorErrorAutomatic, TorErrorSocketPort, TorErrorSocketFile, TorErrorMissingPassword, TorErrorUnreadableCookieFile, TorErrorAuthError, TorErrorProtocolError, BundledTorTimeout) as e:
            self.starting_server_error.emit(e.args[0])
            return
        self.app.stay_open = (not self.settings.get('close_after_first_download'))
        t = threading.Thread(target=web.start, args=(self.app.port, self.app.stay_open))
        t.daemon = True
        t.start()
        time.sleep(0.2)
    t = threading.Thread(target=start_onion_service, kwargs={'self': self})
    t.daemon = True
    t.start()
