Skip to content

Commit 7e26456

Browse files
authored
Video ready (#1302)
* Adding endpoint to check video recording started * Exposing port
1 parent 7e0747a commit 7e26456

File tree

4 files changed

+39
-3
lines changed

4 files changed

+39
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ node_modules/
1010
selenium_server_deploy.jar
1111
# assets directory
1212
assets
13+
.vscode
1314

1415
# Ignoring generated files during the build process
1516
StandaloneC*/selenium.conf

Video/Dockerfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,19 @@ ENV DEBIAN_FRONTEND=noninteractive \
1717
#========================
1818
RUN apt-get -qqy update \
1919
&& apt-get -qqy --no-install-recommends install \
20-
supervisor x11-xserver-utils \
20+
supervisor x11-xserver-utils python3-pip \
2121
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*
2222

2323
#======================================
24-
# Add Supervisor configuration file
24+
# Add Supervisor configuration files
2525
#======================================
2626
COPY supervisord.conf /etc
27-
COPY entry_point.sh video.sh /opt/bin/
27+
COPY entry_point.sh video.sh video_ready.py /opt/bin/
28+
RUN cd /opt/bin && pip install psutil
2829

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

3132
ENTRYPOINT ["/opt/bin/entry_point.sh"]
3233
CMD ["/opt/bin/entry_point.sh"]
34+
35+
EXPOSE 9000

Video/supervisord.conf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,16 @@ redirect_stderr=true
2525
stdout_logfile=/dev/stdout
2626
stdout_logfile_maxbytes=0
2727

28+
[program:video-ready]
29+
priority=5
30+
command=python3 /opt/bin/video_ready.py
31+
autostart=true
32+
autorestart=false
33+
startsecs=0
34+
startretries=0
35+
stopsignal=INT
36+
37+
;Logs (all activity redirected to stdout so it can be seen through "docker logs"
38+
redirect_stderr=true
39+
stdout_logfile=/dev/stdout
40+
stdout_logfile_maxbytes=0

Video/video_ready.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from http.server import BaseHTTPRequestHandler,HTTPServer
2+
from os import environ
3+
import json
4+
import psutil
5+
6+
video_ready_port = environ.get('VIDEO_READY_PORT', 9000)
7+
8+
class Handler(BaseHTTPRequestHandler):
9+
10+
def do_GET(self):
11+
video_ready = "ffmpeg" in (p.name().lower() for p in psutil.process_iter())
12+
response_code = 200 if video_ready else 404
13+
response_text = "ready" if video_ready else "not ready"
14+
self.send_response(response_code)
15+
self.end_headers()
16+
self.wfile.write(json.dumps({'status': response_text}).encode('utf-8'))
17+
18+
httpd = HTTPServer( ('0.0.0.0', video_ready_port), Handler )
19+
httpd.serve_forever()

0 commit comments

Comments
 (0)