Fix Backup and fix worker discord
This commit is contained in:
39
src/Managing.Api.Workers/appsettings.json
Normal file
39
src/Managing.Api.Workers/appsettings.json
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"ManagingDatabase": {
|
||||
"ConnectionString": "mongodb://managingdb",
|
||||
"DatabaseName": "ManagingDb"
|
||||
},
|
||||
"InfluxDb": {
|
||||
"Url": "http://influxdb:8086/",
|
||||
"Organization": "",
|
||||
"Token": ""
|
||||
},
|
||||
"Serilog": {
|
||||
"MinimumLevel": {
|
||||
"Default": "Information",
|
||||
"Override": {
|
||||
"Microsoft": "Information",
|
||||
"System": "Warning"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ElasticConfiguration": {
|
||||
"Uri": "http://elasticsearch:9200"
|
||||
},
|
||||
"Discord": {
|
||||
"BotActivity": "with jobs",
|
||||
"HandleUserAction": true,
|
||||
"ApplicationId": "1132062339592622221",
|
||||
"PublicKey": "e422f3326307788608eceba919497d3f2758cc64d20bb8a6504c695192404808",
|
||||
"TokenId": "MTEzMjA2MjMzOTU5MjYyMjIyMQ.GySuNX.rU-9uIX6-yDthBjT_sbXioaJGyJva2ABNNEaj4",
|
||||
"SignalChannelId": 966080506473099314,
|
||||
"TradesChannelId": 998374177763491851,
|
||||
"TroublesChannelId": 1015761955321040917,
|
||||
"CopyTradingChannelId": 1132022887012909126,
|
||||
"RequestsChannelId": 1018589494968078356,
|
||||
"FundingRateChannelId": 1263566138709774336,
|
||||
"LeaderboardChannelId": 1133169725237633095,
|
||||
"ButtonExpirationMinutes": 10
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
@@ -12,7 +12,7 @@ public class BotManagerWorker(
|
||||
IWorkerService workerService)
|
||||
: BaseWorker<BotManagerWorker>(WorkerType.BotManager,
|
||||
logger,
|
||||
TimeSpan.FromMinutes(1),
|
||||
TimeSpan.FromMinutes(5),
|
||||
workerService)
|
||||
{
|
||||
protected override async Task Run(CancellationToken cancellationToken)
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
"Uri": "http://elasticsearch:9200/"
|
||||
},
|
||||
"Discord": {
|
||||
"BotActivity": "trading strategies",
|
||||
"BotActivity": "with trading strategies",
|
||||
"HandleUserAction": true,
|
||||
"ApplicationId": "966075382002516031",
|
||||
"PublicKey": "63028f6bb740cd5d26ae0340b582dee2075624011b28757436255fc002ca8a7c",
|
||||
|
||||
@@ -173,15 +173,21 @@ namespace Managing.Application.ManageBot
|
||||
return Enums.BotStatus.Down.ToString();
|
||||
}
|
||||
|
||||
public Task<bool> DeleteBot(string botName)
|
||||
public async Task<bool> DeleteBot(string botName)
|
||||
{
|
||||
if (_botTasks.TryRemove(botName, out _))
|
||||
if (_botTasks.TryRemove(botName, out var botWrapper))
|
||||
{
|
||||
_botRepository.DeleteBotBackup(botName);
|
||||
return Task.FromResult(true);
|
||||
if (botWrapper.BotInstance is IBot bot)
|
||||
{
|
||||
await Task.Run(() =>
|
||||
bot.Stop()); // Assuming Stop is an asynchronous process wrapped in Task.Run for synchronous methods
|
||||
}
|
||||
|
||||
return Task.FromResult(false);
|
||||
_botRepository.DeleteBotBackup(botName);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public Task<string> RestartBot(string botName)
|
||||
|
||||
@@ -43,6 +43,7 @@ namespace Managing.Domain.Bots
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
}
|
||||
|
||||
ExecutionCount++;
|
||||
await Task.Delay(Interval, CancellationToken.Token);
|
||||
if (CancellationToken.IsCancellationRequested)
|
||||
@@ -54,7 +55,7 @@ namespace Managing.Domain.Bots
|
||||
public void Stop()
|
||||
{
|
||||
Status = BotStatus.Down;
|
||||
//CancellationToken.Cancel();
|
||||
CancellationToken.Cancel();
|
||||
}
|
||||
|
||||
public void Restart()
|
||||
|
||||
Reference in New Issue
Block a user