public async Task <IActionResult> Enable(string id) { if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageTenants)) { return(Unauthorized()); } if (!IsDefaultShell()) { return(Unauthorized()); } var shellContext = _orchardHost .ListShellContexts() .OrderBy(x => x.Settings.Name) .Where(x => string.Equals(x.Settings.Name, id, StringComparison.OrdinalIgnoreCase)) .FirstOrDefault(); if (shellContext == null) { return(NotFound()); } var shellSettings = shellContext.Settings; if (shellSettings.State != TenantState.Disabled) { _notifier.Error(H["You can only enable a Disabled shell."]); } shellSettings.State = TenantState.Running; _orchardHost.UpdateShellSettings(shellSettings); return(RedirectToAction(nameof(Index))); }
/// <summary> /// Releases all shells so that new ones will be built for subsequent requests. /// Note: Can be used to free up resources after a given period of inactivity. /// </summary> public async static Task ReleaseAllShellContextsAsync(this IShellHost shellHost) { foreach (var shell in shellHost.ListShellContexts()) { await shellHost.ReleaseShellContextAsync(shell.Settings); } }
private IEnumerable <ShellContext> GetRunningShells() { return(_shellHost.ListShellContexts().Where(s => s.Settings.State == TenantState.Running && s.Pipeline != null).ToArray()); }