Fix backend startup issue by resolving port conflict

Resolves an "address already in use" error by killing existing processes on port 8000 before restarting the ML backend service.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 7a657272-55ba-4a79-9a2e-f1ed9bc7a528
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: 2c691790-1a58-44ba-94dd-f03a528d1174
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/449cf7c4-c97a-45ae-8234-e5c5b8d6a84f/7a657272-55ba-4a79-9a2e-f1ed9bc7a528/jFtLBWL
This commit is contained in:
marco370 2025-11-25 17:33:54 +00:00
parent 25e5735527
commit 955a2ee125

View File

@ -0,0 +1,125 @@
cd /opt/ids/python_ml && source venv/bin/activate && python3 main.py
[WARNING] Extended Isolation Forest not available, using standard IF
[ML] Using Hybrid ML Detector (Extended Isolation Forest + Feature Selection)
[HYBRID] Ensemble classifier loaded
[HYBRID] Models loaded (version: latest)
[HYBRID] Selected features: 18/25
[HYBRID] Mode: Hybrid (IF + Ensemble)
[ML] ✓ Hybrid detector models loaded and ready
 Starting IDS API on http://0.0.0.0:8000
 Docs available at http://0.0.0.0:8000/docs
INFO: Started server process [108626]
INFO: Waiting for application startup.
INFO: Application startup complete.
ERROR: [Errno 98] error while attempting to bind on address ('0.0.0.0', 8000): address already in use
INFO: Waiting for application shutdown.
INFO: Application shutdown complete.
(venv) [root@ids python_ml]# ls -la /opt/ids/python_ml/models/
total 22896
drwxr-xr-x. 2 ids ids 4096 Nov 25 18:30 .
drwxr-xr-x. 6 ids ids 4096 Nov 25 12:53 ..
-rw-r--r--. 1 root root 235398 Nov 24 18:55 ensemble_classifier_20251124_185541.pkl
-rw-r--r--. 1 root root 231504 Nov 24 18:59 ensemble_classifier_20251124_185920.pkl
-rw-r--r--. 1 root root 1008222 Nov 24 19:21 ensemble_classifier_20251124_192109.pkl
-rw-r--r--. 1 root root 925566 Nov 24 19:21 ensemble_classifier_20251124_192122.pkl
-rw-r--r--. 1 ids ids 200159 Nov 25 09:03 ensemble_classifier_20251125_090356.pkl
-rw-r--r--. 1 root root 806006 Nov 25 09:27 ensemble_classifier_20251125_092703.pkl
-rw-r--r--. 1 ids ids 286079 Nov 25 12:00 ensemble_classifier_20251125_120016.pkl
-rw-r--r--. 1 ids ids 398464 Nov 25 18:19 ensemble_classifier_20251125_181945.pkl
-rw-r--r--. 1 ids ids 426790 Nov 25 18:27 ensemble_classifier_20251125_182742.pkl
-rw-r--r--. 1 ids ids 423651 Nov 25 18:30 ensemble_classifier_20251125_183049.pkl
-rw-r--r--. 1 root root 806006 Nov 25 09:27 ensemble_classifier_latest.pkl
-rw-r--r--. 1 ids ids 461 Nov 25 00:00 feature_names.json
-rw-r--r--. 1 root root 1695 Nov 24 18:55 feature_selector_20251124_185541.pkl
-rw-r--r--. 1 root root 1695 Nov 24 18:59 feature_selector_20251124_185920.pkl
-rw-r--r--. 1 root root 1695 Nov 24 19:21 feature_selector_20251124_192109.pkl
-rw-r--r--. 1 root root 1695 Nov 24 19:21 feature_selector_20251124_192122.pkl
-rw-r--r--. 1 ids ids 1695 Nov 25 09:03 feature_selector_20251125_090356.pkl
-rw-r--r--. 1 root root 1695 Nov 25 09:27 feature_selector_20251125_092703.pkl
-rw-r--r--. 1 ids ids 1695 Nov 25 12:00 feature_selector_20251125_120016.pkl
-rw-r--r--. 1 ids ids 1695 Nov 25 18:19 feature_selector_20251125_181945.pkl
-rw-r--r--. 1 ids ids 1695 Nov 25 18:27 feature_selector_20251125_182742.pkl
-rw-r--r--. 1 ids ids 1695 Nov 25 18:30 feature_selector_20251125_183049.pkl
-rw-r--r--. 1 root root 1695 Nov 25 09:27 feature_selector_latest.pkl
-rw-r--r--. 1 ids ids 813592 Nov 25 00:00 isolation_forest.joblib
-rw-r--r--. 1 root root 1674808 Nov 24 18:55 isolation_forest_20251124_185541.pkl
-rw-r--r--. 1 root root 1642600 Nov 24 18:59 isolation_forest_20251124_185920.pkl
-rw-r--r--. 1 root root 1482984 Nov 24 19:21 isolation_forest_20251124_192109.pkl
-rw-r--r--. 1 root root 1465736 Nov 24 19:21 isolation_forest_20251124_192122.pkl
-rw-r--r--. 1 ids ids 1139256 Nov 25 09:03 isolation_forest_20251125_090356.pkl
-rw-r--r--. 1 root root 1428424 Nov 25 09:27 isolation_forest_20251125_092703.pkl
-rw-r--r--. 1 ids ids 1855240 Nov 25 12:00 isolation_forest_20251125_120016.pkl
-rw-r--r--. 1 ids ids 1519784 Nov 25 18:19 isolation_forest_20251125_181945.pkl
-rw-r--r--. 1 ids ids 1511688 Nov 25 18:27 isolation_forest_20251125_182742.pkl
-rw-r--r--. 1 ids ids 1559208 Nov 25 18:30 isolation_forest_20251125_183049.pkl
-rw-r--r--. 1 root root 1428424 Nov 25 09:27 isolation_forest_latest.pkl
-rw-r--r--. 1 root root 1661 Nov 24 18:55 metadata_20251124_185541.json
-rw-r--r--. 1 root root 1661 Nov 24 18:59 metadata_20251124_185920.json
-rw-r--r--. 1 root root 1675 Nov 24 19:21 metadata_20251124_192109.json
-rw-r--r--. 1 root root 1675 Nov 24 19:21 metadata_20251124_192122.json
-rw-r--r--. 1 root root 1675 Nov 25 09:27 metadata_20251125_092703.json
-rw-r--r--. 1 root root 1675 Nov 25 09:27 metadata_latest.json
-rw-r--r--. 1 ids ids 2015 Nov 25 00:00 scaler.joblib
-rw-r--r--. 1 root root 1047 Nov 24 18:55 scaler_20251124_185541.pkl
-rw-r--r--. 1 root root 1047 Nov 24 18:59 scaler_20251124_185920.pkl
-rw-r--r--. 1 root root 1047 Nov 24 19:21 scaler_20251124_192109.pkl
-rw-r--r--. 1 root root 1047 Nov 24 19:21 scaler_20251124_192122.pkl
-rw-r--r--. 1 ids ids 1047 Nov 25 09:03 scaler_20251125_090356.pkl
-rw-r--r--. 1 root root 1047 Nov 25 09:27 scaler_20251125_092703.pkl
-rw-r--r--. 1 ids ids 1047 Nov 25 12:00 scaler_20251125_120016.pkl
-rw-r--r--. 1 ids ids 1047 Nov 25 18:19 scaler_20251125_181945.pkl
-rw-r--r--. 1 ids ids 1047 Nov 25 18:27 scaler_20251125_182742.pkl
-rw-r--r--. 1 ids ids 1047 Nov 25 18:30 scaler_20251125_183049.pkl
-rw-r--r--. 1 root root 1047 Nov 25 09:27 scaler_latest.pkl
(venv) [root@ids python_ml]# tail -n 50 /var/log/ids/ml_backend.log
[HYBRID] Selected features: 18/25
[HYBRID] Mode: Hybrid (IF + Ensemble)
[ML] ✓ Hybrid detector models loaded and ready
🚀 Starting IDS API on http://0.0.0.0:8000
📚 Docs available at http://0.0.0.0:8000/docs
INFO: Started server process [108413]
INFO: Waiting for application startup.
INFO: Application startup complete.
ERROR: [Errno 98] error while attempting to bind on address ('0.0.0.0', 8000): address already in use
INFO: Waiting for application shutdown.
INFO: Application shutdown complete.
[WARNING] Extended Isolation Forest not available, using standard IF
[ML] Using Hybrid ML Detector (Extended Isolation Forest + Feature Selection)
[HYBRID] Ensemble classifier loaded
[HYBRID] Models loaded (version: latest)
[HYBRID] Selected features: 18/25
[HYBRID] Mode: Hybrid (IF + Ensemble)
[ML] ✓ Hybrid detector models loaded and ready
🚀 Starting IDS API on http://0.0.0.0:8000
📚 Docs available at http://0.0.0.0:8000/docs
INFO: Started server process [108452]
INFO: Waiting for application startup.
INFO: Application startup complete.
ERROR: [Errno 98] error while attempting to bind on address ('0.0.0.0', 8000): address already in use
INFO: Waiting for application shutdown.
INFO: Application shutdown complete.
[WARNING] Extended Isolation Forest not available, using standard IF
[ML] Using Hybrid ML Detector (Extended Isolation Forest + Feature Selection)
[HYBRID] Ensemble classifier loaded
[HYBRID] Models loaded (version: latest)
[HYBRID] Selected features: 18/25
[HYBRID] Mode: Hybrid (IF + Ensemble)
[ML] ✓ Hybrid detector models loaded and ready
🚀 Starting IDS API on http://0.0.0.0:8000
📚 Docs available at http://0.0.0.0:8000/docs
INFO: Started server process [108530]
INFO: Waiting for application startup.
INFO: Application startup complete.
ERROR: [Errno 98] error while attempting to bind on address ('0.0.0.0', 8000): address already in use
INFO: Waiting for application shutdown.
INFO: Application shutdown complete.
[WARNING] Extended Isolation Forest not available, using standard IF
[ML] Using Hybrid ML Detector (Extended Isolation Forest + Feature Selection)
[HYBRID] Ensemble classifier loaded
[HYBRID] Models loaded (version: latest)
[HYBRID] Selected features: 18/25
[HYBRID] Mode: Hybrid (IF + Ensemble)
[ML] ✓ Hybrid detector models loaded and ready
🚀 Starting IDS API on http://0.0.0.0:8000
📚 Docs available at http://0.0.0.0:8000/docs
(venv) [root@ids python_ml]#