public IActionResult DownloadPackage([FromHeader] string authorization, string packageFileName) { if (string.IsNullOrWhiteSpace(packageFileName)) { return(BadRequest()); } EnsureGoodAuthorization(authorization); var list = Collector.GetAvailablePackageList(); var serviceInfo = list.FirstOrDefault(i => i.PackageFileName.Equals(packageFileName, StringComparison.InvariantCultureIgnoreCase)); if (serviceInfo == null) { return(NotFound($"this service name {packageFileName} does not exist")); } var palaceInfo = PalaceInfoManager.GetOrCreatePalaceInfo(HttpContext.GetUserAgent(), HttpContext.GetUserHostAddress()); if (serviceInfo.LockedBy != null && serviceInfo.LockedBy != palaceInfo.Key) { return(NoContent()); } var fileName = System.IO.Path.Combine(PalaceServerSettings.MicroServiceRepositoryFolder, packageFileName); var stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read); return(File(stream, "application/zip", packageFileName)); }
public IActionResult GetAction([FromHeader] string authorization, string serviceName) { EnsureGoodAuthorization(authorization); var palaceInfo = PalaceInfoManager.GetOrCreatePalaceInfo(HttpContext.GetUserAgent(), HttpContext.GetUserHostAddress()); var key = $"{palaceInfo.MachineName}.{palaceInfo.HostName}.{serviceName}".ToLower(); var svc = Collector.GetRunningList().FirstOrDefault(i => i.Key == key); if (svc == null) { return(Ok(new Models.NextActionResult { Action = Models.ServiceAction.DoNothing })); } var nextAction = svc.NextAction; if (nextAction != Models.ServiceAction.DoNothing) { Logger.LogInformation($"Action {nextAction} required for running service {serviceName} on {svc.Key}"); } var result = new Models.NextActionResult { Action = nextAction }; svc.NextAction = Models.ServiceAction.DoNothing; return(Ok(result)); }
public IActionResult GetConfiguration([FromHeader] string authorization) { EnsureGoodAuthorization(authorization); var palaceInfo = PalaceInfoManager.GetOrCreatePalaceInfo(HttpContext.GetUserAgent(), HttpContext.GetUserHostAddress()); if (palaceInfo == null) { return(NoContent()); } return(Ok(palaceInfo.MicroServiceSettingsList)); }
public IActionResult AddService([FromHeader] string authorization, Models.MicroServiceSettings serviceSettings) { EnsureGoodAuthorization(authorization); var palaceInfo = PalaceInfoManager.GetOrCreatePalaceInfo(HttpContext.GetUserAgent(), HttpContext.GetUserHostAddress()); if (palaceInfo == null) { return(NoContent()); } var result = PalaceInfoManager.SaveMicroServiceSettings(palaceInfo, serviceSettings); if (result.Count > 0) { BadRequest(result); } return(Ok()); }