Disable orleans reminder for deploy and add whitelisted addresses

This commit is contained in:
2025-08-15 16:48:23 +07:00
parent 54bf914e95
commit 0966eace58
12 changed files with 188 additions and 29 deletions

View File

@@ -238,7 +238,7 @@ builder.Services.AddScoped<IJwtUtils, JwtUtils>();
builder.Services.RegisterApiDependencies(builder.Configuration);
// Orleans Configuration
// Orleans is always configured, but grains can be controlled
builder.Host.ConfigureOrleans(builder.Configuration, builder.Environment.IsProduction());
builder.Services.AddEndpointsApiExplorer();

View File

@@ -0,0 +1,116 @@
# Orleans Configuration
This document explains how to configure Orleans usage in the Managing API.
## Overview
The Managing API now always runs Orleans for infrastructure, but supports configurable grain execution through the `RunOrleansGrains` configuration option. This allows you to control whether Orleans grains (bots, timers, reminders) are active during runtime.
## Configuration Options
### 1. Configuration File (appsettings.json)
Add the Orleans grain control parameter to your appsettings file:
```json
{
"RunOrleansGrains": true
}
```
- `RunOrleansGrains`: Boolean value that controls whether Orleans grains (bots, timers, reminders) are active
- `true` (default): Grains are active and can run timers/reminders
- `false`: Grains are inactive, no timers or reminders will execute
**Note**: Orleans infrastructure is always enabled and configured. This flag only controls grain execution.
### 2. Environment Variables
You can also control Orleans grain execution through environment variables:
```bash
# Enable Orleans grains (bots, timers, reminders)
export RUN_ORLEANS_GRAINS=true
# Disable Orleans grains (infrastructure still runs)
export RUN_ORLEANS_GRAINS=false
```
**Note**: Environment variables take precedence over configuration file settings.
## Configuration Files
The following configuration files have been updated with Orleans grain control settings:
- `appsettings.json` - Base configuration (RunOrleansGrains: true)
- `appsettings.Development.json` - Development configuration (RunOrleansGrains: false)
- `appsettings.Oda.json` - Oda environment (RunOrleansGrains: true)
- `appsettings.Oda-docker.json` - Oda Docker environment (RunOrleansGrains: true)
- `appsettings.Sandbox.json` - Sandbox environment (RunOrleansGrains: true)
- `appsettings.SandboxLocal.json` - Local Sandbox environment (RunOrleansGrains: true)
- `appsettings.Production.json` - Production environment (RunOrleansGrains: true)
## Use Cases
### Development Environment
- Set `RunOrleansGrains: false` to run Orleans infrastructure without active grains
- Useful for development and testing without bot execution overhead
### Testing Environment
- Set `RunOrleansGrains: false` to test Orleans infrastructure without running bots
- Useful for integration testing without triggering actual trading operations
### Production Environment
- Set `RunOrleansGrains: true` to enable full Orleans grain functionality
- Required for production trading bot operations
### Docker/Container Environment
- Use environment variables for easy configuration
- Example: `docker run -e RUN_ORLEANS_GRAINS=false ...`
## Implementation Details
The Orleans configuration is implemented in:
1. **ApiBootstrap.cs** - Orleans configuration logic
2. **Program.cs** - Application startup Orleans configuration
## Security Considerations
- Orleans configuration is not sensitive and can be included in configuration files
- Environment variables provide runtime flexibility without code changes
- Default behavior maintains backward compatibility (Orleans enabled by default)
## Troubleshooting
### Orleans Not Starting
1. Orleans infrastructure is always enabled
2. Ensure PostgreSQL connection string for Orleans is configured
3. Check application logs for connection errors
### Grains Not Running
1. Check `RunOrleansGrains` configuration value
2. Verify environment variable `RUN_ORLEANS_GRAINS` is not set to `false`
3. Ensure Orleans infrastructure is running properly
### Configuration Not Applied
1. Verify configuration file syntax
2. Check environment variable spelling (`RUN_ORLEANS_GRAINS`)
3. Restart the application after configuration changes
## Migration
Existing deployments will continue to work as Orleans grains are enabled by default. To control Orleans grain behavior:
### Disable Grains (Keep Orleans Infrastructure)
1. Add `"RunOrleansGrains": false` to your appsettings file, or
2. Set environment variable `RUN_ORLEANS_GRAINS=false`
### Development/Testing Setup
```json
{
"RunOrleansGrains": false
}
```
**Note**: Orleans infrastructure is always enabled and cannot be disabled.

View File

@@ -0,0 +1,9 @@
{
"RunOrleansGrains": false,
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@@ -30,5 +30,6 @@
"RequestsChannelId": 1018589494968078356,
"ButtonExpirationMinutes": 10
},
"RunOrleansGrains": true,
"AllowedHosts": "*"
}

View File

@@ -30,5 +30,6 @@
"RequestsChannelId": 1018589494968078356,
"ButtonExpirationMinutes": 2
},
"RunOrleansGrains": true,
"AllowedHosts": "*"
}

View File

@@ -37,6 +37,7 @@
"RequestsChannelId": 1018589494968078356,
"ButtonExpirationMinutes": 2
},
"RunOrleansGrains": true,
"AllowedHosts": "*",
"WorkerBotManager": true,
"WorkerBalancesTracking": false,

View File

@@ -30,6 +30,7 @@
"Sentry": {
"Dsn": "https://698e00d7cb404b049aff3881e5a47f6b@bugcenter.apps.managing.live/1"
},
"RunOrleansGrains": true,
"AllowedHosts": "*",
"WorkerBotManager": true,
"WorkerBalancesTracking": true,

View File

@@ -35,5 +35,6 @@
"Sentry": {
"Dsn": "https://698e00d7cb404b049aff3881e5a47f6b@bugcenter.apps.managing.live/1"
},
"RunOrleansGrains": true,
"AllowedHosts": "*"
}

View File

@@ -24,6 +24,7 @@
"ElasticConfiguration": {
"Uri": "http://elasticsearch:9200"
},
"RunOrleansGrains": true,
"AllowedHosts": "*",
"WorkerBotManager": false,
"WorkerBalancesTracking": false

View File

@@ -66,5 +66,6 @@
"FundingRateChannelId": 1263566138709774336,
"ButtonExpirationMinutes": 10
},
"RunOrleansGrains": true,
"AllowedHosts": "*"
}