fix REDIS_URL unix socket path parsing for relative paths
ci/woodpecker/push/woodpecker Pipeline was successful Details
ci/woodpecker/pr/woodpecker Pipeline was successful Details

roof/22-11-24-misc
kouhai dev 2022-11-25 21:31:39 -06:00
parent bd0da3a499
commit d2d168cd57
4 changed files with 22 additions and 4 deletions

View File

@ -1,6 +1,7 @@
LOCAL_DOMAIN=localhost
ALTERNATE_DOMAINS=mastodon.internal
DB_HOST=$(pwd)/data/postgres
DB_USER=mastodon
DB_NAME=mastodon_dev
REDIS_URL=redis://$(pwd)/data/redis/redis-dev.sock
REDIS_URL=unix://./data/redis/redis-dev.sock

View File

@ -7,4 +7,4 @@ LOCAL_HTTPS=true
DB_HOST=$(pwd)/data/postgres
DB_USER=mastodon
DB_NAME=mastodon_dev
REDIS_URL=redis://$(pwd)/data/redis/redis-test.sock
REDIS_URL=unix://./data/redis/redis-dev.sock

View File

@ -1,10 +1,27 @@
# frozen_string_literal: true
require 'pathname'
def setup_redis_env_url(prefix = nil, defaults = true)
prefix = prefix.to_s.upcase + '_' unless prefix.nil?
prefix = '' if prefix.nil?
return if ENV[prefix + 'REDIS_URL'].present?
if ENV["#{prefix}REDIS_URL"].present?
conn = +ENV["#{prefix}REDIS_URL"].sub(/redis:\/\//i, '')
unix = !!conn.sub!(/^unix:\/\//i, '')
unix |= conn.sub!(/^(\.\/)+/, '')
unix |= conn.start_with?('/')
ENV["#{prefix}REDIS_URL"] = begin
pn = Pathname.new(conn)
pn = Pathname.getwd / pn if pn.relative?
"unix://#{pn}"
end if unix
return
end
password = ENV.fetch(prefix + 'REDIS_PASSWORD') { '' if defaults }
host = ENV.fetch(prefix + 'REDIS_HOST') { 'localhost' if defaults }

View File

@ -18,7 +18,7 @@ const env = process.env.NODE_ENV || 'development';
const alwaysRequireAuth = process.env.LIMITED_FEDERATION_MODE === 'true' || process.env.WHITELIST_MODE === 'true' || process.env.AUTHORIZED_FETCH === 'true';
dotenv.config({
path: env === 'production' ? '.env.production' : '.env',
path: env === 'production' || env === 'development' ? `.env.${env}` : '.env',
});
log.level = process.env.LOG_LEVEL || 'verbose';