auto commit

This commit is contained in:
bangdk 2024-11-25 07:57:25 +09:00
parent 7bd9d70716
commit 063bfa5f24
3 changed files with 108 additions and 9 deletions

View File

@ -28,6 +28,8 @@ JWT_EXPIRES_IN=1d
# REALTIME API
REALTIME_API_PORT=3004
REALTIME_BACKEND_API_URL=http://localhost:3004
# Main Backend
ADMIN_API_KEY=your_admin_api_key
# Database
POSTGRES_HOST=fems-postgres
@ -52,6 +54,7 @@ TIMESCALEDB_PASSWORD=wacefems-tsdb-password-PPw09!keep
REDIS_HOST=fems-redis
REDIS_PORT=6379
REDIS_PASSWORD=wacefems-redis-password-PPw09!keep
REDIS_DB=0
# MQTT Broker
MQTT_BROKER_URL=mqtt://fems-mqtt:1883

View File

@ -16005,3 +16005,70 @@ To fix this, use `chmod 0700 /mosquitto/config/passwd`.
1732488328: New connection from ::1:42548 on port 1883.
1732488328: New client connected from ::1:42548 as auto-D84863A7-B648-5FF2-41C2-40606B1D1BCE (p2, c1, k60, u'fems').
1732488328: Client auto-D84863A7-B648-5FF2-41C2-40606B1D1BCE closed its connection.
1732488531: mosquitto version 2.0.20 starting
1732488531: Config loaded from /mosquitto/config/mosquitto.conf.
1732488531: Opening ipv4 listen socket on port 1883.
1732488531: Opening ipv6 listen socket on port 1883.
1732488531: mosquitto version 2.0.20 running
1732488562: New connection from ::1:52214 on port 1883.
1732488562: New client connected from ::1:52214 as auto-00480A34-F853-56EA-5102-017344805812 (p2, c1, k60, u'fems').
1732488562: Client auto-00480A34-F853-56EA-5102-017344805812 closed its connection.
1732488592: New connection from ::1:35136 on port 1883.
1732488592: New client connected from ::1:35136 as auto-9E020DC1-7BF4-15BC-3D28-D131C329B7A2 (p2, c1, k60, u'fems').
1732488592: Client auto-9E020DC1-7BF4-15BC-3D28-D131C329B7A2 closed its connection.
1732488622: New connection from ::1:43668 on port 1883.
1732488622: New client connected from ::1:43668 as auto-DD0D1A2E-3ABF-00DD-EBB4-9726341AE7E8 (p2, c1, k60, u'fems').
1732488622: Client auto-DD0D1A2E-3ABF-00DD-EBB4-9726341AE7E8 closed its connection.
1732488652: New connection from ::1:57446 on port 1883.
1732488652: New client connected from ::1:57446 as auto-F55FDB59-A402-3A7F-C8B3-28EE30DF10DF (p2, c1, k60, u'fems').
1732488652: Client auto-F55FDB59-A402-3A7F-C8B3-28EE30DF10DF closed its connection.
1732488682: New connection from ::1:36594 on port 1883.
1732488682: New client connected from ::1:36594 as auto-6ADD248F-4DD9-1182-F798-497D36F6996B (p2, c1, k60, u'fems').
1732488682: Client auto-6ADD248F-4DD9-1182-F798-497D36F6996B closed its connection.
1732488713: New connection from ::1:55290 on port 1883.
1732488713: New client connected from ::1:55290 as auto-34B20C39-1719-306B-0A04-739983EDC42B (p2, c1, k60, u'fems').
1732488713: Client auto-34B20C39-1719-306B-0A04-739983EDC42B closed its connection.
1732488743: New connection from ::1:48264 on port 1883.
1732488743: New client connected from ::1:48264 as auto-386489BF-C359-702D-ECE0-B739C7AEE09E (p2, c1, k60, u'fems').
1732488743: Client auto-386489BF-C359-702D-ECE0-B739C7AEE09E closed its connection.
1732488773: New connection from ::1:52922 on port 1883.
1732488773: New client connected from ::1:52922 as auto-749B469E-AEC5-0B50-7D4C-F0B39192DBFA (p2, c1, k60, u'fems').
1732488773: Client auto-749B469E-AEC5-0B50-7D4C-F0B39192DBFA closed its connection.
1732488803: New connection from ::1:38468 on port 1883.
1732488803: New client connected from ::1:38468 as auto-7EA01BFD-EEA4-E9DB-640C-5DFDA6D80D16 (p2, c1, k60, u'fems').
1732488803: Client auto-7EA01BFD-EEA4-E9DB-640C-5DFDA6D80D16 closed its connection.
1732488829: New connection from 172.19.0.8:46098 on port 1883.
1732488829: New client connected from 172.19.0.8:46098 as fems_realtime_129 (p2, c1, k60, u'fems').
1732488833: New connection from ::1:46540 on port 1883.
1732488833: New client connected from ::1:46540 as auto-11F2C909-409B-E04A-BCFB-680532C2914A (p2, c1, k60, u'fems').
1732488834: Client auto-11F2C909-409B-E04A-BCFB-680532C2914A closed its connection.
1732488848: Client fems_realtime_129 closed its connection.
1732488849: New connection from 172.19.0.8:35098 on port 1883.
1732488849: New client connected from 172.19.0.8:35098 as fems_realtime_149 (p2, c1, k60, u'fems').
1732488864: New connection from ::1:56256 on port 1883.
1732488864: New client connected from ::1:56256 as auto-4D8F2C8A-1C37-A246-C8FC-0722A026BF4B (p2, c1, k60, u'fems').
1732488864: Client auto-4D8F2C8A-1C37-A246-C8FC-0722A026BF4B closed its connection.
1732488894: New connection from ::1:57430 on port 1883.
1732488894: New client connected from ::1:57430 as auto-BC533A36-C47A-010F-2CC5-10101978EFE2 (p2, c1, k60, u'fems').
1732488894: Client auto-BC533A36-C47A-010F-2CC5-10101978EFE2 closed its connection.
1732488903: Client fems_realtime_149 closed its connection.
1732488903: New connection from 172.19.0.8:58676 on port 1883.
1732488903: New client connected from 172.19.0.8:58676 as fems_realtime_175 (p2, c1, k60, u'fems').
1732488924: New connection from ::1:39824 on port 1883.
1732488924: New client connected from ::1:39824 as auto-6D12CEC4-232E-41FB-D442-E905CFFCDFD7 (p2, c1, k60, u'fems').
1732488924: Client auto-6D12CEC4-232E-41FB-D442-E905CFFCDFD7 closed its connection.
1732488954: New connection from ::1:53958 on port 1883.
1732488954: New client connected from ::1:53958 as auto-C4909E34-0B3C-E5E8-8498-FA2FCF49297C (p2, c1, k60, u'fems').
1732488954: Client auto-C4909E34-0B3C-E5E8-8498-FA2FCF49297C closed its connection.
1732488984: New connection from ::1:54148 on port 1883.
1732488984: New client connected from ::1:54148 as auto-48380A77-A9E2-5F1A-DBB7-CA0B349FFE1D (p2, c1, k60, u'fems').
1732488984: Client auto-48380A77-A9E2-5F1A-DBB7-CA0B349FFE1D closed its connection.
1732489014: New connection from ::1:32834 on port 1883.
1732489014: New client connected from ::1:32834 as auto-10895F11-3FC3-F2D0-D05F-57B11E8DEA22 (p2, c1, k60, u'fems').
1732489014: Client auto-10895F11-3FC3-F2D0-D05F-57B11E8DEA22 closed its connection.
1732489036: Client fems_realtime_175 closed its connection.
1732489037: New connection from 172.19.0.8:44524 on port 1883.
1732489037: New client connected from 172.19.0.8:44524 as fems_realtime_213 (p2, c1, k60, u'fems').
1732489044: New connection from ::1:39722 on port 1883.
1732489044: New client connected from ::1:39722 as auto-606217CB-63B1-C803-3818-9B8CA606A1FA (p2, c1, k60, u'fems').
1732489044: Client auto-606217CB-63B1-C803-3818-9B8CA606A1FA closed its connection.

