mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-04-28 15:39:46 +00:00
Improve hot reload logic with enhanced logging and semaphore management
This commit is contained in:
parent
a3a1483c84
commit
2492a588b7
@ -22,15 +22,23 @@ public static partial class PluginFactory
|
|||||||
HOT_RELOAD_WATCHER.Filter = "*.lua";
|
HOT_RELOAD_WATCHER.Filter = "*.lua";
|
||||||
HOT_RELOAD_WATCHER.Changed += async (_, args) =>
|
HOT_RELOAD_WATCHER.Changed += async (_, args) =>
|
||||||
{
|
{
|
||||||
|
var changeType = args.ChangeType.ToString().ToLowerInvariant();
|
||||||
if (!await HOT_RELOAD_SEMAPHORE.WaitAsync(0))
|
if (!await HOT_RELOAD_SEMAPHORE.WaitAsync(0))
|
||||||
{
|
{
|
||||||
LOG.LogInformation($"File changed ({args.ChangeType}): {args.FullPath}. Already processing another change.");
|
LOG.LogInformation($"File changed ({changeType}): {args.FullPath}. Already processing another change.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG.LogInformation($"File changed ({args.ChangeType}): {args.FullPath}. Reloading plugins...");
|
try
|
||||||
|
{
|
||||||
|
LOG.LogInformation($"File changed ({changeType}): {args.FullPath}. Reloading plugins...");
|
||||||
await LoadAll();
|
await LoadAll();
|
||||||
await messageBus.SendMessage<bool>(null, Event.PLUGINS_RELOADED);
|
await messageBus.SendMessage<bool>(null, Event.PLUGINS_RELOADED);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
HOT_RELOAD_SEMAPHORE.Release();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
HOT_RELOAD_WATCHER.EnableRaisingEvents = true;
|
HOT_RELOAD_WATCHER.EnableRaisingEvents = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user