Fix Backup and fix worker discord

This commit is contained in:
2024-07-22 03:20:13 +07:00
parent 3360e48f47
commit ab621554ce
5 changed files with 54 additions and 8 deletions

View 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": "*"
}

View File

@@ -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)
@@ -20,4 +20,4 @@ public class BotManagerWorker(
var loadBackupBotCommand = new LoadBackupBotCommand();
await mediadior.Send(loadBackupBotCommand, cancellationToken);
}
}
}

View File

@@ -34,7 +34,7 @@
"Uri": "http://elasticsearch:9200/"
},
"Discord": {
"BotActivity": "trading strategies",
"BotActivity": "with trading strategies",
"HandleUserAction": true,
"ApplicationId": "966075382002516031",
"PublicKey": "63028f6bb740cd5d26ae0340b582dee2075624011b28757436255fc002ca8a7c",

View File

@@ -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))
{
if (botWrapper.BotInstance is IBot bot)
{
await Task.Run(() =>
bot.Stop()); // Assuming Stop is an asynchronous process wrapped in Task.Run for synchronous methods
}
_botRepository.DeleteBotBackup(botName);
return Task.FromResult(true);
return true;
}
return Task.FromResult(false);
return false;
}
public Task<string> RestartBot(string botName)

View File

@@ -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()