View File

@ -14,20 +14,49 @@ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
async function waitForServices() {
const maxRetries = 30;
let retries = 0;
const services = {
timescaledb: false,
redis: false,
};
while (retries < maxRetries) {
try {
const pool = new Pool(config.timescaledb);
await pool.query("SELECT 1");
await pool.end();
const redis = new Redis(config.redis);
await redis.ping();
await redis.quit();
logger.info("Successfully connected to all services");
return;
// TimescaleDB 연결 시도
if (!services.timescaledb) {
const pool = new Pool(config.timescaledb);
await pool.query("SELECT 1");
await pool.end();
services.timescaledb = true;
logger.info("Successfully connected to TimescaleDB");
}
// Redis 연결 시도
if (!services.redis) {
const redis = new Redis({
...config.redis,
enableReadyCheck: true,
maxRetriesPerRequest: 3,
});
await redis.ping();
await redis.quit();
services.redis = true;
logger.info("Successfully connected to Redis");
}
// 모든 서비스가 연결되었는지 확인
if (Object.values(services).every((status) => status)) {
logger.info("All services are connected");
return;
}
} catch (error) {
retries++;
logger.warn(
`Failed to connect to services, attempt ${retries}/${maxRetries}`
`Failed to connect to services, attempt ${retries}/${maxRetries}`,
{
error: error.message,
services: JSON.stringify(services),
}
);
await sleep(2000);
}