File size: 6,713 Bytes
c293f7c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | # π οΈ Scripts Usage Guide
This folder contains useful development, testing, and deployment scripts for the Enhanced Fake News Detection System.
## π **Available Scripts**
### π **Verification & Testing**
#### `verify_project.py`
**Purpose**: Comprehensive project verification before deployment
```bash
python scripts/verify_project.py
```
**What it checks**:
- β
Project structure completeness
- β
Python syntax validation
- β
Documentation completeness
- β
Docker configuration
- β
Git repository status
#### `final_verification.py`
**Purpose**: Final deployment readiness check with Docker testing
```bash
python scripts/final_verification.py
```
**What it checks**:
- β
All project verification checks
- β
Docker build testing
- β
Docker Compose validation
- β
System requirements
- β
Deployment summary
#### `health_check.py`
**Purpose**: Application health monitoring and status checks
```bash
python scripts/health_check.py
# Or with custom URL
python scripts/health_check.py --url http://localhost:8080
```
**What it monitors**:
- β
API endpoint health
- β
Database connectivity
- β
Service response times
- β
System resource usage
#### `performance_benchmark.py`
**Purpose**: Performance testing and benchmarking
```bash
python scripts/performance_benchmark.py
```
**What it tests**:
- β
API response times
- β
Throughput testing
- β
Memory usage analysis
- β
Concurrent request handling
#### `validate_environment.py`
**Purpose**: Environment setup validation
```bash
python scripts/validate_environment.py
```
**What it validates**:
- β
Python dependencies
- β
Environment variables
- β
System requirements
- β
Configuration files
---
### π³ **Docker Management**
#### `docker-dev.sh`
**Purpose**: Docker development environment management
```bash
# Make executable (Linux/Mac)
chmod +x scripts/docker-dev.sh
# Start development environment
./scripts/docker-dev.sh start
# Stop development environment
./scripts/docker-dev.sh stop
# Rebuild and restart
./scripts/docker-dev.sh restart
# View logs
./scripts/docker-dev.sh logs
# Clean up
./scripts/docker-dev.sh clean
```
#### `docker-prod.sh`
**Purpose**: Docker production environment management
```bash
# Make executable (Linux/Mac)
chmod +x scripts/docker-prod.sh
# Deploy to production
./scripts/docker-prod.sh deploy
# Stop production
./scripts/docker-prod.sh stop
# Update production
./scripts/docker-prod.sh update
# View production logs
./scripts/docker-prod.sh logs
```
---
### π **Local Development**
#### `run_local.sh` (Linux/Mac)
**Purpose**: Local development environment setup
```bash
# Make executable
chmod +x scripts/run_local.sh
# Start local development
./scripts/run_local.sh
# Start with specific mode
./scripts/run_local.sh --mode development
# Skip dependency installation
./scripts/run_local.sh --skip-deps
# Run in background
./scripts/run_local.sh --detached
```
#### `run_local.ps1` (Windows)
**Purpose**: Windows local development setup
```powershell
# Run in PowerShell
.\scripts\run_local.ps1
# With parameters
.\scripts\run_local.ps1 -Mode development -SkipDeps
```
#### `run_tests.sh`
**Purpose**: Test execution and validation
```bash
# Make executable
chmod +x scripts/run_tests.sh
# Run all tests
./scripts/run_tests.sh
# Run specific test suite
./scripts/run_tests.sh --suite unit
./scripts/run_tests.sh --suite integration
./scripts/run_tests.sh --suite e2e
# Run with coverage
./scripts/run_tests.sh --coverage
# Run in verbose mode
./scripts/run_tests.sh --verbose
```
---
## π― **Common Workflows**
### **1. New Developer Setup**
```bash
# 1. Verify project setup
python scripts/verify_project.py
# 2. Validate environment
python scripts/validate_environment.py
# 3. Start local development
./scripts/run_local.sh
# 4. Run tests to ensure everything works
./scripts/run_tests.sh
```
### **2. Before Deployment**
```bash
# 1. Run comprehensive verification
python scripts/final_verification.py
# 2. Performance benchmark
python scripts/performance_benchmark.py
# 3. Deploy with Docker
./scripts/docker-prod.sh deploy
```
### **3. Health Monitoring**
```bash
# Check application health
python scripts/health_check.py
# Continuous monitoring (every 30 seconds)
watch -n 30 python scripts/health_check.py
```
### **4. Development Workflow**
```bash
# Start development environment
./scripts/docker-dev.sh start
# Make changes to code...
# Run tests
./scripts/run_tests.sh
# Restart with changes
./scripts/docker-dev.sh restart
# Check health
python scripts/health_check.py
```
---
## π§ **Script Requirements**
### **Python Scripts**
- Python 3.8+
- Dependencies from `requirements.txt`
- Some scripts may need additional packages (specified in script headers)
### **Shell Scripts**
- **Linux/Mac**: Bash shell
- **Windows**: PowerShell 5.0+
- Docker and Docker Compose installed
- Git (for some verification scripts)
---
## π **Script Output Examples**
### **Verification Success**
```
π Enhanced Fake News Detection System - Project Verification
======================================================================
β
PASS Project Structure
β
PASS Python Dependencies
β
PASS Documentation
β
PASS Docker Availability
β
PASS Docker Build
β
PASS Docker Compose
β
PASS Git Status
Score: 7/7 checks passed
π ALL CHECKS PASSED!
```
### **Health Check Success**
```
π₯ Application Health Check
======================================================================
β
API Health: HEALTHY (200ms)
β
Database: CONNECTED
β
Memory Usage: 45% (2.1GB/4.0GB)
β
CPU Usage: 12%
β
Disk Space: 78% available
Overall Status: HEALTHY π’
```
---
## π¨ **Troubleshooting**
### **Permission Issues (Linux/Mac)**
```bash
# Make scripts executable
chmod +x scripts/*.sh
```
### **PowerShell Execution Policy (Windows)**
```powershell
# Allow script execution
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
```
### **Docker Issues**
```bash
# Ensure Docker is running
docker --version
docker-compose --version
# Check Docker daemon
docker ps
```
---
## π **Adding New Scripts**
When adding new scripts to this folder:
1. **Follow naming convention**: `action_description.py` or `action_description.sh`
2. **Add documentation**: Include usage instructions in script header
3. **Update this README**: Add the new script to the appropriate section
4. **Make executable**: `chmod +x scripts/new_script.sh`
5. **Test thoroughly**: Ensure script works in different environments
---
**π οΈ These scripts help streamline development, testing, and deployment workflows for the Enhanced Fake News Detection System.** |