# DBIS Services Status Report

**Date**: 2026-01-02  
**Status**: ⚠️ **SERVICES REQUIRING ATTENTION**

---

## Executive Summary

After comprehensive checks of all DBIS containers following IP address changes, the following status has been determined:

- ✅ **Redis (10120)**: Running and accessible
- ✅ **Frontend/Nginx (10130)**: Running and accessible
- ❌ **PostgreSQL Primary (10100)**: Not running - service not installed/configured
- ❌ **PostgreSQL Replica (10101)**: Not running - service not installed/configured
- ❌ **API Primary (10150)**: Not running - requires DATABASE_URL update and service start
- ❌ **API Secondary (10151)**: Not running - requires DATABASE_URL update and service start

**Critical Issue**: API containers have `.env` files with old database IP addresses that need to be updated.

---

## Detailed Service Status

### ✅ VMID 10120 - Redis Cache

**Container IP**: 192.168.11.120/24  
**Status**: ✅ **RUNNING**

- **Container**: ✅ Running
- **Service**: ✅ `redis-server.service` active and running
- **Port 6379**: ✅ Listening on 0.0.0.0:6379
- **Process**: ✅ Redis server process running (PID 11479)
- **External Connectivity**: ✅ Accessible from outside container

**Action Required**: ✅ None - Service is fully operational

---

### ✅ VMID 10130 - Frontend

**Container IP**: 192.168.11.130/24  
**Status**: ✅ **RUNNING**

- **Container**: ✅ Running
- **Service**: ✅ `nginx.service` active and running
- **Port 80**: ✅ Listening on 0.0.0.0:80
- **Process**: ✅ Nginx master and worker processes running
- **External Connectivity**: ⏳ To be verified

**Action Required**: 
- ⏳ Verify Nginx configuration for API endpoint references (check if proxy_pass uses old IPs)

---

### ❌ VMID 10100 - PostgreSQL Primary

**Container IP**: 192.168.11.105/24  
**Status**: ❌ **NOT RUNNING**

- **Container**: ✅ Running
- **Service**: ❌ No PostgreSQL systemd service found
- **Port 5432**: ❌ Not listening
- **Process**: ❌ No PostgreSQL process running
- **External Connectivity**: ❌ Not accessible

**Action Required**:
1. ⏳ Verify PostgreSQL installation
2. ⏳ Install PostgreSQL if not installed
3. ⏳ Configure PostgreSQL service
4. ⏳ Start PostgreSQL service
5. ⏳ Verify database initialization

---

### ❌ VMID 10101 - PostgreSQL Replica

**Container IP**: 192.168.11.106/24  
**Status**: ❌ **NOT RUNNING**

- **Container**: ✅ Running
- **Service**: ❌ No PostgreSQL systemd service found
- **Port 5432**: ❌ Not listening
- **Process**: ❌ No PostgreSQL process running
- **External Connectivity**: ❌ Not accessible

**Action Required**:
1. ⏳ Verify PostgreSQL installation
2. ⏳ Install PostgreSQL if not installed
3. ⏳ Configure PostgreSQL replication
4. ⏳ Start PostgreSQL service
5. ⏳ Configure replication from primary (192.168.11.105)

---

### ❌ VMID 10150 - API Primary

**Container IP**: 192.168.11.155/24  
**Status**: ❌ **NOT RUNNING - CONFIGURATION ISSUE**

- **Container**: ✅ Running
- **Service**: ❌ No API/systemd service found
- **Port 3000**: ❌ Not listening
- **Process**: ❌ No Node.js process running
- **External Connectivity**: ❌ Not accessible
- **Health Endpoint**: ❌ Not accessible

**Critical Configuration Issue**:
- ❌ **DATABASE_URL in `.env` file uses OLD IP**: `192.168.11.100`
- ⚠️ **Must be updated to**: `192.168.11.105`

**Location**: `/opt/dbis-core/.env`
```env
DATABASE_URL=postgresql://dbis:...@192.168.11.100:5432/dbis_core
```

**Action Required**:
1. 🔴 **CRITICAL**: Update `.env` file DATABASE_URL to use new IP (192.168.11.105)
2. ⏳ Verify Node.js installation
3. ⏳ Verify DBIS Core application is installed
4. ⏳ Start API service (systemd or process manager)
5. ⏳ Verify database connectivity
6. ⏳ Test health endpoint

