chamburr / modmail

A feature-rich Discord bot for easy communication between server staff and users.
https://modmail.xyz
GNU Affero General Public License v3.0
336 stars 242 forks source link

Updates to prometheus.py fail on MacOS #40

Closed Nelluk closed 3 years ago

Nelluk commented 3 years ago

Describe the bug Self-hosting on MacOS no longer works due to recent changes to prometheus.py. This utility now attempts to open /proc/stat which does not exist in MacOS, and does not handle the error gracefully.

[Cluster 1] Traceback (most recent call last):
[Cluster 1]   File "/Users/Nelluk/Documents/ProgrammingProjects/discord_bots/modmail-pc-2/main.py", line 67, in <module>
[Cluster 1]     loop.run_until_complete(bot.start_bot())
[Cluster 1]   File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
[Cluster 1]     return future.result()
[Cluster 1]   File "/Users/Nelluk/Documents/ProgrammingProjects/discord_bots/modmail-pc-2/classes/bot.py", line 102, in start_bot
[Cluster 1]     await self.connect_prometheus()
[Cluster 1]   File "/Users/Nelluk/Documents/ProgrammingProjects/discord_bots/modmail-pc-2/classes/bot.py", line 95, in connect_prometheus
[Cluster 1]     self.prom = prometheus.Prometheus(self)
[Cluster 1]   File "/Users/Nelluk/Documents/ProgrammingProjects/discord_bots/modmail-pc-2/utils/prometheus.py", line 22, in __init__
[Cluster 1]     with open(os.path.join("/proc", "stat"), "rb") as stat:
[Cluster 1] FileNotFoundError: [Errno 2] No such file or directory: '/proc/stat'
[Cluster 1] ERROR:asyncio:Unclosed client session
[Cluster 1] client_session: <aiohttp.client.ClientSession object at 0x10494ce80>
[Cluster 1] ERROR:asyncio:Exception in default exception handler
chamburr commented 3 years ago

Fixed in 3e9346f45c6170edf3a4ddd05f4b0e2805589c6c