Shards will now show when they're unresponsive in .shardstats command
This commit is contained in:
parent
6b51dbd330
commit
9fddfe77c4
@ -12,5 +12,6 @@ namespace NadekoBot.DataStructures.ShardCom
|
|||||||
public int ShardId { get; set; }
|
public int ShardId { get; set; }
|
||||||
public ConnectionState ConnectionState { get; set; }
|
public ConnectionState ConnectionState { get; set; }
|
||||||
public int Guilds { get; set; }
|
public int Guilds { get; set; }
|
||||||
|
public DateTime Time { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -270,7 +270,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
add += Format.Bold(GetText("queue_stopped", Format.Code(Prefix + "play"))) + "\n";
|
add += Format.Bold(GetText("queue_stopped", Format.Code(Prefix + "play"))) + "\n";
|
||||||
var mps = mp.MaxPlaytimeSeconds;
|
var mps = mp.MaxPlaytimeSeconds;
|
||||||
if (mps > 0)
|
if (mps > 0)
|
||||||
add += Format.Bold(GetText("song_skips_after", TimeSpan.FromSeconds(mps).ToString("g"))) + "\n";
|
add += Format.Bold(GetText("song_skips_after", TimeSpan.FromSeconds(mps).ToString("HH\\:mm\\:ss"))) + "\n";
|
||||||
if (mp.RepeatCurrentSong)
|
if (mp.RepeatCurrentSong)
|
||||||
add += "🔂 " + GetText("repeating_cur_song") + "\n";
|
add += "🔂 " + GetText("repeating_cur_song") + "\n";
|
||||||
else if (mp.Shuffle)
|
else if (mp.Shuffle)
|
||||||
|
@ -295,8 +295,13 @@ namespace NadekoBot.Modules.Utility
|
|||||||
|
|
||||||
var allShardStrings = statuses
|
var allShardStrings = statuses
|
||||||
.Select(x =>
|
.Select(x =>
|
||||||
GetText("shard_stats_txt", x.ShardId.ToString(),
|
{
|
||||||
Format.Bold(x.ConnectionState.ToString()), Format.Bold(x.Guilds.ToString())))
|
var timeDiff = DateTime.UtcNow - x.Time;
|
||||||
|
if (timeDiff > TimeSpan.FromSeconds(20))
|
||||||
|
return $"Shard #{x.ShardId.ToString()} **UNRESPONSIVE** for {timeDiff.ToString(@"hh\:mm\:ss")}";
|
||||||
|
return GetText("shard_stats_txt", x.ShardId.ToString(),
|
||||||
|
Format.Bold(x.ConnectionState.ToString()), Format.Bold(x.Guilds.ToString()), timeDiff.ToString(@"hh\:mm\:ss"));
|
||||||
|
})
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
await Context.Channel.SendPaginatedConfirmAsync(_client, page, (curPage) =>
|
await Context.Channel.SendPaginatedConfirmAsync(_client, page, (curPage) =>
|
||||||
|
@ -130,8 +130,9 @@ namespace NadekoBot
|
|||||||
ConnectionState = Client.ConnectionState,
|
ConnectionState = Client.ConnectionState,
|
||||||
Guilds = Client.ConnectionState == ConnectionState.Connected ? Client.Guilds.Count : 0,
|
Guilds = Client.ConnectionState == ConnectionState.Connected ? Client.Guilds.Count : 0,
|
||||||
ShardId = Client.ShardId,
|
ShardId = Client.ShardId,
|
||||||
|
Time = DateTime.UtcNow,
|
||||||
});
|
});
|
||||||
await Task.Delay(1000);
|
await Task.Delay(5000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ using NadekoBot.Services;
|
|||||||
using NadekoBot.Services.Impl;
|
using NadekoBot.Services.Impl;
|
||||||
using NLog;
|
using NLog;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -21,7 +22,7 @@ namespace NadekoBot
|
|||||||
private readonly Logger _log;
|
private readonly Logger _log;
|
||||||
private readonly ShardComServer _comServer;
|
private readonly ShardComServer _comServer;
|
||||||
private readonly int _port;
|
private readonly int _port;
|
||||||
|
|
||||||
public ShardsCoordinator(int port)
|
public ShardsCoordinator(int port)
|
||||||
{
|
{
|
||||||
LogSetup.SetupLogger();
|
LogSetup.SetupLogger();
|
||||||
@ -40,6 +41,7 @@ namespace NadekoBot
|
|||||||
private Task _comServer_OnDataReceived(ShardComMessage msg)
|
private Task _comServer_OnDataReceived(ShardComMessage msg)
|
||||||
{
|
{
|
||||||
Statuses[msg.ShardId] = msg;
|
Statuses[msg.ShardId] = msg;
|
||||||
|
|
||||||
if (msg.ConnectionState == Discord.ConnectionState.Disconnected || msg.ConnectionState == Discord.ConnectionState.Disconnecting)
|
if (msg.ConnectionState == Discord.ConnectionState.Disconnected || msg.ConnectionState == Discord.ConnectionState.Disconnecting)
|
||||||
_log.Error("!!! SHARD {0} IS IN {1} STATE", msg.ShardId, msg.ConnectionState.ToString());
|
_log.Error("!!! SHARD {0} IS IN {1} STATE", msg.ShardId, msg.ConnectionState.ToString());
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
@ -87,7 +89,7 @@ namespace NadekoBot
|
|||||||
_log.Info(string.Join("\n", Statuses
|
_log.Info(string.Join("\n", Statuses
|
||||||
.ToArray()
|
.ToArray()
|
||||||
.Where(x => x != null)
|
.Where(x => x != null)
|
||||||
.Select(x => $"Shard {x.ShardId} is in {x.ConnectionState.ToString()} state with {x.Guilds} servers")) + "\n" + groupStr);
|
.Select(x => $"Shard {x.ShardId} is in {x.ConnectionState.ToString()} state with {x.Guilds} servers. {(DateTime.UtcNow - x.Time).ToString(@"hh\:mm\:ss")} ago")) + "\n" + groupStr);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -678,7 +678,7 @@
|
|||||||
"utility_server_info": "Server info",
|
"utility_server_info": "Server info",
|
||||||
"utility_shard": "Shard",
|
"utility_shard": "Shard",
|
||||||
"utility_shard_stats": "Shard stats",
|
"utility_shard_stats": "Shard stats",
|
||||||
"utility_shard_stats_txt": "Shard **#{0}** is in {1} state with {2} servers",
|
"utility_shard_stats_txt": "Shard **#{0}** is in {1} state with {2} servers - {3} ago",
|
||||||
"utility_showemojis": "**Name:** {0} **Link:** {1}",
|
"utility_showemojis": "**Name:** {0} **Link:** {1}",
|
||||||
"utility_showemojis_none": "No special emojis found.",
|
"utility_showemojis_none": "No special emojis found.",
|
||||||
"utility_stats_songs": "Playing {0} songs, {1} queued.",
|
"utility_stats_songs": "Playing {0} songs, {1} queued.",
|
||||||
|
Loading…
Reference in New Issue
Block a user