Skip to content
This repository has been archived by the owner on Aug 27, 2024. It is now read-only.

Commit

Permalink
swap to gunicorn
Browse files Browse the repository at this point in the history
  • Loading branch information
CelestialCrafter committed Jan 23, 2024
1 parent 23cfc13 commit 52af980
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ COPY . .
EXPOSE 80
WORKDIR /app/src
ENV WSGI 1
CMD ["conda", "run", "--no-capture-output", "-n", "auto-trading", "python", "app.py"]
CMD ["conda", "run", "--no-capture-output", "-n", "auto-trading", "gunicorn", "app:get_app", "--config", "config.py"]
4 changes: 2 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies:
- blinker=1.7.0
- brotli=1.0.9
- bzip2=1.0.8
- ca-certificates=2023.08.22
- ca-certificates=2023.12.12
- click=8.1.7
- contourpy=1.2.0
- cycler=0.12.1
Expand All @@ -25,6 +25,7 @@ dependencies:
- glib=2.69.1
- gst-plugins-base=1.14.1
- gstreamer=1.14.1
- gunicorn=20.1.0
- icu=58.2
- importlib-metadata=6.8.0
- itsdangerous=2.1.2
Expand Down Expand Up @@ -96,7 +97,6 @@ dependencies:
- tornado=6.1
- typing_extensions=4.8.0
- tzdata=2023c
- waitress=2.1.2
- werkzeug=3.0.1
- wheel=0.41.2
- xz=5.4.2
Expand Down
12 changes: 3 additions & 9 deletions src/app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import waitress
import os
import schedule, time
from threading import Thread
from dotenv import load_dotenv
Expand Down Expand Up @@ -36,11 +34,7 @@ def start_price_cache():

if __name__ == '__main__':
start_price_cache()
app.run()

if os.environ.get('WSGI') == '1':
listen_url = '0.0.0.0:80'
print('starting waitress...')
waitress.serve(app, listen=listen_url)
print(f'listening on {listen_url}')
else:
app.run()
def get_app():
return app
8 changes: 8 additions & 0 deletions src/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import app

bind = '0.0.0.0:80'
workers = 2
loglevel = 'info'
captureoutput = True

on_starting = lambda server: app.start_price_cache()

0 comments on commit 52af980

Please sign in to comment.