Plugins - Added timeout for plugin enable

Plugins - Delete lock file even on exception, only leave it in place on crash
Plugins - Added --ignore-plugin-lock startup argument
UI - Renamed -autorun argument to --autorun
This commit is contained in:
SpoinkyNL committed 2020-06-29 23:24:49 +02:00
1 parent 40eda4fc2b
commit ac45c4d5d3
11 files changed
+56 -27

No files matched your search

+2 -1
View File
@@ -63,6 +63,7 @@ namespace Artemis.Core.Services
public TimeSpan FrameTime { get; private set; }
public bool PluginUpdatingDisabled { get; set; }
public bool ModuleRenderingDisabled { get; set; }
public List<string> StartupArguments { get; set; }
public void Dispose()
{
@@ -83,7 +84,7 @@ namespace Artemis.Core.Services
// Initialize the services
_pluginService.CopyBuiltInPlugins();
_pluginService.LoadPlugins();
_pluginService.LoadPlugins(StartupArguments.Contains("--ignore-plugin-lock"));
var surfaceConfig = _surfaceService.ActiveSurface;
if (surfaceConfig != null)
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using Artemis.Core.Events;
namespace Artemis.Core.Services.Interfaces
@@ -25,6 +26,11 @@ namespace Artemis.Core.Services.Interfaces
/// </summary>
bool ModuleRenderingDisabled { get; set; }
/// <summary>
/// Gets or sets a list of startup arguments
/// </summary>
List<string> StartupArguments { get; set; }
/// <summary>
/// Initializes the core, only call once
/// </summary>
@@ -23,7 +23,7 @@ namespace Artemis.Core.Services.Interfaces
/// <summary>
/// Loads all installed plugins. If plugins already loaded this will reload them all
/// </summary>
void LoadPlugins();
void LoadPlugins(bool ignorePluginLock);
/// <summary>
/// Unloads all installed plugins.
+7 -14
View File
@@ -107,8 +107,7 @@ namespace Artemis.Core.Services
}
}
/// <inheritdoc />
public void LoadPlugins()
public void LoadPlugins(bool ignorePluginLock)
{
if (LoadingPlugins)
throw new ArtemisCoreException("Cannot load plugins while a previous load hasn't been completed yet.");
@@ -150,7 +149,7 @@ namespace Artemis.Core.Services
{
try
{
EnablePlugin(pluginInfo.Instance, true);
EnablePlugin(pluginInfo.Instance, !ignorePluginLock);
}
catch (Exception)
{
@@ -305,13 +304,13 @@ namespace Artemis.Core.Services
{
// On an auto-enable, ensure PluginInfo.Enabled is true even if enable failed, that way a failure on auto-enable does
// not affect the user's settings
if (isAutoEnable)
if (isAutoEnable)
plugin.PluginInfo.Enabled = true;
plugin.PluginInfo.ApplyToEntity();
_pluginRepository.SavePlugin(plugin.PluginInfo.PluginEntity);
if (plugin.PluginInfo.Enabled)
if (plugin.PluginInfo.Enabled)
_logger.Debug("Successfully enabled plugin {pluginInfo}", plugin.PluginInfo);
}
}
@@ -351,10 +350,7 @@ namespace Artemis.Core.Services
/// <inheritdoc />
public PluginInfo GetPluginInfo(Plugin plugin)
{
lock (_plugins)
{
return _plugins.FirstOrDefault(p => p.Instance == plugin);
}
return _plugins.FirstOrDefault(p => p.Instance == plugin);
}
/// <inheritdoc />
@@ -366,10 +362,7 @@ namespace Artemis.Core.Services
/// <inheritdoc />
public List<T> GetPluginsOfType<T>() where T : Plugin
{
lock (_plugins)
{
return _plugins.Where(p => p.Enabled && p.Instance is T).Select(p => (T) p.Instance).ToList();
}
return _plugins.Where(p => p.Enabled && p.Instance is T).Select(p => (T) p.Instance).ToList();
}
public Plugin GetDevicePlugin(IRGBDevice rgbDevice)
@@ -393,7 +386,7 @@ namespace Artemis.Core.Services
Directory.CreateDirectory(pluginDirectory.FullName);
builtInPluginDirectory.CopyFilesRecursively(pluginDirectory);
if (createLockFile)
if (createLockFile)
File.Create(Path.Combine(pluginDirectory.FullName, "artemis.lock")).Close();
}