fix: refactor Redis configuration to use separate host, port, and password fields
This commit is contained in:
@@ -8,7 +8,9 @@ const config = {
|
||||
jwtRefreshExpiry: '7d',
|
||||
|
||||
// Redis
|
||||
redisUrl: process.env.REDIS_URL || 'redis://localhost:6379/2',
|
||||
redisHost: process.env.REDIS_HOST || 'localhost',
|
||||
redisPort: process.env.REDIS_PORT || '6379',
|
||||
redisPassword: process.env.REDIS_PASSWORD || undefined,
|
||||
|
||||
// Gitea
|
||||
giteaUrl: process.env.GITEA_URL || 'http://gitea:3000',
|
||||
|
||||
@@ -42,15 +42,19 @@ function notifyDeployListeners(deployId, message, stream) {
|
||||
* Initialize the build queue and worker
|
||||
*/
|
||||
export async function initQueue() {
|
||||
// Parse Redis URL
|
||||
const redisUrl = new URL(config.redisUrl);
|
||||
console.log(`[QUEUE] Redis parsed - host: ${redisUrl.hostname}, port: ${redisUrl.port}, password: ${redisUrl.password ? '***' : '(none)'}, db: ${redisUrl.pathname}`);
|
||||
|
||||
console.log(`[QUEUE] Redis: ${config.redisHost}:${config.redisPort} (DB 2)`);
|
||||
|
||||
if (!config.redisPassword) {
|
||||
console.error(`NO REDIS PASSWORD!`);
|
||||
}
|
||||
|
||||
connection = new IORedis({
|
||||
host: redisUrl.hostname,
|
||||
port: parseInt(redisUrl.port || '6379'),
|
||||
db: parseInt(redisUrl.pathname?.replace('/', '') || '2'),
|
||||
password: redisUrl.password || redisUrl.username || undefined,
|
||||
maxRetriesPerRequest: null, // Required by BullMQ
|
||||
host: config.redisHost,
|
||||
port: parseInt(config.redisPort || '6379'),
|
||||
db: parseInt('2'),
|
||||
password: config.redisPassword || undefined,
|
||||
maxRetriesPerRequest: null,
|
||||
enableReadyCheck: false,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user