add
This commit is contained in:
parent
43459e64bf
commit
55ee7b7a1c
12
core/db.py
12
core/db.py
|
@ -2,6 +2,7 @@
|
|||
# @name: db
|
||||
# @auth: rainy-autumn@outlook.com
|
||||
# @version:
|
||||
import time
|
||||
from urllib.parse import quote_plus
|
||||
|
||||
from motor.motor_asyncio import AsyncIOMotorClient, AsyncIOMotorCursor
|
||||
|
@ -23,11 +24,20 @@ async def get_mongo_db():
|
|||
|
||||
async def create_database():
|
||||
client = None
|
||||
check_flag = 0
|
||||
try:
|
||||
while True:
|
||||
try:
|
||||
# 创建新的 MongoDB 客户端
|
||||
client = AsyncIOMotorClient(f"mongodb://{quote_plus(DATABASE_USER)}:{quote_plus(DATABASE_PASSWORD)}@{MONGODB_IP}:{str(MONGODB_PORT)}",
|
||||
serverSelectionTimeoutMS=2000)
|
||||
|
||||
break
|
||||
except Exception as e:
|
||||
time.sleep(5)
|
||||
check_flag += 1
|
||||
if check_flag == 5:
|
||||
logger.error(f"Error re creating database: {e}")
|
||||
exit(0)
|
||||
# 获取数据库列表
|
||||
database_names = await client.list_database_names()
|
||||
|
||||
|
|
|
@ -63,9 +63,6 @@ services:
|
|||
retries: 10
|
||||
networks:
|
||||
- scopesentry-network
|
||||
dns:
|
||||
- 8.8.8.8
|
||||
- 1.1.1.1
|
||||
|
||||
scopesentry-scan:
|
||||
image: autumn27/scopesentry-scan:latest
|
||||
|
@ -88,6 +85,3 @@ services:
|
|||
condition: service_healthy
|
||||
networks:
|
||||
- scopesentry-network
|
||||
dns:
|
||||
- 8.8.8.8
|
||||
- 1.1.1.1
|
||||
|
|
Loading…
Reference in New Issue