Unverified Commit f4b05625 authored by Kroese's avatar Kroese Committed by GitHub
Browse files

fix: Use combination of websockets and long polling (#882)

parent ce0c7959
Loading
Loading
Loading
Loading
+15 −10
Original line number Diff line number Diff line
@@ -548,9 +548,7 @@ closeBridge() {
  return 0
}

closeNetwork() {

  if [[ "${WEB:-}" != [Nn]* ]]; then
closeWeb() {

  # Shutdown nginx
  nginx -s stop 2> /dev/null
@@ -561,6 +559,13 @@ closeNetwork() {
  [ -s "$pid" ] && pKill "$(<"$pid")"
  rm -f "$pid"

  return 0
}

closeNetwork() {

  if [[ "${WEB:-}" != [Nn]* ]]; then
    closeWeb  
  fi

  [[ "$NETWORK" == [Nn]* ]] && return 0
+0 −2
Original line number Diff line number Diff line
@@ -206,6 +206,4 @@ if [[ "$KVM" != [Nn]* ]]; then

fi

html "Starting $APP for $ENGINE..."

return 0
+2 −0
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@ fi
cp -r /var/www/* /run/shm
rm -f /var/run/websocketd.pid

html "Starting $APP for $ENGINE..."

if [[ "${WEB:-}" != [Nn]* ]]; then

  mkdir -p /etc/nginx/sites-enabled
+16 −11
Original line number Diff line number Diff line
@@ -66,7 +66,6 @@ function processInfo() {

        var msg = request.responseText;
        if (msg == null || msg.length == 0) {
            setError("Lost connection");
            window.location.reload();
            return false;
        }
@@ -78,6 +77,7 @@ function processInfo() {
                notFound = true;
            } else {
                setInfo(msg);
                schedule();
                return true;
            }
        }
@@ -103,13 +103,19 @@ function setInfo(msg, loading, error) {
            return false;
        }

        var el = document.getElementById("spinner");
        var el = document.getElementById("info");

        if (el.innerText == msg || el.innerHTML == msg) {
            return true;
        }

        var spin = document.getElementById("spinner");

        error = !!error;
        if (!error) {
            el.style.visibility = 'visible';
            spin.style.visibility = 'visible';
        } else {
            el.style.visibility = 'hidden';
            spin.style.visibility = 'hidden';
        }

        loading = !!loading;
@@ -117,12 +123,7 @@ function setInfo(msg, loading, error) {
            msg = "<p class=\"loading\">" + msg + "</p>";
        }

        el = document.getElementById("info");

        if (el.innerHTML != msg) {
        el.innerHTML = msg;
        }

        return true;

    } catch (e) {
@@ -136,6 +137,10 @@ function setError(text) {
    return setInfo(text, false, true);
}

function schedule() {
    setTimeout(getInfo, interval);
}

function connect() {

    var wsUrl = getURL() + "/status";
@@ -182,5 +187,5 @@ function connect() {
    };
}

getInfo();
schedule();
connect();