Merge branch 'main' into patch-4
This commit is contained in:
@@ -9,14 +9,21 @@ worker_processes auto;
|
||||
worker_cpu_affinity auto;
|
||||
pid /run/nginx.pid;
|
||||
|
||||
# link configuration
|
||||
env CIPHERSERVER_PORT_8001_TCP_ADDR;
|
||||
env CIPHERSERVER_PORT_8001_TCP_PORT;
|
||||
|
||||
# user configuration
|
||||
env TUBESYNC_CIPHER_HTTPS;
|
||||
env TUBESYNC_CIPHER_IPADDR;
|
||||
env TUBESYNC_CIPHER_PORT;
|
||||
|
||||
env YT_POT_BGUTIL_BASE_URL;
|
||||
# link configuration
|
||||
env POTSERVER_PORT_4416_TCP_ADDR;
|
||||
env POTSERVER_PORT_4416_TCP_PORT;
|
||||
# user configuration
|
||||
env TUBESYNC_POT_HTTPS;
|
||||
env TUBESYNC_POT_IPADDR;
|
||||
env TUBESYNC_POT_PORT;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
|
||||
@@ -1,5 +1,68 @@
|
||||
lua_shared_dict token_server 1m;
|
||||
upstream token_server {
|
||||
server 127.0.0.2:4416 down;
|
||||
server 127.0.0.1:4406 max_fails=0;
|
||||
|
||||
balancer_by_lua_block {
|
||||
local balancer = require "ngx.balancer"
|
||||
local upstream = ngx.shared.token_server
|
||||
local exit_error = ngx.HTTP_INTERNAL_SERVER_ERROR
|
||||
|
||||
local ok, err, empty_port, host, port
|
||||
local default_host, default_port, tries = '127.0.0.1', '4406', 1
|
||||
|
||||
local user_host = os.getenv('TUBESYNC_POT_IPADDR')
|
||||
local link_host = os.getenv('POTSERVER_PORT_4416_TCP_ADDR')
|
||||
local use_https = os.getenv('TUBESYNC_POT_HTTPS')
|
||||
if user_host and use_https then
|
||||
use_https = true
|
||||
empty_port = '443'
|
||||
else
|
||||
use_https = false
|
||||
empty_port = '80'
|
||||
end
|
||||
|
||||
ok, err = balancer.get_last_failure()
|
||||
if ok then
|
||||
host, port, tries = default_host, default_port, 0
|
||||
elseif link_host then
|
||||
host = link_host
|
||||
local link_port = os.getenv('POTSERVER_PORT_4416_TCP_PORT')
|
||||
if link_port then
|
||||
port = link_port
|
||||
else
|
||||
port = empty_port
|
||||
end
|
||||
elseif user_host then
|
||||
host = user_host
|
||||
local user_port = os.getenv('TUBESYNC_POT_PORT')
|
||||
if user_port then
|
||||
port = user_port
|
||||
else
|
||||
port = empty_port
|
||||
end
|
||||
ok, err = balancer.set_upstream_tls(use_https)
|
||||
if not ok then
|
||||
ngx.log(ngx.ERR, "failed to set upstream TLS: ", err)
|
||||
end
|
||||
end
|
||||
if not host then
|
||||
host, port, tries = default_host, default_port, 0
|
||||
end
|
||||
|
||||
ok, err = balancer.set_more_tries(tries)
|
||||
if not ok then
|
||||
ngx.log(ngx.err, ("failed to set tries to %d: "):format(tries), err)
|
||||
end
|
||||
|
||||
ok, err = balancer.set_current_peer(host, port)
|
||||
if ok then
|
||||
upstream:set('addr', host)
|
||||
upstream:set('port', port)
|
||||
else
|
||||
ngx.log(ngx.err, "failed to set the current peer: ", err)
|
||||
return ngx.exit(exit_error)
|
||||
end
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
@@ -11,19 +74,7 @@ server {
|
||||
# Server domain name
|
||||
server_name _;
|
||||
|
||||
set_by_lua_block $pot_url {
|
||||
local default = 'http://token_server'
|
||||
local url = os.getenv('YT_POT_BGUTIL_BASE_URL')
|
||||
if not url then
|
||||
return default
|
||||
end
|
||||
if #url and url:find('://') then
|
||||
return url
|
||||
end
|
||||
return default
|
||||
}
|
||||
|
||||
location / {
|
||||
proxy_pass $pot_url;
|
||||
proxy_pass http://token_server;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
base
|
||||
tubesync-init
|
||||
32
config/root/etc/s6-overlay/s6-rc.d/bgutil-ytdlp-pot-provider-build/run
Executable file
32
config/root/etc/s6-overlay/s6-rc.d/bgutil-ytdlp-pot-provider-build/run
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/command/with-contenv bash
|
||||
|
||||
set -eu
|
||||
cd /app/bgutil-ytdlp-pot-provider/server
|
||||
chmod -c 00755 ../node
|
||||
|
||||
tmp_app_home="$(realpath -e "$(mktemp --directory --tmpdir=.)")"
|
||||
trap "rm -rf ${tmp_app_home}" EXIT
|
||||
|
||||
command -v deno >/dev/null || \
|
||||
/app/install_deno.sh
|
||||
|
||||
test '!' -d build || \
|
||||
test '!' -f build/main.js || \
|
||||
test '!' -d node_modules || \
|
||||
exit 0 # nothing needs to be built
|
||||
|
||||
command -v node > /dev/null || \
|
||||
install -v -t /usr/local/bin ../node
|
||||
|
||||
chown -R app:app .
|
||||
|
||||
s6-setuidgid app \
|
||||
env HOME="${tmp_app_home}" DENO_COMPAT=1 deno run -A npm:npm ci --no-fund
|
||||
|
||||
s6-setuidgid app \
|
||||
env HOME="${tmp_app_home}" DENO_COMPAT=1 deno run -A npm:npm audit fix
|
||||
|
||||
s6-setuidgid app \
|
||||
env HOME="${tmp_app_home}" ../node npm:typescript/tsc
|
||||
|
||||
chown -R root:app .
|
||||
@@ -0,0 +1 @@
|
||||
oneshot
|
||||
3
config/root/etc/s6-overlay/s6-rc.d/bgutil-ytdlp-pot-provider-build/up
Executable file
3
config/root/etc/s6-overlay/s6-rc.d/bgutil-ytdlp-pot-provider-build/up
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/command/execlineb -P
|
||||
|
||||
/etc/s6-overlay/s6-rc.d/bgutil-ytdlp-pot-provider-build/run
|
||||
@@ -0,0 +1,2 @@
|
||||
base
|
||||
bgutil-ytdlp-pot-provider-build
|
||||
7
config/root/etc/s6-overlay/s6-rc.d/bgutil-ytdlp-pot-provider/run
Executable file
7
config/root/etc/s6-overlay/s6-rc.d/bgutil-ytdlp-pot-provider/run
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/command/with-contenv bash
|
||||
|
||||
set -e
|
||||
cd /app/bgutil-ytdlp-pot-provider
|
||||
|
||||
exec s6-setuidgid app \
|
||||
./node server/build/main.js -p 4406
|
||||
@@ -0,0 +1 @@
|
||||
longrun
|
||||
@@ -1 +1,2 @@
|
||||
tubesync-init
|
||||
base
|
||||
tubesync-init
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
|
||||
0
config/root/etc/s6-overlay/s6-rc.d/huey-database/run
Normal file → Executable file
0
config/root/etc/s6-overlay/s6-rc.d/huey-database/run
Normal file → Executable file
0
config/root/etc/s6-overlay/s6-rc.d/huey-filesystem/run
Normal file → Executable file
0
config/root/etc/s6-overlay/s6-rc.d/huey-filesystem/run
Normal file → Executable file
0
config/root/etc/s6-overlay/s6-rc.d/huey-net-limited/run
Normal file → Executable file
0
config/root/etc/s6-overlay/s6-rc.d/huey-net-limited/run
Normal file → Executable file
0
config/root/etc/s6-overlay/s6-rc.d/huey-network/run
Normal file → Executable file
0
config/root/etc/s6-overlay/s6-rc.d/huey-network/run
Normal file → Executable file
@@ -1 +1,2 @@
|
||||
gunicorn
|
||||
base
|
||||
gunicorn
|
||||
|
||||
@@ -2,15 +2,4 @@
|
||||
|
||||
cd /
|
||||
|
||||
https="${TUBESYNC_POT_HTTPS:+https}"
|
||||
ip_address="${TUBESYNC_POT_IPADDR:-${POTSERVER_PORT_4416_TCP_ADDR}}"
|
||||
: "${TUBESYNC_POT_PORT:=${POTSERVER_PORT_4416_TCP_PORT}}"
|
||||
port="${TUBESYNC_POT_PORT:+:}${TUBESYNC_POT_PORT}"
|
||||
|
||||
if [ -n "${ip_address}" ]
|
||||
then
|
||||
YT_POT_BGUTIL_BASE_URL="${https:-http}://${ip_address}${port}"
|
||||
export YT_POT_BGUTIL_BASE_URL
|
||||
fi
|
||||
|
||||
exec /usr/bin/openresty -c /etc/nginx/nginx.conf -e stderr
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
base
|
||||
Reference in New Issue
Block a user