.../emsdk/upstream/emscripten/emrun.py", line 1641, in run
httpd = HTTPWebServer((options.hostname, options.port), HTTPHandler)
File "/usr/lib/python2.7/SocketServer.py", line 417, in __init__
self.server_bind()
File "/usr/lib/python2.7/BaseHTTPServer.py", line 108, in server_bind
SocketServer.TCPServer.server_bind(self)
File "/usr/lib/python2.7/SocketServer.py", line 431, in server_bind
self.socket.bind(self.server_address)
File "/usr/lib/python2.7/socket.py", line 228, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 98] Address already in use
6931, I checked and discovered that the port is already open :lsof -i :6931
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
python 3368 flix 3u IPv4 59440 0t0 TCP localhost:6931 (LISTEN)
> lsof -i :6931
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
python 3368 flix 3u IPv4 59440 0t0 TCP localhost:6931 (LISTEN)
> kill 3368
> lsof -i :6931
[nothing more]
OK, I've made this script for Linux that seems to work (well, it still needs CTRL+C to close the terminal, but then the port is closed).
Script "main.html.sh" in the same folder as main.html
#!/bin/bash
source /.../emsdk/path_to_my_emsdk_env.sh
# Check and close port if open
MYPID=`lsof -i :6931 | sed -n '2p' | awk '{print $2}'`
if [ -n "${MYPID}" ]; then
#echo $MYPID
kill $MYPID
fi
# Execute html
emrun --kill_start --kill_exit main.html
# Check and close port if open
MYPID=`lsof -i :6931 | sed -n '2p' | awk '{print $2}'`
if [ -n "${MYPID}" ]; then
#echo $MYPID
kill $MYPID
fi