Real-Time Web Demo: Simplify server initialization.

This commit is contained in:
Brandon Amos 2015-12-19 18:17:27 -05:00
parent 7d73946836
commit 027f9dcf8e
2 changed files with 45 additions and 14 deletions

34
demos/web/start-servers.sh Executable file
View File

@ -0,0 +1,34 @@
#!/bin/bash
set -e -u
function die { echo $1; exit 42; }
HTTP_PORT=8000
WEBSOCKET_PORT=9000
case $# in
0) ;;
1) HTTP_PORT=$1
;;
2) WEBSOCKET_PORT=$2
;;
*) die "Usage: $0 <HTTP Server Port> <WebSocket Port>"
;;
esac
cd $(dirname $0)
trap 'kill $(jobs -p)' EXIT
printf "HTTP Port: %s\n" $HTTP_PORT
printf "WebSocket Port: %s\n\n" $WEBSOCKET_PORT
WEBSOCKET_LOG='/tmp/openface.websocket.log'
printf "WebSocket Server: Logging to '%s'\n\n" $WEBSOCKET_LOG
python2 -m SimpleHTTPServer $HTTP_PORT &> /dev/null &
cd ../../ # Root OpenFace directory.
./demos/web/websocket-server.py --port $WEBSOCKET_PORT 2>&1 | tee $WEBSOCKET_LOG &
wait

View File

@ -40,22 +40,19 @@ This is currently not included in the Docker container.
The application is split into a processing server and static The application is split into a processing server and static
web pages that communicate via web sockets. web pages that communicate via web sockets.
Start the server with `./demos/web/server.py`. Start the HTTP and WebSocket servers on ports 8000 and 9000, respectively,
With your client system with webcam and browser, with `./demos/web/start-servers.sh`.
you should now be able to send a request to the websocket If you wish to use other ports,
pass them as `./demos/web/start-servers.sh HTTP_PORT WEBSOCKET_PART`.
You should now be able to send a request to the websocket
connection with `curl your-server:9000` (`localhost:9000` if running on your machine), connection with `curl your-server:9000` (`localhost:9000` if running on your machine),
which should inform you that it's' a WebSocket endpoint and not a web server. which should inform you that it's' a WebSocket endpoint and not a web server.
Please check routing between your client and server if you Please check routing between your client and server if you
get connection refused issues. get connection refused issues.
You should now also be able to access the demo from your browser
If you are running the server remotely (relative to your browser) at `http://your-server:8000`.
or in a Docker container,
change the WebSocket connection in
[index.html](https://github.com/cmusatyalab/openface/blob/master/demos/web/index.html)
from `127.0.0.1` to the IP address of your server
that you were able to connect to with `curl`.
With the WebSocket server running, serve the static website with
`python2 -m SimpleHTTPServer 8000` from the `/demos/web` directory.
You should now be able to access the demo from your browser
at `http://your-server:8000`, (`http://localhost:8000` if running on your machine),
The saved faces are only available for the browser session. The saved faces are only available for the browser session.
If you experience issues running these commands,
please post the WebSocket log contents from `/tmp/openface.websocket.log`
to [our mailing list](https://groups.google.com/forum/#!forum/cmu-openface).