th: maybe fix streaming

main
kouhai dev 2024-02-17 13:38:16 -08:00
parent ccc1e60c78
commit cf306e331a
4 changed files with 17 additions and 19 deletions

View File

@ -1,5 +1,6 @@
LOCAL_DOMAIN=localhost LOCAL_DOMAIN=localhost
ALTERNATE_DOMAINS=mastodon.internal ALTERNATE_DOMAINS=mastodon.internal
STREAMING_API_BASE_URL=https://streaming.mastodon.internal
DB_HOST=$PWD/data/postgres DB_HOST=$PWD/data/postgres
DB_USER=mastodon DB_USER=mastodon

View File

@ -1,4 +1,4 @@
web: env PORT=3000 RAILS_ENV=development bundle exec puma -C config/puma.rb web: env PORT=3000 RAILS_ENV=development bundle exec puma -C config/puma.rb
sidekiq: env PORT=3000 RAILS_ENV=development bundle exec sidekiq sidekiq: env PORT=3000 RAILS_ENV=development bundle exec sidekiq
stream: env PORT=4000 yarn workspace @mastodon/streaming start stream: env PORT=4000 yarn workspace @mastodon/streaming start | npx pino-pretty
webpack: bin/webpack-dev-server webpack: bin/webpack-dev-server

View File

@ -25,21 +25,14 @@ const dotenvFile = environment === 'production' ? '.env.production' : '.env.deve
const dotenvFileLocal = `${dotenvFile}.local` const dotenvFileLocal = `${dotenvFile}.local`
// Replicate dotenv-rails's behavior // Replicate dotenv-rails's behavior
dotenv.config({ const projectDir = path.resolve(__dirname, '..')
path: '.env', const dotenvFiles = ['.env', dotenvFile, '.env.local', dotenvFileLocal]
}); .map(s => path.join(projectDir, s));
dotenv.config({ dotenvFiles.forEach(path => dotenv.config({path}));
path: path.resolve(__dirname, path.join('..', dotenvFile))
}); if (process.env.REDIS_URL && process.env.PWD) {
dotenv.config({ process.env.REDIS_URL = process.env.REDIS_URL.replace(/\$PWD\b|$\{PWD\}/, projectDir);
path: '.env.local', }
});
dotenv.config({
path: environment === 'production' ? '.env.production.local' : '.env.development.local',
});
dotenv.config({
path: path.resolve(__dirname, path.join('..', dotenvFileLocal))
});
initializeLogLevel(process.env, environment); initializeLogLevel(process.env, environment);
@ -81,7 +74,7 @@ const createRedisClient = async (config) => {
client = new Redis(redisUrl, redisParams);; client = new Redis(redisUrl, redisParams);;
} }
// @ts-ignore // @ts-ignore
client.on('error', (err) => log.error('Redis Client Error!', err)); client.on('error', (err) => logger.error(err, 'Redis Client Error!'));
return client; return client;
}; };
@ -205,10 +198,14 @@ const redisConfigFromEnv = (env) => {
redisParams.path = env.REDIS_URL.slice(7); redisParams.path = env.REDIS_URL.slice(7);
} }
const redisUrlParams = env.REDIS_URL ? {
redisUrl: env.REDIS_URL,
} : {};
return { return {
redisParams, redisParams,
redisPrefix, redisPrefix,
redisUrl: env.REDIS_URL, ...redisUrlParams,
}; };
}; };

View File

@ -56,7 +56,7 @@ const logger = pino({
'req.headers.cookie', 'req.headers.cookie',
'req.query.access_token' 'req.query.access_token'
] ]
} },
}); });
const httpLogger = pinoHttp({ const httpLogger = pinoHttp({