diff --git a/docker-compose.yml b/docker-compose.yml index 6ee8a398..f36e8900 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,7 +16,7 @@ services: - redis db: - image: postgres:15 + image: postgres:13 environment: POSTGRES_DB: ${DB_NAME} POSTGRES_USER: ${DB_USER} diff --git a/nginx.conf b/nginx.conf index 1e4b4d17..e9d636f8 100644 --- a/nginx.conf +++ b/nginx.conf @@ -7,7 +7,7 @@ server { } location /api { - proxy_pass http://localhost:8080; + proxy_pass http://127.0.0.1:8080; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; diff --git a/server/src/constants/config.ts b/server/src/constants/config.ts index afc77031..74d9de4c 100644 --- a/server/src/constants/config.ts +++ b/server/src/constants/config.ts @@ -1,4 +1,4 @@ export const SERVER_PORT = process.env.SERVER_PORT ? Number(process.env.SERVER_PORT) : 8080 export const DEBUG = process.env.DEBUG === 'true' export const LOGS_PATH = process.env.LOGS_PATH ?? 'server/logs' -export const ANALYTICS_ID = process.env.ANALYTICS_ID ?? 'oss' \ No newline at end of file +export const ANALYTICS_ID = 'oss' \ No newline at end of file diff --git a/server/src/server.ts b/server/src/server.ts index dd824004..5c7fc898 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -62,8 +62,13 @@ readdirSync(path.join(__dirname, 'api')).forEach((r) => { } }); -const workerProcess = fork(path.resolve(__dirname, './worker.ts'), [], { - execArgv: ['--inspect=5859'], // Specify a different debug port for the worker +// Check if we're running in production or development +const isProduction = process.env.NODE_ENV === 'production'; +const workerPath = path.resolve(__dirname, isProduction ? './worker.js' : '/worker.ts'); + +// Fork the worker process +const workerProcess = fork(workerPath, [], { + execArgv: isProduction ? ['--inspect=8081'] : ['--inspect=5859'], }); workerProcess.on('message', (message) => { diff --git a/server/src/storage/db.ts b/server/src/storage/db.ts index 56c68d8b..6a23ef42 100644 --- a/server/src/storage/db.ts +++ b/server/src/storage/db.ts @@ -6,7 +6,7 @@ dotenv.config(); const sequelize = new Sequelize( `postgresql://${process.env.DB_USER}:${process.env.DB_PASSWORD}@${process.env.DB_HOST}:${process.env.DB_PORT}/${process.env.DB_NAME}`, { - host: 'localhost', + host: process.env.DB_HOST, dialect: 'postgres', logging: false, } diff --git a/server/src/utils/auth.ts b/server/src/utils/auth.ts index b1f6850f..e73a4237 100644 --- a/server/src/utils/auth.ts +++ b/server/src/utils/auth.ts @@ -24,9 +24,9 @@ export const comparePassword = (password: string, hash: string): Promise { - const ivLength = parseInt(getEnvVariable('IV_LENGTH'), 10); + const ivLength = 16; const iv = crypto.randomBytes(ivLength); - const algorithm = getEnvVariable('ALGORITHM'); + const algorithm = 'aes-256-cbc'; const key = Buffer.from(getEnvVariable('ENCRYPTION_KEY'), 'hex'); const cipher = crypto.createCipheriv(algorithm, key, iv); let encrypted = cipher.update(text, 'utf8', 'hex'); diff --git a/server/src/worker.ts b/server/src/worker.ts index 00bb13d2..fd3470d4 100644 --- a/server/src/worker.ts +++ b/server/src/worker.ts @@ -5,8 +5,13 @@ import { handleRunRecording } from "./workflow-management/scheduler"; import Robot from './models/Robot'; import { computeNextRun } from './utils/schedule'; +console.log('Environment variables:', { + REDIS_HOST: process.env.REDIS_HOST, + REDIS_PORT: process.env.REDIS_PORT, +}); + const connection = new IORedis({ - host: process.env.REDIS_HOST ? process.env.REDIS_HOST : 'redis', + host: process.env.REDIS_HOST, port: process.env.REDIS_PORT ? parseInt(process.env.REDIS_PORT, 10) : 6379, maxRetriesPerRequest: null, });