Skip to content

Commit

Permalink
Initial support for Gunicorn, but not ideal.
Browse files Browse the repository at this point in the history
Signed-off-by: bghira <bghira@users.github.com>
  • Loading branch information
bghira committed Apr 22, 2023
1 parent e234630 commit ddc8001
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 4 deletions.
2 changes: 1 addition & 1 deletion discord_tron_master/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def run_discord_bot():

with ThreadPoolExecutor(max_workers=3) as executor:
tasks = [
executor.submit(run_flask_api),
# executor.submit(run_flask_api),
executor.submit(run_discord_bot),
]

Expand Down
5 changes: 4 additions & 1 deletion discord_tron_master/cogs/user/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ async def my_settings(self, ctx, *args):
f"🟠 **Resolution:** `{resolution['width']}x{resolution['height']}`\n❓ Lower resolutions render more quickly, and has a relationship with `steps` that can really influence the output. See **{self.config.get_command_prefix()}help resolution** for more information."
)
if hasattr(ctx, "message"):
await ctx.message.delete()
try:
await ctx.message.delete()
except:
logging.warning(f"Could not delete message, it was likely deleted by another worker or a moderator.")
elif hasattr(ctx, "delete"):
await ctx.delete()
await self.send_large_message(ctx, message)
Expand Down
9 changes: 9 additions & 0 deletions discord_tron_master/gunicorn_entry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from discord_tron_master import __main__

application = __main__.api.app
running = False
print(f"We are running via {__name__}")
if 'gunicorn_entry' in __name__ and running is False:
running = True
print(f"Running main.")
__main__.main()
2 changes: 1 addition & 1 deletion discord_tron_master/websocket_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async def handler(self, websocket, path):
raw_result = await self.command_processor.process_command(decoded, websocket)
result = json.dumps(raw_result)
# Did result error? If so, close the websocket connection:
if "RegistrationError" in raw_result:
if "RegistrationError" in raw_result or "RegistrationError" in result.json()["error"]:
await websocket.close(code=4002, reason="RegistrationError:" + raw_result)
return
if raw_result is None or "error" in raw_result:
Expand Down
23 changes: 22 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ tiktoken = "^0.3.3"
transformers = "^4.28.1"
xformers = "^0.0.18"
accelerate = "^0.18.0"
gunicorn = "^20.1.0"


[build-system]
Expand Down

0 comments on commit ddc8001

Please sign in to comment.