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
ALTERNATE_DOMAINS=mastodon.internal
STREAMING_API_BASE_URL=https://streaming.mastodon.internal
DB_HOST=$PWD/data/postgres
DB_USER=mastodon

View File

@ -1,4 +1,4 @@
web: env PORT=3000 RAILS_ENV=development bundle exec puma -C config/puma.rb
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

View File

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

View File

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