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)
|
IWorkerService workerService)
|
||||||
: BaseWorker<BotManagerWorker>(WorkerType.BotManager,
|
: BaseWorker<BotManagerWorker>(WorkerType.BotManager,
|
||||||
logger,
|
logger,
|
||||||
TimeSpan.FromMinutes(1),
|
TimeSpan.FromMinutes(5),
|
||||||
workerService)
|
workerService)
|
||||||
{
|
{
|
||||||
protected override async Task Run(CancellationToken cancellationToken)
|
protected override async Task Run(CancellationToken cancellationToken)
|
||||||
@@ -20,4 +20,4 @@ public class BotManagerWorker(
|
|||||||
var loadBackupBotCommand = new LoadBackupBotCommand();
|
var loadBackupBotCommand = new LoadBackupBotCommand();
|
||||||
await mediadior.Send(loadBackupBotCommand, cancellationToken);
|
await mediadior.Send(loadBackupBotCommand, cancellationToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
"Uri": "http://elasticsearch:9200/"
|
"Uri": "http://elasticsearch:9200/"
|
||||||
},
|
},
|
||||||
"Discord": {
|
"Discord": {
|
||||||
"BotActivity": "trading strategies",
|
"BotActivity": "with trading strategies",
|
||||||
"HandleUserAction": true,
|
"HandleUserAction": true,
|
||||||
"ApplicationId": "966075382002516031",
|
"ApplicationId": "966075382002516031",
|
||||||
"PublicKey": "63028f6bb740cd5d26ae0340b582dee2075624011b28757436255fc002ca8a7c",
|
"PublicKey": "63028f6bb740cd5d26ae0340b582dee2075624011b28757436255fc002ca8a7c",
|
||||||
|
|||||||
@@ -173,15 +173,21 @@ namespace Managing.Application.ManageBot
|
|||||||
return Enums.BotStatus.Down.ToString();
|
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);
|
_botRepository.DeleteBotBackup(botName);
|
||||||
return Task.FromResult(true);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Task.FromResult(false);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<string> RestartBot(string botName)
|
public Task<string> RestartBot(string botName)
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ namespace Managing.Domain.Bots
|
|||||||
{
|
{
|
||||||
Console.WriteLine(ex.Message);
|
Console.WriteLine(ex.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
ExecutionCount++;
|
ExecutionCount++;
|
||||||
await Task.Delay(Interval, CancellationToken.Token);
|
await Task.Delay(Interval, CancellationToken.Token);
|
||||||
if (CancellationToken.IsCancellationRequested)
|
if (CancellationToken.IsCancellationRequested)
|
||||||
@@ -54,7 +55,7 @@ namespace Managing.Domain.Bots
|
|||||||
public void Stop()
|
public void Stop()
|
||||||
{
|
{
|
||||||
Status = BotStatus.Down;
|
Status = BotStatus.Down;
|
||||||
//CancellationToken.Cancel();
|
CancellationToken.Cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Restart()
|
public void Restart()
|
||||||
|
|||||||
Reference in New Issue
Block a user