Replace Redis shell exec with spawn

This commit is contained in:
Tor Wingalen
2026-05-15 23:45:59 +02:00
parent f64cc97475
commit be11bb94d7
+11 -2
View File
@@ -4,7 +4,7 @@ import { HttpExceptionFilter } from './shared/filters/http-exception.filter';
import { AppModule } from './app.module'; import { AppModule } from './app.module';
import * as fs from 'fs'; import * as fs from 'fs';
import { resolve } from 'path'; import { resolve } from 'path';
import { exec } from 'child_process'; import { spawn } from 'child_process';
import helmet from 'helmet'; import helmet from 'helmet';
import { EnvironmentEnum } from './environmentEnum'; import { EnvironmentEnum } from './environmentEnum';
@@ -27,7 +27,16 @@ async function bootstrap() {
try { try {
// Convenience mode for the single-container Docker image. // Convenience mode for the single-container Docker image.
// Hardened deployments should prefer an external Redis service. // Hardened deployments should prefer an external Redis service.
exec(`redis-server --port ${process.env.REDIS_PORT || 6379}`); const redisProcess = spawn(
'redis-server',
['--port', String(process.env.REDIS_PORT || 6379)],
{
stdio: 'ignore',
detached: true,
},
);
redisProcess.unref();
} catch (e) { } catch (e) {
console.log('Unable to run redis server from app'); console.log('Unable to run redis server from app');
console.log(e); console.log(e);