From dc320cd53975a11442312c1742e4944d5ed522c3 Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 9 May 2022 15:46:53 +0800 Subject: [PATCH] Migrate to lighthouse. --- .github/workflows/release.yml | 35 ++++++++++++++++++++++++++++++++++- main.go | 4 ++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index adae532..e7c0d12 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: "Release" +name: "Release SRS demo signaling" on: push: @@ -16,6 +16,13 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 + # Generate variables like: + # SRS_DROPLET_EIP=1.2.3.4 + - name: Build droplet variables + run: | + SRS_DROPLET_EIP=$(dig +short lh.ossrs.net) + echo "SRS_DROPLET_EIP=$SRS_DROPLET_EIP" >> $GITHUB_ENV + ################################################################ # Build # The github.ref is, for example, refs/tags/v1.0.52 @@ -49,3 +56,29 @@ jobs: docker tag ossrs/signaling:$SRS_TAG registry.cn-hangzhou.aliyuncs.com/ossrs/signaling:$SRS_MAJOR docker push --all-tags registry.cn-hangzhou.aliyuncs.com/ossrs/signaling + ################################################################ + # Execute command in a ssh, because ufw limit the rate. + - name: Restart the containers + env: + SEARCH_APIKEY: ${{ secrets.SEARCH_APIKEY }} + uses: appleboy/ssh-action@master + with: + host: ${{ env.SRS_DROPLET_EIP }} + username: root + key: ${{ secrets.DIGITALOCEAN_SSHKEY }} + port: 22 + envs: SRS_TAG,SRS_MAJOR + timeout: 60s + command_timeout: 30m + script: | + # + #ufw allow 1989 # For SRS demo signaling service. + # + # Restart SRS signaling service + for ((i=0; i < 5; i++)); do + if [[ $(docker ps -af name=docs-signaling |wc -l) -eq 1 ]]; then echo "Killed"; break; fi; + docker rm -f docs-signaling; sleep 0.3; + done + docker run -d -it --restart always --name docs-signaling -p 1989:1989 \ + registry.cn-hangzhou.aliyuncs.com/ossrs/signaling:$SRS_TAG + diff --git a/main.go b/main.go index e91ec43..5535447 100644 --- a/main.go +++ b/main.go @@ -177,6 +177,10 @@ func main() { http.Handle("/", http.FileServer(http.Dir(html))) + http.Handle("/sig/v1/versions", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.Write([]byte("1.0")) + })) + // Key is name of room, value is Room var rooms sync.Map http.Handle("/sig/v1/rtc", websocket.Handler(func(c *websocket.Conn) {