forked from treehouse/mastodon
fix REDIS_URL unix socket path parsing for relative paths
parent
bd0da3a499
commit
d2d168cd57
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 }
|
||||
|
|
|
@ -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';
|
||||
|
|
Loading…
Reference in New Issue