Skip to content

Commit

Permalink
Video ready (#1302)
Browse files Browse the repository at this point in the history
* Adding endpoint to check video recording started

* Exposing port
  • Loading branch information
diemol committed May 30, 2021
1 parent 7e0747a commit 7e26456
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -10,6 +10,7 @@ node_modules/
selenium_server_deploy.jar
# assets directory
assets
.vscode

# Ignoring generated files during the build process
StandaloneC*/selenium.conf
Expand Down
9 changes: 6 additions & 3 deletions Video/Dockerfile
Expand Up @@ -17,16 +17,19 @@ ENV DEBIAN_FRONTEND=noninteractive \
#========================
RUN apt-get -qqy update \
&& apt-get -qqy --no-install-recommends install \
supervisor x11-xserver-utils \
supervisor x11-xserver-utils python3-pip \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*

#======================================
# Add Supervisor configuration file
# Add Supervisor configuration files
#======================================
COPY supervisord.conf /etc
COPY entry_point.sh video.sh /opt/bin/
COPY entry_point.sh video.sh video_ready.py /opt/bin/
RUN cd /opt/bin && pip install psutil

RUN mkdir -p /var/run/supervisor /var/log/supervisor /videos

ENTRYPOINT ["/opt/bin/entry_point.sh"]
CMD ["/opt/bin/entry_point.sh"]

EXPOSE 9000
13 changes: 13 additions & 0 deletions Video/supervisord.conf
Expand Up @@ -25,3 +25,16 @@ redirect_stderr=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0

[program:video-ready]
priority=5
command=python3 /opt/bin/video_ready.py
autostart=true
autorestart=false
startsecs=0
startretries=0
stopsignal=INT

;Logs (all activity redirected to stdout so it can be seen through "docker logs"
redirect_stderr=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
19 changes: 19 additions & 0 deletions Video/video_ready.py
@@ -0,0 +1,19 @@
from http.server import BaseHTTPRequestHandler,HTTPServer
from os import environ
import json
import psutil

video_ready_port = environ.get('VIDEO_READY_PORT', 9000)

class Handler(BaseHTTPRequestHandler):

def do_GET(self):
video_ready = "ffmpeg" in (p.name().lower() for p in psutil.process_iter())
response_code = 200 if video_ready else 404
response_text = "ready" if video_ready else "not ready"
self.send_response(response_code)
self.end_headers()
self.wfile.write(json.dumps({'status': response_text}).encode('utf-8'))

httpd = HTTPServer( ('0.0.0.0', video_ready_port), Handler )
httpd.serve_forever()

0 comments on commit 7e26456

Please sign in to comment.