Interrupt if unable to start webapp

This commit is contained in:
Davte 2019-08-04 22:27:10 +02:00
parent e6ed4176ad
commit e0f1199768
2 changed files with 6 additions and 2 deletions

View File

@ -14,7 +14,7 @@ __author__ = "Davide Testa"
__email__ = "davide@davte.it" __email__ = "davide@davte.it"
__credits__ = ["Marco Origlia", "Nick Lee @Nickoala"] __credits__ = ["Marco Origlia", "Nick Lee @Nickoala"]
__license__ = "GNU General Public License v3.0" __license__ = "GNU General Public License v3.0"
__version__ = "2.2.5" __version__ = "2.2.6"
__maintainer__ = "Davide Testa" __maintainer__ = "Davide Testa"
__contact__ = "t.me/davte" __contact__ = "t.me/davte"

View File

@ -2272,7 +2272,11 @@ class Bot(TelegramBot, ObjectWithDatabase, MultiLanguageObject):
cls.runner = web.AppRunner(cls.app) cls.runner = web.AppRunner(cls.app)
await cls.runner.setup() await cls.runner.setup()
cls.server = web.TCPSite(cls.runner, cls.local_host, cls.port) cls.server = web.TCPSite(cls.runner, cls.local_host, cls.port)
try:
await cls.server.start() await cls.server.start()
except OSError as e:
logging.error(e)
raise KeyboardInterrupt("Unable to start web app.")
logging.info(f"App running at http://{cls.local_host}:{cls.port}") logging.info(f"App running at http://{cls.local_host}:{cls.port}")
@classmethod @classmethod