/// <summary> /// Grab the deployers for an application /// </summary> /// <returns></returns> public DeployerCollection GrabDeployers(ILoggerInterface logger) { Dictionary <string, Type> deployerTypes = new Dictionary <string, Type>() { { "php", typeof(Php.PhpDeployer) }, { "iis", typeof(IIS.IISDeployer) }, { "app", typeof(Storage.AppBaseStorageDeployer) }, }; var deployers = new DeployerCollection(this.globalSettings, this, logger, this.parentInstalledApplicationSettings); foreach (var d in this.appSettings.getDeployers()) { var type = (string)d.Value["type"]; if (type == null || !deployerTypes.ContainsKey(type)) { throw new Exception($"Deployer type '{type}' not found."); } Type deployertype = deployerTypes[type]; deployers.AddItem(deployertype, (JObject)d.Value); } return(deployers); }
public DeployerCollection GrabServices(ILoggerInterface logger) { Dictionary <string, Type> serviceTypes = new Dictionary <string, Type>() { { "sqlsrv", typeof(Services.SQLService) }, { "disk", typeof(Services.DiskService) }, { "couchbase", typeof(Services.CouchbaseService) }, { "scheduler", typeof(Services.ScheduleService) } }; var services = new DeployerCollection(this.globalSettings, this, logger, this.parentInstalledApplicationSettings); foreach (var d in this.appSettings.getServices()) { var type = (string)d.Value["type"]; if (!serviceTypes.ContainsKey(type)) { throw new Exception("Service type not found:" + type); } Type serviceType = serviceTypes[type]; services.AddItem(serviceType, (JObject)d.Value); } return(services); }
/// <summary> /// Uninstalls and APP and removes all services and deployments. /// </summary> /// <param name="force">If set to true, will force removal even if there are partial failures.</param> public void UninstallApp(bool force = true) { this.Logger.LogInfo(false, "UninstallApp: " + this.DeploymentActive.getShortId()); DeployerCollection deployers = null; DeployerCollection services = null; try { deployers = this.DeploymentActive.GrabDeployers(this.Logger); } catch (Exception e0) { if (!force) { throw; } } try { services = this.DeploymentActive.GrabServices(this.Logger); } catch (Exception e0) { if (!force) { throw; } } try { // We need to stop prior to removing... deployers?.StopAll(); services?.StopAll(); // Cleanup previous environments deployers?.UndeployAll(true, true); services?.UndeployAll(true, true); // Remove File.Delete(this.activeDeploymentPathStorage); } catch (Exception e) { if (force) { this.Logger.LogException(new Exception("An issue was found during application removal. But still application has been uninstalled by using the -force option.", e)); File.Delete(this.activeDeploymentPathStorage); } else { throw; } } }