Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Chelsea486MHz committed Dec 31, 2023
1 parent ebce8d7 commit 9a36724
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 17 deletions.
1 change: 0 additions & 1 deletion auth/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ FROM python:3.11
# App settings
ENV DEBUG False
WORKDIR /app
EXPOSE 5000
ENV PYTHONUNBUFFERED=1

# Install dependencies from the build image venv
Expand Down
2 changes: 0 additions & 2 deletions compute/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ FROM python:3.11
# App settings
ENV DEBUG False
WORKDIR /app
EXPOSE 5000
ENV COQUI_TOS_AGREED=1
ENV PYTHONUNBUFFERED=1

# Install dependencies from the build image venv
Expand Down
10 changes: 7 additions & 3 deletions compute/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ class Token(db.Model):
token = db.Column(db.String(48), unique=True, nullable=False)


@app.route('/api/version')
def generate_step():
@app.route('/api/common/type')
def api_common_type():
return stargazer.common.version

@app.route('/api/common/version')
def api_common_version():
print('Request received')

# Check if the authorization token is included in the request headers
Expand All @@ -40,7 +44,7 @@ def generate_step():
return 'Unauthorized', 401
print('Request authenticated')

return version
return stargazer.common.version


if __name__ == '__main__':
Expand Down
14 changes: 14 additions & 0 deletions compute/gunicorn_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import os

# Restart Gunicorn every 950-1050 requests
# May mitigate memory leak attacks
max_requests = 1000
max_requests_jitter = 50

listening_address = os.environ.get("LISTENING_ADDRESS", "0.0.0.0")
listening_port = os.environ.get("LISTENING_PORT", "5000")
bind = "{}:{}".format(listening_address, listening_port)

# May thread starve /!\
workers = 1
timeout = 120
4 changes: 4 additions & 0 deletions compute/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
gunicorn
flask
Flask-SQLAlchemy
PyMySQL
25 changes: 14 additions & 11 deletions deployments/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
version: '3'

services:
compute-1:
build: ../compute

compute-2:
build: ../compute

compute-3:
compute:
build: ../compute
restart: unless-stopped
depends_on:
- auth
- manager
environment:
TOKEN: 'Kq5AfYtpYkcGbPnm0z2I_SIRGRem-zKmXA5rnPguUIB7y2DNQTW1KIYouV9IaHH6'

auth:
build: ../auth
restart: unless-stopped
environment:
USER_TOKEN: 'DrERUGbWdDltQmkii0Mswney_dgDnUKFAwMC-TYB-C2zMnOuQeHgPtsHhBWzgoIg'

manager:
build: ../manager
restart: unless-stopped
depends_on:
- compute-1
- compute-2
- compute-3
- auth
- auth
environment:
TOKEN: '3gEy0rWMRqXfJw9aLKzzSuhXggxGTLL4bYsTt-VdmFcmOWQ_ZCwTswvZM6kNVg2r'
2 changes: 2 additions & 0 deletions stargazer/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version = "1.0"
type = "compute"

0 comments on commit 9a36724

Please sign in to comment.