Chandima Prabhath commited on
Commit
f27ea86
·
1 Parent(s): f0052f2

Update Dockerfile and run.py for improved environment configuration; enhance health check response in main.py

Browse files
Files changed (3) hide show
  1. Dockerfile +2 -1
  2. run.py +9 -12
  3. video_encoder/api/main.py +1 -1
Dockerfile CHANGED
@@ -12,4 +12,5 @@ RUN pip install --no-cache-dir --upgrade -r requirements.txt
12
  EXPOSE 7860
13
 
14
  COPY --chown=user . /app
15
- CMD ["python","run.py"]
 
 
12
  EXPOSE 7860
13
 
14
  COPY --chown=user . /app
15
+ ENV HOST=0.0.0.0 PORT=7860
16
+ CMD ["python", "run.py"]
run.py CHANGED
@@ -4,20 +4,17 @@ from rq import Worker, Queue
4
  from redis import Redis
5
  from video_encoder.config import RedisConfig
6
 
7
- if __name__ == "__main__":
8
- import threading
 
 
 
9
 
10
  def start_worker():
11
- redis_conn = RedisConfig.get_connection()
12
- queues = [Queue(name=RedisConfig.QUEUE_NAME, connection=redis_conn)]
13
- worker = Worker(queues, connection=redis_conn)
14
  worker.work()
15
 
16
- worker_thread = threading.Thread(target=start_worker)
 
17
  worker_thread.start()
18
-
19
- uvicorn.run(
20
- app,
21
- host="0.0.0.0",
22
- port=7860
23
- )
 
4
  from redis import Redis
5
  from video_encoder.config import RedisConfig
6
 
7
+ import threading
8
+ import uvicorn
9
+ from video_encoder.api.main import app
10
+ from rq import Worker
11
+ from video_encoder.config import RedisConfig
12
 
13
  def start_worker():
14
+ worker = Worker([RedisConfig.QUEUE_NAME], connection=RedisConfig.get_connection())
 
 
15
  worker.work()
16
 
17
+ if __name__ == "__main__":
18
+ worker_thread = threading.Thread(target=start_worker, daemon=True)
19
  worker_thread.start()
20
+ uvicorn.run(app, host="0.0.0.0", port=7860, log_config=None)
 
 
 
 
 
video_encoder/api/main.py CHANGED
@@ -26,7 +26,7 @@ async def startup_event():
26
 
27
  @app.get("/")
28
  async def health_check():
29
- return {"status": "ok"}
30
 
31
  @app.post("/upload")
32
  async def upload_video(file: UploadFile):
 
26
 
27
  @app.get("/")
28
  async def health_check():
29
+ return {"status": "ok", "redis": "connected"}
30
 
31
  @app.post("/upload")
32
  async def upload_video(file: UploadFile):