From 02e12c31fe488ae4a1f2ae3a395a59577b0b8e6d Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Fri, 9 Apr 2021 15:56:55 +0200 Subject: glt-stream: one collector per room --- spreadspace/glt-stream.yml | 48 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 5 deletions(-) (limited to 'spreadspace/glt-stream.yml') diff --git a/spreadspace/glt-stream.yml b/spreadspace/glt-stream.yml index 48541d85..8f380565 100644 --- a/spreadspace/glt-stream.yml +++ b/spreadspace/glt-stream.yml @@ -37,6 +37,15 @@ add_header Access-Control-Allow-Methods "GET,HEAD,OPTIONS"; add_header Access-Control-Allow-Origin "*"; add_header Access-Control-Expose-Headers "Server,range,Content-Length,Content-Range,Date"; + + {% for room_id in [1,2,3] %} + location /stats/saal{{ room_id }}/ { + include snippets/proxy-nobuff.conf; + proxy_set_header Host $host; + include snippets/proxy-forward-headers.conf; + proxy_pass http://127.0.0.1:{{ 4200 + room_id }}/; + } + {% endfor %} locations: '/': root: /srv/www/stream @@ -78,16 +87,41 @@ src: "{{ global_files_dir }}/glt/stream-stats.go" dest: /srv/www/stats/stream-stats.go + - name: install start script for collector + copy: + content: | + #!/bin/bash + ROOM=$1 + case "$ROOM" in + saal1) + PORT=4201 + ;; + saal2) + PORT=4202 + ;; + saal3) + PORT=4203 + ;; + *) + echo "unknown room" + exit 1 + ;; + esac + exec /usr/bin/go run /srv/www/stats/stream-stats.go 127.0.0.1:$PORT /srv/www/stats/data/glt21-$ROOM.json + dest: /srv/www/stats/run.sh + mode: 0755 + - name: install systemd unit for stats collector copy: content: | [Unit] - Description=GLT21 Stream Stats Collector + Description=GLT21 Stream Stats Collector (%I) [Service] Type=simple + User=stats Environment="GOCACHE=/srv/www/stats/.gocache" - ExecStart=/usr/bin/go run /srv/www/stats/stream-stats.go 127.0.0.1:4200 /srv/www/stats/data/glt21.json + ExecStart=/srv/www/stats/run.sh %i NoNewPrivileges=yes PrivateTmp=yes PrivateDevices=yes @@ -101,11 +135,15 @@ [Install] WantedBy=multi-user.target - dest: /etc/systemd/system/stream-stats.service + dest: /etc/systemd/system/stream-stats@.service - - name: make sure stats collector service unit is enabled and started + - name: make sure stats collector service units are enabled and started + loop: + - saal1 + - saal2 + - saal3 systemd: - name: stream-stats.service + name: "stream-stats@{{ item }}.service" daemon_reload: yes enabled: yes state: started -- cgit v1.2.3