fix(docker): 简化site存在性检查
- 只检查site目录是否存在,避免复杂的数据库检查 - 移除不可靠的frappe.ping检查 - 防止每次重启都重新创建site
This commit is contained in:
+1
-30
@@ -89,39 +89,10 @@ PROCFILE
|
||||
fi
|
||||
|
||||
# Create site if not exists
|
||||
SITE_DIR_EXISTS=false
|
||||
DB_EXISTS=false
|
||||
|
||||
if [ -d "${BENCH_DIR}/sites/${SITE_NAME}" ]; then
|
||||
SITE_DIR_EXISTS=true
|
||||
fi
|
||||
|
||||
# Check if database is accessible by trying to connect
|
||||
if bench --site "${SITE_NAME}" execute frappe.ping 2>/dev/null || \
|
||||
(cd "${BENCH_DIR}" && python3 -c "
|
||||
import sys
|
||||
try:
|
||||
import frappe
|
||||
frappe.init('${SITE_NAME}')
|
||||
frappe.connect()
|
||||
frappe.db.sql('SELECT 1')
|
||||
print('DB_OK')
|
||||
sys.exit(0)
|
||||
except:
|
||||
sys.exit(1)
|
||||
" 2>/dev/null); then
|
||||
DB_EXISTS=true
|
||||
fi
|
||||
|
||||
if [ "${SITE_DIR_EXISTS}" = "false" ] || [ "${DB_EXISTS}" = "false" ]; then
|
||||
if [ ! -d "${BENCH_DIR}/sites/${SITE_NAME}" ]; then
|
||||
echo "Creating site: ${SITE_NAME}..."
|
||||
cd "${BENCH_DIR}"
|
||||
|
||||
# Remove incomplete site directory if exists
|
||||
if [ -d "${BENCH_DIR}/sites/${SITE_NAME}" ]; then
|
||||
rm -rf "${BENCH_DIR}/sites/${SITE_NAME}"
|
||||
fi
|
||||
|
||||
# Set common config for Redis services
|
||||
bench set-config -g redis_cache "redis://redis-cache:6379"
|
||||
bench set-config -g redis_queue "redis://redis-queue:6379"
|
||||
|
||||
Reference in New Issue
Block a user