diff --git a/.github/workflows/healthcheck-image-sfu.yml b/.github/workflows/healthcheck-image-sfu.yml new file mode 100644 index 00000000..24f25352 --- /dev/null +++ b/.github/workflows/healthcheck-image-sfu.yml @@ -0,0 +1,27 @@ +name: Check health of SFU docker image + +on: + workflow_dispatch: + push: + paths: + - "SFU/**" + pull_request: + paths: + - "SFU/**" + +jobs: + build-docker-image: + if: github.repository == 'EpicGamesExt/PixelStreamingInfrastructure' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Build the SFU container image + uses: docker/build-push-action@v3 + with: + context: . + push: false + file: SFU/Dockerfile + + diff --git a/.github/workflows/healthcheck-image-wilbur.yml b/.github/workflows/healthcheck-image-wilbur.yml new file mode 100644 index 00000000..e86e795f --- /dev/null +++ b/.github/workflows/healthcheck-image-wilbur.yml @@ -0,0 +1,26 @@ +name: Check health of wilbur docker image + +on: + workflow_dispatch: + push: + paths: + - "SignallingWebServer/**" + pull_request: + paths: + - "SignallingWebServer/**" + +jobs: + build-docker-image: + if: github.repository == 'EpicGamesExt/PixelStreamingInfrastructure' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Build the wilbur container image + uses: docker/build-push-action@v3 + with: + context: . + push: false + file: SignallingWebServer/Dockerfile + diff --git a/.github/workflows/healthcheck-libraries.yml b/.github/workflows/healthcheck-libraries.yml new file mode 100644 index 00000000..d29883b7 --- /dev/null +++ b/.github/workflows/healthcheck-libraries.yml @@ -0,0 +1,61 @@ +name: Library Health + +on: + workflow_dispatch: + push: + paths: + - "Common/**" + - "Signalling/**" + - "SignallingWebServer/**" + - "Frontend/library/**" + - "Frontend/ui-library/**" + - "Frontend/implementations/typescript/**" + pull_request: + paths: + - "Common/**" + - "Signalling/**" + - "SignallingWebServer/**" + - "Frontend/library/**" + - "Frontend/ui-library/**" + - "Frontend/implementations/typescript/**" + +env: + NODE_VERSION: 18.17.x + +jobs: + build: + if: github.repository == 'EpicGamesExt/PixelStreamingInfrastructure' + runs-on: ubuntu-latest + steps: + - name: Checkout source code + uses: actions/checkout@v3 + + - uses: actions/setup-node@v4 + with: + node-version: "${{ env.NODE_VERSION }}" + registry-url: 'https://registry.npmjs.org' + + - name: Clean build and lint checks on common library + working-directory: Common + run: npm ci && npm run build && npm run lint + + - name: Clean build and lint checks on signalling library + working-directory: Signalling + run: npm ci && npm link ../Common && npm run build && npm run lint + + - name: Clean build and lint checks on wilbur + working-directory: SignallingWebServer + run: npm ci && npm link ../Signalling && npm run build && npm run lint + + - name: Clean build, lint and unit tests on frontend library + working-directory: Frontend/library + run: npm ci && npm link ../../Common && npm run build && npm run lint && npm run test + + - name: Clean build and lint checks on frontend ui library + working-directory: Frontend/ui-library + run: npm ci && npm link ../library && npm run build && npm run lint + + - name: Clean build of frontend implementation + working-directory: Frontend/implementations/typescript + run: npm ci && npm link ../../library ../../ui-library && npm run build + diff --git a/.github/workflows/check-markdown-links.yml b/.github/workflows/healthcheck-markdown-links.yml similarity index 95% rename from .github/workflows/check-markdown-links.yml rename to .github/workflows/healthcheck-markdown-links.yml index a965da0e..aaa8f7fc 100644 --- a/.github/workflows/check-markdown-links.yml +++ b/.github/workflows/healthcheck-markdown-links.yml @@ -1,4 +1,4 @@ -name: Check Markdown links +name: Check health of document links on: push diff --git a/.github/workflows/healthcheck-platform-scripts.yml b/.github/workflows/healthcheck-platform-scripts.yml new file mode 100644 index 00000000..10796a58 --- /dev/null +++ b/.github/workflows/healthcheck-platform-scripts.yml @@ -0,0 +1,36 @@ +name: Check health of platform scripts + +on: + workflow_dispatch: + push: + paths: + - "SignallingWebServer/**" + pull_request: + paths: + - "SignallingWebServer/**" + +jobs: + run-script-linux: + if: github.repository == 'EpicGamesExt/PixelStreamingInfrastructure' + runs-on: ubuntu-latest + steps: + - name: Checkout source code + uses: actions/checkout@v3 + - name: Launch and query signalling server using the REST API + working-directory: SignallingWebServer + run: | + ./platform_scripts/bash/start.sh --rest_api & + curl --retry 10 --retry-delay 20 --retry-connrefused http://localhost/api/status + + run-script-windows: + if: github.repository == 'EpicGamesExt/PixelStreamingInfrastructure' + runs-on: windows-latest + steps: + - name: Checkout source code + uses: actions/checkout@v3 + - name: Launch and query signalling server using the REST API + working-directory: SignallingWebServer + run: | + Start-Process -NoNewWindow .\platform_scripts\cmd\start.bat --rest_api + curl --retry 10 --retry-delay 20 --retry-connrefused http://localhost/api/status + diff --git a/.github/workflows/healthcheck-signalling-protocol.yml b/.github/workflows/healthcheck-signalling-protocol.yml new file mode 100644 index 00000000..6ee5abf3 --- /dev/null +++ b/.github/workflows/healthcheck-signalling-protocol.yml @@ -0,0 +1,31 @@ +name: Check health of signalling protocol + +on: + workflow_dispatch: + push: + paths: + - "Common/**" + - "Signalling/**" + - "SignallingWebServer/**" + - "SS_Test/**" + pull_request: + paths: + - "Common/**" + - "Signalling/**" + - "SignallingWebServer/**" + - "SS_Test/**" + +jobs: + signalling-protocol-test: + if: github.repository == 'EpicGamesExt/PixelStreamingInfrastructure' + runs-on: ubuntu-latest + steps: + - name: Checkout source code + uses: actions/checkout@v3 + + - name: Launch signalling tests in docker containers + uses: isbang/compose-action@v1.5.1 + with: + compose-file: "SS_Test/docker-compose.yml" + up-flags: "--build --abort-on-container-exit --exit-code-from tester" + diff --git a/.github/workflows/publish-container-images.yml b/.github/workflows/publish-container-images.yml new file mode 100644 index 00000000..26695f79 --- /dev/null +++ b/.github/workflows/publish-container-images.yml @@ -0,0 +1,42 @@ +name: Publish container images + +on: + workflow_dispatch: + push: + branches: ['UE5.5'] + paths: ['SignallingWebServer/**'] + +jobs: + signalling-server-image: + if: github.repository == 'EpicGamesExt/PixelStreamingInfrastructure' + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + username: pixelstreamingunofficial + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Build and push the Signalling Server container image + uses: docker/build-push-action@v3 + with: + context: . + tags: 'pixelstreamingunofficial/pixel-streaming-signalling-server:5.4' + push: true + file: SignallingWebServer/Dockerfile + - + name: Build and push the SFU container image + uses: docker/build-push-action@v3 + with: + context: . + tags: 'pixelstreamingunofficial/pixel-streaming-sfu:5.4' + push: true + file: SFU/Dockerfile + diff --git a/.github/workflows/run-library-unit-tests.yml b/.github/workflows/run-library-unit-tests.yml deleted file mode 100644 index 49cd426e..00000000 --- a/.github/workflows/run-library-unit-tests.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: Run library unit tests - -on: - push: - paths: ['Frontend/library/**'] - pull_request: - paths: ['Frontend/library/**'] - -env: - NODE_VERSION: 18.17.x - -jobs: - - build: - runs-on: ubuntu-latest - defaults: - run: - working-directory: ./ - - permissions: - contents: write - steps: - - name: "Checkout source code" - uses: actions/checkout@v3 - - - name: Setup node - uses: actions/setup-node@v3 - with: - node-version: "${{ env.NODE_VERSION }}" - registry-url: 'https://registry.npmjs.org' - - - name: Build common library - working-directory: ./Common - run: npm ci && npm run build - - - name: Install library deps - working-directory: ./Frontend/library - run: npm ci && npm link ../../Common - - - name: Run frontend lib tests - working-directory: ./Frontend/library - run: npm run test - diff --git a/.github/workflows/run-presubmit-checks.yml b/.github/workflows/run-presubmit-checks.yml deleted file mode 100644 index d524d23b..00000000 --- a/.github/workflows/run-presubmit-checks.yml +++ /dev/null @@ -1,86 +0,0 @@ -name: Run presubmit build and lint checks - -on: - workflow_dispatch: - push: - paths: - - 'Common/**' - - 'Signalling/**' - - 'SignallingWebServer/**' - - 'Frontend/library/**' - - 'Frontend/ui-library/**' - - 'Frontend/implementations/typescript/**' - pull_request: - paths: - - 'Common/**' - - 'Signalling/**' - - 'SignallingWebServer/**' - - 'Frontend/library/**' - - 'Frontend/ui-library/**' - - 'Frontend/implementations/typescript/**' - -env: - NODE_VERSION: 18.17.x - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: "Checkout source code" - uses: actions/checkout@v3 - - uses: actions/setup-node@v4 - with: - node-version: "${{ env.NODE_VERSION }}" - registry-url: 'https://registry.npmjs.org' - - - working-directory: Common - run: npm ci && npm run build && npm run lint - - working-directory: Signalling - run: npm ci && npm link ../Common && npm run build && npm run lint - - working-directory: SignallingWebServer - run: npm ci && npm link ../Signalling && npm run build && npm run lint - - working-directory: Frontend/library - run: npm ci && npm link ../../Common && npm run build && npm run lint - - working-directory: Frontend/ui-library - run: npm ci && npm link ../library && npm run build && npm run lint - - run-linux: - runs-on: ubuntu-latest - steps: - - name: "Checkout source code" - uses: actions/checkout@v3 - - name: "Launch and query signalling server using the REST API" - working-directory: SignallingWebServer - run: | - ./platform_scripts/bash/start.sh --rest_api & - curl --retry 10 --retry-delay 20 --retry-connrefused http://localhost/api/status - - run-windows: - runs-on: windows-latest - steps: - - name: "Checkout source code" - uses: actions/checkout@v3 - - name: "Launch and query signalling server using the REST API" - working-directory: SignallingWebServer - run: | - Start-Process -NoNewWindow .\platform_scripts\cmd\start.bat --rest_api - curl --retry 10 --retry-delay 20 --retry-connrefused http://localhost/api/status - - build-docker-images: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Build the Signalling Server container image - uses: docker/build-push-action@v3 - with: - context: . - push: false - file: SignallingWebServer/Dockerfile - - name: Build the SFU container image - uses: docker/build-push-action@v3 - with: - context: . - push: false - file: SFU/Dockerfile - diff --git a/.github/workflows/run-signalling-tests.yml b/.github/workflows/run-signalling-tests.yml deleted file mode 100644 index 5b869541..00000000 --- a/.github/workflows/run-signalling-tests.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Run signalling tests - -on: - workflow_dispatch: - push: - paths: ['Common/**', 'SignallingWebServer/**', 'SS_Test/**'] - pull_request: - paths: ['Common/**', 'SignallingWebServer/**', 'SS_Test/**'] - -jobs: - - build: - runs-on: ubuntu-latest - defaults: - run: - working-directory: ./ - - permissions: - contents: write - - steps: - - name: "Checkout source code" - uses: actions/checkout@v3 - - - name: "Docker compose" - uses: isbang/compose-action@v1.5.1 - with: - compose-file: "SS_Test/docker-compose.yml" - up-flags: "--build --abort-on-container-exit --exit-code-from tester" diff --git a/Common/.dockerignore b/Common/.dockerignore new file mode 100644 index 00000000..8ff7aa83 --- /dev/null +++ b/Common/.dockerignore @@ -0,0 +1,3 @@ +build/ +node_modules/ + diff --git a/README.md b/README.md index c09d43b9..5d26ff12 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -[![Run library unit tests](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/run-library-unit-tests.yml/badge.svg?branch=master)](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/run-library-unit-tests.yml) +[![Check health of library code](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/healthcheck-libraries.yml/badge.svg?branch=master)](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/healthcheck-libraries.yml) | Action | UE5.5 | UE5.4 | UE5.3 | | -------|--|--|--| | Common Lib | [![Publish common lib](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/publish-common-library-to-npm.yml/badge.svg?branch=UE5.5)](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/publish-common-library-to-npm.yml) | [![Publish common lib](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/publish-common-library-to-npm.yml/badge.svg?branch=UE5.4)](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/publish-common-library-to-npm.yml) | [![Publish common lib](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/publish-common-library-to-npm.yml/badge.svg?branch=UE5.3)](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/publish-common-library-to-npm.yml) | | Signalling Lib | [![Publish signalling lib](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/publish-signalling-library-to-npm.yml/badge.svg?branch=UE5.5)](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/publish-signalling-library-to-npm.yml) | | | -| SignallingWebServer Container | [![Publish signalling web server image](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/publish-signallingwebserver-image.yml/badge.svg?branch=UE5.5)](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/publish-signallingwebserver-image.yml) | [![Publish container images](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/container-images.yml/badge.svg?branch=UE5.4)](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/container-images.yml) | [![Publish container images](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/container-images.yml/badge.svg?branch=UE5.3)](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/container-images.yml) | -| SFU Container | [![Publish SFU image](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/publish-sfu-image.yml/badge.svg?branch=UE5.5)](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/publish-sfu-image.yml) | [![Publish container images](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/container-images.yml/badge.svg?branch=UE5.4)](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/container-images.yml) | [![Publish container images](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/container-images.yml/badge.svg?branch=UE5.3)](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/container-images.yml) | +| SignallingWebServer Container | [![Publish signalling web server image](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/publish-signallingwebserver-image.yml/badge.svg?branch=UE5.5)](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/publish-signallingwebserver-image.yml) | | | +| SFU Container | [![Publish SFU image](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/publish-sfu-image.yml/badge.svg?branch=UE5.5)](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/publish-sfu-image.yml) | | | | Frontend lib | [![Publish frontend lib](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/publish-library-to-npm.yml/badge.svg?branch=UE5.5)](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/publish-library-to-npm.yml) | [![Publish frontend lib](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/publish-library-to-npm.yml/badge.svg?branch=UE5.4)](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/publish-library-to-npm.yml) | [![Publish frontend lib](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/publish-library-to-npm.yml/badge.svg?branch=UE5.3)](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/publish-library-to-npm.yml) | | Frontend ui-lib | [![Publish ui-lib](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/publish-ui-library-to-npm.yml/badge.svg?branch=UE5.5)](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/publish-ui-library-to-npm.yml) | [![Publish ui-lib](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/publish-ui-library-to-npm.yml/badge.svg?branch=UE5.4)](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/publish-ui-library-to-npm.yml) | [![Publish ui-lib](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/publish-ui-library-to-npm.yml/badge.svg?branch=UE5.3)](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/publish-ui-library-to-npm.yml) | | Release | [![Releases](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/create-gh-release.yml/badge.svg?branch=UE5.5)](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/create-gh-release.yml) | [![Releases](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/create-gh-release.yml/badge.svg?branch=UE5.4)](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/create-gh-release.yml) | [![Releases](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/create-gh-release.yml/badge.svg?branch=UE5.3)](https://github.com/EpicGamesExt/PixelStreamingInfrastructure/actions/workflows/create-gh-release.yml) | diff --git a/Signalling/.dockerignore b/Signalling/.dockerignore new file mode 100644 index 00000000..3e2e84b0 --- /dev/null +++ b/Signalling/.dockerignore @@ -0,0 +1,2 @@ +build/ +node_modules/ diff --git a/SignallingWebServer/.dockerignore b/SignallingWebServer/.dockerignore new file mode 100644 index 00000000..8ff7aa83 --- /dev/null +++ b/SignallingWebServer/.dockerignore @@ -0,0 +1,3 @@ +build/ +node_modules/ + diff --git a/SignallingWebServer/Dockerfile b/SignallingWebServer/Dockerfile index c82a3f77..67cd602f 100644 --- a/SignallingWebServer/Dockerfile +++ b/SignallingWebServer/Dockerfile @@ -6,6 +6,7 @@ COPY /Signalling /Signalling COPY /SignallingWebServer /SignallingWebServer COPY /Frontend /Frontend # Install the dependencies for the signalling server and build the frontend +RUN apt-get update RUN SignallingWebServer/platform_scripts/bash/setup.sh --build # Expose TCP ports 80 and 443 for player WebSocket connections and web server HTTP(S) access diff --git a/SignallingWebServer/platform_scripts/bash/common.sh b/SignallingWebServer/platform_scripts/bash/common.sh index afb9d482..0d93897c 100644 --- a/SignallingWebServer/platform_scripts/bash/common.sh +++ b/SignallingWebServer/platform_scripts/bash/common.sh @@ -24,6 +24,7 @@ function print_usage() { Default value as above --build Force a rebuild of the typescript frontend even if it already exists --frontend-dir Sets the output path for the fontend build + --dev Dev mode. (forces build of wilbur and its dependencies) Other options: stored and passed to the server. All parameters printed once the script values are set. Command line options might be omitted to run with defaults and it is a good practice to omit specific ones when just starting the TURN or the STUN server alone, not the whole set of scripts. @@ -38,6 +39,10 @@ function parse_args() { FORCE_BUILD=0 DEFAULT_STUN=0 DEFAULT_TURN=0 + BUILD_WILBUR=0 + if [[ ! -d "${SCRIPT_DIR}/../../build/" ]]; then + BUILD_WILBUR=1 + fi while(($#)) ; do case "$1" in --debug ) IS_DEBUG=1; shift;; @@ -53,6 +58,7 @@ function parse_args() { --start-turn ) START_TURN=1; shift;; --publicip ) PUBLIC_IP="$2"; shift 2;; --frontend-dir ) FRONTEND_DIR="$(realpath "$2")"; shift 2;; + --dev ) BUILD_WILBUR=1; shift;; --help ) print_usage;; * ) SERVER_ARGS+=" $1"; shift;; esac @@ -117,7 +123,7 @@ function check_and_install() { #dep_name #get_version_string #version_min #insta check_version "$current" "$minimum" if [ "$?" -lt 2 ]; then echo "$1 is installed." - return 0 + is_installed=1 else echo "Required install of $1 not found installing" fi @@ -129,7 +135,7 @@ function check_and_install() { #dep_name #get_version_string #version_min #insta start_process $4 if [ $? -ge 1 ]; then - echo "Installation of $1 failed try running `export VERBOSE=1` then run this script again for more details" + echo "Installation of $1 failed try running 'export VERBOSE=1' then run this script again for more details" fi fi } @@ -341,19 +347,37 @@ function start_process() { # Assumes the following are set # SCRIPT_DIR = The path to the root of the PixelStreamingInfrastructure repo. # NPM = The npm command path -# SERVER_ARGS The arguments to be passed to the server -function start_wilbur() { +function build_wilbur() { pushd ${SCRIPT_DIR}/../../.. > /dev/null + pushd Common > /dev/null + if [[ ! -d "build" ]]; then + echo Building common + ${NPM} run build + fi + popd + pushd Signalling > /dev/null + echo Building signalling ${NPM} link ../Common ${NPM} run build popd > /dev/null pushd SignallingWebServer > /dev/null + echo Building wilbur ${NPM} link ../Signalling ${NPM} run build + popd > /dev/null +} + +# Assumes the following are set +# SCRIPT_DIR = The path to the root of the PixelStreamingInfrastructure repo. +# NPM = The npm command path +# SERVER_ARGS The arguments to be passed to the server +function start_wilbur() { + pushd ${SCRIPT_DIR}/../../../SignallingWebServer > /dev/null + echo "Starting wilbur signalling server use ctrl-c to exit" echo "----------------------------------" @@ -361,4 +385,3 @@ function start_wilbur() { popd > /dev/null } - diff --git a/SignallingWebServer/platform_scripts/bash/start.sh b/SignallingWebServer/platform_scripts/bash/start.sh index 76a09d24..419b7342 100755 --- a/SignallingWebServer/platform_scripts/bash/start.sh +++ b/SignallingWebServer/platform_scripts/bash/start.sh @@ -11,17 +11,21 @@ setup_turn_stun "bg" SERVER_ARGS+=" --serve --https_redirect --console_messages verbose --public_ip=${PUBLIC_IP}" if [[ ! -z "$STUN_SERVER" && ! -z "$TURN_SERVER" ]]; then - PEER_OPTIONS='{\"iceServers\":[{\"urls\":[\"stun:'${STUN_SERVER}'\",\"turn:'${TURN_SERVER}'\"],\"username\":\"'${TURN_USER}'\",\"credential\":\"'${TURN_PASS}'\"}]}' + PEER_OPTIONS="{\"iceServers\":[{\"urls\":[\"stun:${STUN_SERVER}\",\"turn:${TURN_SERVER}\"],\"username\":\"${TURN_USER}\",\"credential\":\"${TURN_PASS}\"}]}" elif [[ ! -z "$STUN_SERVER" ]]; then - PEER_OPTIONS='{\"iceServers\":[{\"urls\":[\"stun:'${STUN_SERVER}'\"]}]}' + PEER_OPTIONS="{\"iceServers\":[{\"urls\":[\"stun:${STUN_SERVER}\"]}]}" elif [[ ! -z "$TURN_SERVER" ]]; then - PEER_OPTIONS='{\"iceServers\":[{\"urls\":[\"turn:'${TURN_SERVER}'\"],\"username\":\"'${TURN_USER}'\",\"credentials\":\"'${TURN_PASS}'\"}]}' + PEER_OPTIONS="{\"iceServers\":[{\"urls\":[\"turn:${TURN_SERVER}\"],\"username\":\"${TURN_USER}\",\"credentials\":\"${TURN_PASS}\"}]}" fi if [[ ! -z "$PEER_OPTIONS" ]]; then - SERVER_ARGS+=" --peer_options=\"${PEER_OPTIONS}\"" + SERVER_ARGS+=" --peer_options='${PEER_OPTIONS}'" fi if [[ ! -z "$FRONTEND_DIR" ]]; then - SERVER_ARGS+=" --http_root=\"$FRONTEND_DIR\"" + SERVER_ARGS+=" --http_root='$FRONTEND_DIR'" +fi + +if [[ "$BUILD_WILBUR" == "1" ]]; then + build_wilbur fi print_config diff --git a/SignallingWebServer/platform_scripts/cmd/common.bat b/SignallingWebServer/platform_scripts/cmd/common.bat index ff0519f9..23f85a2a 100644 --- a/SignallingWebServer/platform_scripts/cmd/common.bat +++ b/SignallingWebServer/platform_scripts/cmd/common.bat @@ -28,11 +28,13 @@ echo --stun ^ STUN server to be used echo --default-stun Uses IP address downloaded from https://api.ipify.org and sets up default stun parameters echo --build Force a rebuild of the typescript frontend even if it already exists echo --frontend-dir ^ Sets the output path for the fontend build +echo --dev Dev mode (forces build of wilbur and its dependencies) echo Other options: stored and passed to the server. set CONTINUE=0 exit /b :ParseArgs +set BUILD_WILBUR=0 set FORCE_BUILD=0 set DEFAULT_STUN=0 set DEFAULT_TURN=0 @@ -44,6 +46,9 @@ set TURN_USER= set TURN_PASS= set STUN_SERVER= set PUBLIC_IP= +if not exist "%SCRIPT_DIR%\..\..\build\" ( + set BUILD_WILBUR=1 +) :arg_loop IF NOT "%1"=="" ( set HANDLED=0 @@ -95,6 +100,9 @@ IF NOT "%1"=="" ( set FRONTEND_DIR=%~2 SHIFT ) + IF "%1"=="--dev" ( + set BUILD_WILBUR=1 + ) IF NOT "!HANDLED!"=="1" ( set SERVER_ARGS=%SERVER_ARGS% %1 ) @@ -120,7 +128,8 @@ if exist node\ ( ) rem Print node version -echo Node version: & node\node.exe -v +FOR /f %%A IN ('node\node.exe -v') DO set NODE_VERSION=%%A +echo Node version: %NODE_VERSION% popd exit /b @@ -165,7 +174,7 @@ IF !PATH_LENGTH! GTR 1024 ( echo "Your PATH is greater than 1024 characters, cmd setx cannot change it. Either shorten your user's PATH contents or hope you have NodeJS in your PATH already..." ) else ( rem Set new user PATH for all processes - setx PATH "%NODE_DIR%;%OLD_PATH%" + setx PATH "%NODE_DIR%;%OLD_PATH%" >NUL set PATH_NEEDS_RESTORE=1 ) @@ -204,7 +213,7 @@ IF "%FORCE_BUILD%"=="1" ( IF "%PATH_NEEDS_RESTORE%"=="1" ( rem Restore PATH - setx PATH "%OLD_PATH%" + setx PATH "%OLD_PATH%" >NUL ) exit /b @@ -237,7 +246,7 @@ call :SetupCoturn exit /b :SetPublicIP -FOR /f %%A IN ('curl http://api.ipify.org') DO set PUBLIC_IP=%%A +FOR /f %%A IN ('curl --silent http://api.ipify.org') DO set PUBLIC_IP=%%A Echo External IP is : %PUBLIC_IP% exit /b @@ -254,7 +263,7 @@ IF "%DEFAULT_STUN%"=="1" ( rem Ping own computer name to get local IP FOR /F "delims=[] tokens=2" %%A in ('ping -4 -n 1 %ComputerName% ^| findstr [') do set LOCAL_IP=%%A FOR /F "tokens=1,2 delims=:" %%i in ("%TURN_SERVER%") do ( - set TURN_PORT=%j + set TURN_PORT=%%j ) IF "%TURN_PORT%"=="" ( set TURN_PORT=3478 ) @@ -289,8 +298,15 @@ echo Server command line arguments: %SERVER_ARGS% echo. exit /b -:StartWilbur +:BuildWilbur pushd %SCRIPT_DIR%\..\..\ +pushd ..\Common +IF NOT EXIST build\ ( + echo Building common library... + echo ------------------------ + call "%SCRIPT_DIR%node\npm" run build +) +popd echo Building signalling library... echo ---------------------------- pushd ..\Signalling @@ -301,6 +317,11 @@ echo Building wilbur... echo ---------------------------- call "%SCRIPT_DIR%node\npm" link ../Signalling call "%SCRIPT_DIR%node\npm" run build +popd +exit /b + +:StartWilbur +pushd %SCRIPT_DIR%\..\..\ call %NPM% run start -- %SERVER_ARGS% exit /b diff --git a/SignallingWebServer/platform_scripts/cmd/start.bat b/SignallingWebServer/platform_scripts/cmd/start.bat index 899737ee..90fd4f51 100644 --- a/SignallingWebServer/platform_scripts/cmd/start.bat +++ b/SignallingWebServer/platform_scripts/cmd/start.bat @@ -31,19 +31,25 @@ IF "%CONTINUE%"=="1" ( set SERVER_ARGS=!SERVER_ARGS! --http_root="!FRONTEND_DIR!" ) - call :PrintConfig + if "%BUILD_WILBUR%"=="1" ( + call :BuildWilbur + ) + + call :PrintConfig call :StartWilbur pause ) goto :eof +REM These labels will all jump to common.bat but also jump to the label inside common.bat :Init :ParseArgs :Setup :SetPublicIP :SetupTurnStun :PrintConfig +:BuildWilbur :StartWilbur "%~dp0common.bat" %*