---

### ❌ VMID 10151 - API Secondary

**Container IP**: 192.168.11.156/24  
**Status**: ❌ **NOT RUNNING - CONFIGURATION ISSUE**

- **Container**: ✅ Running
- **Service**: ❌ No API/systemd service found
- **Port 3000**: ❌ Not listening
- **Process**: ❌ No Node.js process running
- **External Connectivity**: ❌ Not accessible
- **Health Endpoint**: ❌ Not accessible

**Critical Configuration Issue**:
- ❌ **DATABASE_URL in `.env` file uses OLD IP**: `192.168.11.100`
- ⚠️ **Must be updated to**: `192.168.11.105`

**Location**: `/opt/dbis-core/.env`
```env
DATABASE_URL=postgresql://dbis:...@192.168.11.100:5432/dbis_core
```

**Action Required**:
1. 🔴 **CRITICAL**: Update `.env` file DATABASE_URL to use new IP (192.168.11.105)
2. ⏳ Verify Node.js installation
3. ⏳ Verify DBIS Core application is installed
4. ⏳ Start API service (systemd or process manager)
5. ⏳ Verify database connectivity
6. ⏳ Test health endpoint

---

## Configuration Files Requiring Updates

### Critical: DATABASE_URL in API Containers

**VMIDs Affected**: 10150, 10151

**File**: `/opt/dbis-core/.env`

**Current (Incorrect)**:
```env
DATABASE_URL=postgresql://dbis:...@192.168.11.100:5432/dbis_core
```

**Required (Correct)**:
```env
DATABASE_URL=postgresql://dbis:...@192.168.11.105:5432/dbis_core
```

**Update Command**:
```bash
# For VMID 10150
ssh root@192.168.11.10 "pct exec 10150 -- sed -i 's/@192.168.11.100:5432/@192.168.11.105:5432/g' /opt/dbis-core/.env"

# For VMID 10151
ssh root@192.168.11.10 "pct exec 10151 -- sed -i 's/@192.168.11.100:5432/@192.168.11.105:5432/g' /opt/dbis-core/.env"
```

### Nginx Configuration (Frontend)

**VMID**: 10130

**Action Required**: Verify Nginx proxy_pass directives reference correct API IPs:
- Should use: `192.168.11.155` and `192.168.11.156`
- Should NOT use: `192.168.11.150` and `192.168.11.151`

---

## Service Startup Priority

1. **PostgreSQL Primary (10100)** - Must be started first (database foundation)
2. **PostgreSQL Replica (10101)** - Can start after primary
3. **Update API .env files** - Before starting API services
4. **API Primary (10150)** - Depends on PostgreSQL
5. **API Secondary (10151)** - Depends on PostgreSQL
6. **Frontend/Nginx (10130)** - Verify API endpoint config, then verify connectivity

---

## Summary of Actions Required

### ✅ Completed

1. ✅ **COMPLETED**: Updated DATABASE_URL in VMIDs 10150 and 10151 `.env` files (old IP: 192.168.11.100 → new IP: 192.168.11.105)

### High Priority

2. ⏳ Verify and start PostgreSQL Primary (VMID 10100)
3. ⏳ Verify and start PostgreSQL Replica (VMID 10101) - if needed
4. ⏳ Verify Nginx configuration in Frontend (VMID 10130) for API endpoints

### Medium Priority

5. ⏳ Start API Primary service (VMID 10150) after database is running
6. ⏳ Start API Secondary service (VMID 10151) after database is running
7. ⏳ Verify all service connectivity

---

## Verification Checklist

- [x] DATABASE_URL updated in API containers ✅
- [ ] PostgreSQL Primary installed and running
- [ ] PostgreSQL Replica installed and running (if needed)
- [ ] API Primary service started
- [ ] API Secondary service started
- [ ] Nginx configuration verified for API endpoints
- [ ] All services accessible on expected ports
- [ ] Health endpoints responding
- [ ] Database connections working

---

**Last Updated**: 2026-01-02  
**Status**: ⚠️ **ACTION REQUIRED** - Services need configuration and startup
