mirror of
https://git.nadeko.net/Fijxu/invidious.git
synced 2025-06-28 18:08:24 +00:00
feat: show status of the instance with a colored dot
Some checks failed
Build and release container directly from master / release (push) Has been cancelled
Invidious CI / build - crystal: ${{ matrix.crystal }}, stable: ${{ matrix.stable }} (1.12.1, true) (push) Has been cancelled
Invidious CI / build - crystal: ${{ matrix.crystal }}, stable: ${{ matrix.stable }} (1.13.2, true) (push) Has been cancelled
Invidious CI / build - crystal: ${{ matrix.crystal }}, stable: ${{ matrix.stable }} (1.14.0, true) (push) Has been cancelled
Invidious CI / build - crystal: ${{ matrix.crystal }}, stable: ${{ matrix.stable }} (1.15.0, true) (push) Has been cancelled
Invidious CI / build - crystal: ${{ matrix.crystal }}, stable: ${{ matrix.stable }} (nightly, false) (push) Has been cancelled
Invidious CI / build-docker (push) Has been cancelled
Invidious CI / build-docker-arm64 (push) Has been cancelled
Invidious CI / lint (push) Has been cancelled
Some checks failed
Build and release container directly from master / release (push) Has been cancelled
Invidious CI / build - crystal: ${{ matrix.crystal }}, stable: ${{ matrix.stable }} (1.12.1, true) (push) Has been cancelled
Invidious CI / build - crystal: ${{ matrix.crystal }}, stable: ${{ matrix.stable }} (1.13.2, true) (push) Has been cancelled
Invidious CI / build - crystal: ${{ matrix.crystal }}, stable: ${{ matrix.stable }} (1.14.0, true) (push) Has been cancelled
Invidious CI / build - crystal: ${{ matrix.crystal }}, stable: ${{ matrix.stable }} (1.15.0, true) (push) Has been cancelled
Invidious CI / build - crystal: ${{ matrix.crystal }}, stable: ${{ matrix.stable }} (nightly, false) (push) Has been cancelled
Invidious CI / build-docker (push) Has been cancelled
Invidious CI / build-docker-arm64 (push) Has been cancelled
Invidious CI / lint (push) Has been cancelled
This commit is contained in:
parent
e5c0f15398
commit
1001a72297
@ -1,16 +1,55 @@
|
|||||||
module BackendInfo
|
module BackendInfo
|
||||||
extend self
|
extend self
|
||||||
@@exvpp_url : String = ""
|
@@exvpp_url : String = ""
|
||||||
|
@@status : Int32 = 0
|
||||||
|
|
||||||
def get_videoplayback_proxy
|
def check_backends
|
||||||
|
check_videoplayback_proxy()
|
||||||
|
check_companion()
|
||||||
|
end
|
||||||
|
|
||||||
|
def check_companion
|
||||||
begin
|
begin
|
||||||
response = HTTP::Client.get "#{CONFIG.invidious_companion.sample.private_url}/info"
|
response = HTTP::Client.get "#{CONFIG.invidious_companion.sample.private_url}/healthz"
|
||||||
exvpp_url = JSON.parse(response.body)["external_videoplayback_proxy"].to_s
|
if response.status_code == 200
|
||||||
|
@@status = 1
|
||||||
|
check_videoplayback_proxy()
|
||||||
|
else
|
||||||
|
@@status = 0
|
||||||
|
end
|
||||||
|
rescue
|
||||||
|
@@status = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def check_videoplayback_proxy
|
||||||
|
begin
|
||||||
|
info = HTTP::Client.get "#{CONFIG.invidious_companion.sample.private_url}/info"
|
||||||
|
exvpp_url = JSON.parse(info.body)["external_videoplayback_proxy"]?.try &.to_s
|
||||||
|
exvpp_url = "" if exvpp_url.nil?
|
||||||
@@exvpp_url = exvpp_url
|
@@exvpp_url = exvpp_url
|
||||||
|
if exvpp_url.empty?
|
||||||
|
@@status = 2
|
||||||
|
return
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
exvpp_health = HTTP::Client.get "#{exvpp_url}/health"
|
||||||
|
if exvpp_health.status_code == 200
|
||||||
|
@@status = 2
|
||||||
|
return
|
||||||
|
end
|
||||||
|
rescue
|
||||||
|
@@status = 1
|
||||||
|
end
|
||||||
|
end
|
||||||
rescue
|
rescue
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_status
|
||||||
|
return @@status
|
||||||
|
end
|
||||||
|
|
||||||
def get_exvpp
|
def get_exvpp
|
||||||
return @@exvpp_url
|
return @@exvpp_url
|
||||||
end
|
end
|
||||||
|
@ -4,9 +4,9 @@ class Invidious::Jobs::CheckBackend < Invidious::Jobs::BaseJob
|
|||||||
|
|
||||||
def begin
|
def begin
|
||||||
loop do
|
loop do
|
||||||
BackendInfo.get_videoplayback_proxy
|
BackendInfo.check_backends
|
||||||
LOGGER.info("Backend Checker: Done, sleeping for 60 seconds")
|
LOGGER.info("Backend Checker: Done, sleeping for 30 seconds")
|
||||||
sleep 60.seconds
|
sleep 30.seconds
|
||||||
Fiber.yield
|
Fiber.yield
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
dark_mode = env.get("preferences").as(Preferences).dark_mode
|
dark_mode = env.get("preferences").as(Preferences).dark_mode
|
||||||
current_backend = env.request.cookies[CONFIG.server_id_cookie_name]?.try &.value || env.request.headers["Host"]
|
current_backend = env.request.cookies[CONFIG.server_id_cookie_name]?.try &.value || env.request.headers["Host"]
|
||||||
current_external_videoplayback_proxy = Invidious::HttpServer::Utils.get_external_proxy()
|
current_external_videoplayback_proxy = Invidious::HttpServer::Utils.get_external_proxy()
|
||||||
|
status = BackendInfo.get_status
|
||||||
%>
|
%>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="<%= locale %>">
|
<html lang="<%= locale %>">
|
||||||
@ -34,7 +35,18 @@
|
|||||||
<div class="pure-g navbar h-box">
|
<div class="pure-g navbar h-box">
|
||||||
<% if navbar_search %>
|
<% if navbar_search %>
|
||||||
<div class="pure-u-1 pure-u-md-4-24">
|
<div class="pure-u-1 pure-u-md-4-24">
|
||||||
<a href="/" class="index-link pure-menu-heading">Invidious</a>
|
<a href="/" class="index-link pure-menu-heading">
|
||||||
|
Invidious
|
||||||
|
<% if status == 0 %>
|
||||||
|
<span style="color: #fd4848;">•</span>
|
||||||
|
<% end %>
|
||||||
|
<% if status == 1 %>
|
||||||
|
<span style="color: #d06925;">•</span>
|
||||||
|
<% end %>
|
||||||
|
<% if status == 2 %>
|
||||||
|
<span style="color: #42ae3c;">•</span>
|
||||||
|
<% end %>
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="pure-u-1 pure-u-md-12-24 searchbar">
|
<div class="pure-u-1 pure-u-md-12-24 searchbar">
|
||||||
<% autofocus = false %><%= rendered "components/search_box" %>
|
<% autofocus = false %><%= rendered "components/search_box" %>
|
||||||
|
Loading…
Reference in New Issue
Block a user