flexbiz-server 12.3.40 → 12.3.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,7 +10,7 @@
10
10
  #rs.initiate({
11
11
  # _id: "rs0",
12
12
  # members: [
13
- # { _id: 0, host: "localhost:27017" }
13
+ # { _id: 0, host: "127.0.0.1:27017" }
14
14
  # ]
15
15
  #})
16
16
 
@@ -47,7 +47,7 @@ sudo systemctl stop mongod || true
47
47
  echo "⚙️ Sao lưu file cấu hình gốc sang ${CONF_FILE}.bak"
48
48
  sudo cp $CONF_FILE ${CONF_FILE}.bak.$(date +%Y%m%d%H%M%S)
49
49
 
50
- # 4. [SỬA LỖI 1] Cập nhật bindIp
50
+ # 4. Cập nhật bindIp
51
51
  echo "⚙️ Cập nhật 'net.bindIp' thành '0.0.0.0' (Cho phép kết nối replica)"
52
52
  if sudo grep -q "bindIp: 127.0.0.1" $CONF_FILE; then
53
53
  sudo sed -i 's/bindIp: 127.0.0.1/bindIp: 0.0.0.0/g' $CONF_FILE
@@ -56,7 +56,7 @@ else
56
56
  echo " -> Không tìm thấy 'bindIp: 127.0.0.1', giả sử đã cấu hình đúng."
57
57
  fi
58
58
 
59
- # 5. [SỬA LỖI 2] Cập nhật khối replication một cách an toàn
59
+ # 5. Cập nhật khối replication một cách an toàn
60
60
  echo "⚙️ Cập nhật khối 'replication'..."
61
61
  # Xóa bất kỳ khối 'replication:' cũ nào (từ dòng "replication:" đến dòng tiếp theo không thụt vào)
62
62
  # để tránh xung đột hoặc trùng lặp.
@@ -78,13 +78,17 @@ sudo systemctl enable mongod
78
78
  echo "⏳ Chờ 30 giây để MongoDB khởi động..."
79
79
  sleep 30
80
80
 
81
- # 8. [SỬA LỖI 3] Khởi tạo replica set
81
+ # 8. Khởi tạo replica set (nếu chưa có)
82
82
  echo "🧠 Khởi tạo replica set (${REPL_NAME})..."
83
- # Chỉ định rõ ràng host là 127.0.0.1 để tránh lỗi phân giải 'hostname'
84
- INIT_JS="rs.initiate({ _id: '${REPL_NAME}', members: [ { _id: 0, host: '127.0.0.1:${MONGO_PORT}' } ] })"
85
83
 
86
- # Chạy lệnh: Thử rs.status(), nếu lỗi (nghĩa chưa init) thì chạy INIT_JS
87
- $MONGO_SHELL --port $MONGO_PORT --eval "try { rs.status() } catch (e) { ${INIT_JS} }"
84
+ INIT_JS="if (rs.status().ok === 0) { rs.initiate({ _id: '${REPL_NAME}', members: [ { _id: 0, host: '127.0.0.1:${MONGO_PORT}' } ] }); }"
85
+
86
+ $MONGO_SHELL --quiet --port $MONGO_PORT --eval "${INIT_JS}" || {
87
+ echo "⚠️ Có thể replica đã được khởi tạo trước đó. Kiểm tra trạng thái..."
88
+ }
89
+
90
+ # Đợi 3s để replica ổn định
91
+ sleep 3
88
92
 
89
93
  # 9. Kiểm tra lại trạng thái
90
94
  echo "🔍 Kiểm tra trạng thái replica set..."
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "flexbiz-server",
3
3
  "main": "./server/app.js",
4
4
  "description": "Flexible Server",
5
- "version": "12.3.40",
5
+ "version": "12.3.42",
6
6
  "author": {
7
7
  "name": "Van Truong Pham",
8
8
  "email": "invncur@gmail.com"
@@ -22,9 +22,7 @@
22
22
  "body-parser": "^1.19.0",
23
23
  "brorand": "^1.1.0",
24
24
  "bwip-js": "^3.1.0",
25
- "cheerio": "^1.0.0-rc.10",
26
25
  "compression": "^1.7.4",
27
- "compression-webpack-plugin": "^3.0.0",
28
26
  "cookie-parser": "^1.4.6",
29
27
  "cors": "^2.8.5",
30
28
  "crypto-js": "^3.1.9-1",