You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.7 KiB

  1. # maunium-stickerpicker - A fast and simple Matrix sticker picker widget.
  2. # Copyright (C) 2020 Tulir Asokan
  3. #
  4. # This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU Affero General Public License as published by
  6. # the Free Software Foundation, either version 3 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU Affero General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU Affero General Public License
  15. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. from mautrix.util.program import Program
  17. from mautrix.util.async_db import Database
  18. from .config import Config
  19. from .server import Server
  20. from .database import upgrade_table, Base
  21. from ..version import version
  22. class StickerServer(Program):
  23. module = "sticker.server"
  24. name = "maunium-stickerpicker server"
  25. version = version
  26. command = "python -m sticker.server"
  27. description = "Server for maunium-stickerpicker"
  28. config_class = Config
  29. config: Config
  30. server: Server
  31. database: Database
  32. async def start(self) -> None:
  33. self.database = Database(url=self.config["database"], upgrade_table=upgrade_table)
  34. Base.db = self.database
  35. self.server = Server(self.config)
  36. await self.database.start()
  37. await self.server.start()
  38. await super().start()
  39. async def stop(self) -> None:
  40. await super().stop()
  41. await self.server.stop()
  42. StickerServer().run()