fixes for global nadeko
This commit is contained in:
parent
8ceb6f5c46
commit
d91b7632f6
@ -5,9 +5,19 @@ namespace NadekoBot.Common.ShardCom
|
|||||||
{
|
{
|
||||||
public class ShardComMessage
|
public class ShardComMessage
|
||||||
{
|
{
|
||||||
|
|
||||||
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; }
|
public DateTime Time { get; set; }
|
||||||
|
|
||||||
|
public ShardComMessage Clone() =>
|
||||||
|
new ShardComMessage
|
||||||
|
{
|
||||||
|
ShardId = ShardId,
|
||||||
|
ConnectionState = ConnectionState,
|
||||||
|
Guilds = Guilds,
|
||||||
|
Time = Time,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,12 +97,17 @@ namespace NadekoBot.Core.Services
|
|||||||
_shardStartQueue.Enqueue(i);
|
_shardStartQueue.Enqueue(i);
|
||||||
#endif
|
#endif
|
||||||
//set the shard's initial state in redis cache
|
//set the shard's initial state in redis cache
|
||||||
_defaultShardState.ShardId = i;
|
var msg = _defaultShardState.Clone();
|
||||||
|
msg.ShardId = i;
|
||||||
//this is to avoid the shard coordinator thinking that
|
//this is to avoid the shard coordinator thinking that
|
||||||
//the shard is unresponsive while startup up
|
//the shard is unresponsive while startup up
|
||||||
_defaultShardState.Time = DateTime.UtcNow + TimeSpan.FromSeconds(45 * (i + 1));
|
var delay = 45;
|
||||||
|
#if GLOBAL_NADEKO
|
||||||
|
delay = 180;
|
||||||
|
#endif
|
||||||
|
msg.Time = DateTime.UtcNow + TimeSpan.FromSeconds(delay * (i + 1));
|
||||||
db.ListRightPush(_key + "_shardstats",
|
db.ListRightPush(_key + "_shardstats",
|
||||||
JsonConvert.SerializeObject(_defaultShardState),
|
JsonConvert.SerializeObject(msg),
|
||||||
flags: CommandFlags.FireAndForget);
|
flags: CommandFlags.FireAndForget);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,10 +146,11 @@ namespace NadekoBot.Core.Services
|
|||||||
private void OnStop(int shardId)
|
private void OnStop(int shardId)
|
||||||
{
|
{
|
||||||
var db = _redis.GetDatabase();
|
var db = _redis.GetDatabase();
|
||||||
_defaultShardState.ShardId = shardId;
|
var msg = _defaultShardState.Clone();
|
||||||
|
msg.ShardId = shardId;
|
||||||
db.ListSetByIndex(_key + "_shardstats",
|
db.ListSetByIndex(_key + "_shardstats",
|
||||||
shardId,
|
shardId,
|
||||||
JsonConvert.SerializeObject(_defaultShardState),
|
JsonConvert.SerializeObject(msg),
|
||||||
CommandFlags.FireAndForget);
|
CommandFlags.FireAndForget);
|
||||||
var p = _shardProcesses[shardId];
|
var p = _shardProcesses[shardId];
|
||||||
_shardProcesses[shardId] = null;
|
_shardProcesses[shardId] = null;
|
||||||
|
Loading…
Reference in New Issue
Block a user