Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {getEcosystemsRouter} from './features/getEcosystems/getEcosystemsRouter'
import {getEcosystemByIdRouter} from './features/getEcosystemById/getEcosystemByIdRouter';
import {errorHandler} from './common/infrastructure/errorHandler';
import {deployEcosystemRouter} from './features/deployEcosystem/api/deployEcosystemRouter';
import redis from './common/infrastructure/redis';
import { dataSource } from './common/infrastructure/datasource';

export const app = express();

Expand All @@ -20,6 +22,21 @@ const authenticateApiKey = (
}
};

app.get('/health', async (_, res) => {
const redisHealthy = (await redis.ping()) === 'PONG';
const dbHealthy = dataSource.isInitialized;

if (redisHealthy && dbHealthy) {
res.status(200).send('OK');
} else {
res.status(500).json({
message: 'Unhealthy',
redis: redisHealthy ? 'healthy' : 'unhealthy',
database: dbHealthy ? 'healthy' : 'unhealthy',
});
}
});

app.use(authenticateApiKey);
app.use(express.json({limit: '50mb'}));
app.use('/api', createEcosystemRouter);
Expand Down
3 changes: 1 addition & 2 deletions src/common/application/launchQueueDashboard.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import express, {Router} from 'express';
import Arena from 'bull-arena';
import BeeQueue from 'bee-queue';
import Redis from 'ioredis';
import {RequestHandler} from 'express';
import {config} from '../../config/configLoader';
import redis from '../infrastructure/redis';

let arenaRouter: Router | null = null;
const redis = new Redis(config.redisConnectionString);

export const getQueuesFromRedis = async (): Promise<
{
Expand Down
2 changes: 1 addition & 1 deletion src/common/infrastructure/redis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Redis from 'ioredis';
import {config} from '../../config/configLoader';
import {logger} from './logger';

const redis = new Redis(config.redisConnectionString);
const redis = new Redis(config.redisConnectionString + "?family=0");

redis.on('error', (error: Error) => {
logger.error('Redis connection error:', error);
Expand Down
1 change: 1 addition & 0 deletions src/config/configLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function loadConfig(): Config {
filename: process.env.LOG_FILE,
},
redisConnectionString: process.env.REDIS_CONNECTION_STRING,
redisUseIpv6: process.env.REDIS_USE_IPV6 === 'true',
rpc: process.env.RPC_CONFIG
? rpcConfigSchema.parse(JSON.parse(process.env.RPC_CONFIG))
: undefined,
Expand Down
1 change: 1 addition & 0 deletions src/config/configSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const configSchema = z.object({
databaseConnectionString: z.string(),
logger: loggingConfigSchema,
redisConnectionString: z.string(),
redisUseIpv6: z.boolean().default(false),
gitHubToken: z.string(),
rpc: rpcConfigSchema,
walletPrivateKey: z.string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ export const handleCreateEcosystem = async (
removeOnFailure: true,
removeOnSuccess: true,
activateDelayedJobs: true,
redis: {url: config.redisConnectionString},
redis: {
url: config.redisConnectionString,
family: config.redisUseIpv6 ? 'IPv6' : undefined,
},
});
logger.info(
`Created project verification queue '${queueKey}' for ecosystem '${ecosystemId}'.`,
Expand Down
5 changes: 4 additions & 1 deletion src/features/deployEcosystem/application/createQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ export default function createQueue(ecosystemId: UUID, chainId: string) {
removeOnFailure: true,
removeOnSuccess: true,
activateDelayedJobs: true,
redis: {url: config.redisConnectionString},
redis: {
url: config.redisConnectionString,
family: config.redisUseIpv6 ? 'IPv6' : undefined,
},
});

logger.info(
Expand Down