mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-04 22:09:40 +00:00
Add enterprise config support via env vars & Windows registry (#491)
This commit is contained in:
1 parent
b88b78a08e
commit
e8cfce05fe
33 files changed
+1061
-98
No files matched your search
@@ -15,32 +15,11 @@ public static partial class PluginFactory
|
||||
LOG.LogInformation($"Start hot reloading plugins for path '{HOT_RELOAD_WATCHER.Path}'.");
|
||||
try
|
||||
{
|
||||
var messageBus = Program.SERVICE_PROVIDER.GetRequiredService<MessageBus>();
|
||||
|
||||
HOT_RELOAD_WATCHER.IncludeSubdirectories = true;
|
||||
HOT_RELOAD_WATCHER.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName;
|
||||
HOT_RELOAD_WATCHER.Filter = "*.lua";
|
||||
HOT_RELOAD_WATCHER.Changed += async (_, args) =>
|
||||
{
|
||||
var changeType = args.ChangeType.ToString().ToLowerInvariant();
|
||||
if (!await HOT_RELOAD_SEMAPHORE.WaitAsync(0))
|
||||
{
|
||||
LOG.LogInformation($"File changed ({changeType}): {args.FullPath}. Already processing another change.");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
LOG.LogInformation($"File changed ({changeType}): {args.FullPath}. Reloading plugins...");
|
||||
await LoadAll();
|
||||
await messageBus.SendMessage<bool>(null, Event.PLUGINS_RELOADED);
|
||||
}
|
||||
finally
|
||||
{
|
||||
HOT_RELOAD_SEMAPHORE.Release();
|
||||
}
|
||||
};
|
||||
|
||||
HOT_RELOAD_WATCHER.Changed += HotReloadEventHandler;
|
||||
HOT_RELOAD_WATCHER.Deleted += HotReloadEventHandler;
|
||||
HOT_RELOAD_WATCHER.EnableRaisingEvents = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -52,4 +31,32 @@ public static partial class PluginFactory
|
||||
LOG.LogInformation("Hot reloading plugins set up.");
|
||||
}
|
||||
}
|
||||
|
||||
private static async void HotReloadEventHandler(object _, FileSystemEventArgs args)
|
||||
{
|
||||
try
|
||||
{
|
||||
var changeType = args.ChangeType.ToString().ToLowerInvariant();
|
||||
if (!await HOT_RELOAD_SEMAPHORE.WaitAsync(0))
|
||||
{
|
||||
LOG.LogInformation($"File changed ({changeType}): {args.FullPath}. Already processing another change.");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
LOG.LogInformation($"File changed ({changeType}): {args.FullPath}. Reloading plugins...");
|
||||
await LoadAll();
|
||||
await MessageBus.INSTANCE.SendMessage<bool>(null, Event.PLUGINS_RELOADED);
|
||||
}
|
||||
finally
|
||||
{
|
||||
HOT_RELOAD_SEMAPHORE.Release();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOG.LogError(e, $"Error while handling hot reload event for file '{args.FullPath}' with change type '{args.ChangeType}'.");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user