43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import { secrets } from './secret-manager.js';
|
|
import { MinioClient } from './minio.js';
|
|
import { NatsClient } from './nats.js';
|
|
import { FFmpegConverter } from './ffmpeg.js';
|
|
import { ImageDerivativesGenerator } from './image-derivaties-generator.js';
|
|
|
|
async function main() {
|
|
try {
|
|
console.log('🔐 Secrets loaded');
|
|
console.log(secrets)
|
|
|
|
// Initialize clients
|
|
const minioClient = new MinioClient();
|
|
const natsClient = new NatsClient();
|
|
const ffmpegConverter = new FFmpegConverter();
|
|
|
|
// Connect to NATS
|
|
await natsClient.connect();
|
|
|
|
// Create and start the service
|
|
const generator = new ImageDerivativesGenerator(
|
|
minioClient,
|
|
natsClient,
|
|
ffmpegConverter
|
|
);
|
|
|
|
await generator.start();
|
|
|
|
// Handle graceful shutdown
|
|
const shutdown = async () => {
|
|
await generator.stop();
|
|
process.exit(0);
|
|
};
|
|
|
|
process.on('SIGINT', shutdown);
|
|
process.on('SIGTERM', shutdown);
|
|
} catch (error) {
|
|
console.error('❌ Failed to start service:', error);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
main(); |