115 lines
4.0 KiB
Markdown
115 lines
4.0 KiB
Markdown
# Worker Consolidation Summary
|
|
|
|
## Overview
|
|
Successfully consolidated the separate Managing.Api.Workers project into the main Managing.Api project as background services. This eliminates Orleans conflicts and simplifies deployment while maintaining all worker functionality.
|
|
|
|
## Changes Made
|
|
|
|
### 1. ✅ Updated ApiBootstrap.cs
|
|
- **File**: `src/Managing.Bootstrap/ApiBootstrap.cs`
|
|
- **Changes**: Added all worker services from WorkersBootstrap to the main AddWorkers method
|
|
- **Workers Added**:
|
|
- PricesFifteenMinutesWorker
|
|
- PricesOneHourWorker
|
|
- PricesFourHoursWorker
|
|
- PricesOneDayWorker
|
|
- PricesFiveMinutesWorker
|
|
- SpotlightWorker
|
|
- TraderWatcher
|
|
- LeaderboardWorker
|
|
- FundingRatesWatcher
|
|
- GeneticAlgorithmWorker
|
|
- BundleBacktestWorker
|
|
- BalanceTrackingWorker
|
|
- NotifyBundleBacktestWorker
|
|
|
|
### 2. ✅ Configuration Files Updated
|
|
- **File**: `src/Managing.Api/appsettings.json`
|
|
- **File**: `src/Managing.Api/appsettings.Oda-docker.json`
|
|
- **Changes**: Added worker configuration flags to control which workers run
|
|
- **Default Values**: All workers disabled by default (set to `false`)
|
|
|
|
### 3. ✅ Deployment Scripts Updated
|
|
- **Files**:
|
|
- `scripts/build_and_run.sh`
|
|
- `scripts/docker-deploy-local.cmd`
|
|
- `scripts/docker-redeploy-oda.cmd`
|
|
- `scripts/docker-deploy-sandbox.cmd`
|
|
- **Changes**: Removed worker-specific build and deployment commands
|
|
|
|
### 4. ✅ Docker Compose Files Updated
|
|
- **Files**:
|
|
- `src/Managing.Docker/docker-compose.yml`
|
|
- `src/Managing.Docker/docker-compose.local.yml`
|
|
- **Changes**: Removed managing.api.workers service definitions
|
|
|
|
### 5. ✅ Workers Project Deprecated
|
|
- **File**: `src/Managing.Api.Workers/Program.cs`
|
|
- **Changes**: Added deprecation notice and removed Orleans configuration
|
|
- **Note**: Project kept for reference but should not be deployed
|
|
|
|
## Benefits Achieved
|
|
|
|
### ✅ Orleans Conflicts Resolved
|
|
- **Before**: Two Orleans clusters competing for same ports (11111/30000)
|
|
- **After**: Single Orleans cluster in main API
|
|
- **Impact**: No more port conflicts or cluster identity conflicts
|
|
|
|
### ✅ Simplified Architecture
|
|
- **Before**: Two separate applications to deploy and monitor
|
|
- **After**: Single application with all functionality
|
|
- **Impact**: Easier deployment, monitoring, and debugging
|
|
|
|
### ✅ Resource Efficiency
|
|
- **Before**: Duplicate service registrations and database connections
|
|
- **After**: Shared resources and connection pools
|
|
- **Impact**: Better performance and resource utilization
|
|
|
|
### ✅ Configuration Management
|
|
- **Before**: Separate configuration files for workers
|
|
- **After**: Centralized configuration with worker flags
|
|
- **Impact**: Easier to manage and control worker execution
|
|
|
|
## How to Enable/Disable Workers
|
|
|
|
Workers are controlled via configuration flags in `appsettings.json`:
|
|
|
|
```json
|
|
{
|
|
"WorkerPricesFifteenMinutes": false,
|
|
"WorkerPricesOneHour": false,
|
|
"WorkerPricesFourHours": false,
|
|
"WorkerPricesOneDay": false,
|
|
"WorkerPricesFiveMinutes": false,
|
|
"WorkerSpotlight": false,
|
|
"WorkerTraderWatcher": false,
|
|
"WorkerLeaderboard": false,
|
|
"WorkerFundingRatesWatcher": false,
|
|
"WorkerGeneticAlgorithm": false,
|
|
"WorkerBundleBacktest": false,
|
|
"WorkerBalancesTracking": false,
|
|
"WorkerNotifyBundleBacktest": false
|
|
}
|
|
```
|
|
|
|
Set any worker to `true` to enable it in that environment.
|
|
|
|
## Testing
|
|
|
|
### ✅ Build Verification
|
|
- Main API project builds successfully
|
|
- All worker dependencies resolved
|
|
- No compilation errors
|
|
|
|
### Next Steps for Full Verification
|
|
1. **Runtime Testing**: Start the main API and verify workers load correctly
|
|
2. **Worker Functionality**: Test that enabled workers execute as expected
|
|
3. **Orleans Integration**: Verify workers can access Orleans grains properly
|
|
4. **Configuration Testing**: Test enabling/disabling workers via config
|
|
|
|
## Migration Complete
|
|
|
|
The worker consolidation is now complete. The Managing.Api project now contains all functionality previously split between the API and Workers projects, providing a more maintainable and efficient architecture.
|
|
|
|
**Deployment**: Use only the main API deployment scripts. The Workers project should not be deployed.
|