public Package CreatePackage(Application application, Core.Package source) { IEnumerable <Package> existingPackages = this.GetPackages(application); PackageContent packageContentInfo; try { packageContentInfo = this.ExtractPackageInfo(source); } catch (AppServerException ex) { Logger.Warn(this, ex, "Unable to extract package info"); throw new InvalidOperationException(ex.Message); } Package package = new Package { Version = Version.Parse(packageContentInfo.Bootstrapper.Assembly.Version) }; Logger.Info(this, "Detected package version = " + package.Version); if (existingPackages.Any(p => p.Version == package.Version)) { throw new InvalidOperationException("Application " + application.Name + " already has a package with version " + package.Version.ToString(4)); } package.Application = application; package.File = Path.Combine(this.RootFolder, application.Name, package.Version.ToString(4), source.Source); package.Directory = Path.GetDirectoryName(package.File); source.SaveAs(package.File); return(package); }
protected void Update(Package package) { Logger.Info(this, "Updating " + this._application.Name + "..."); this._application.Stop().Wait(); this._application.Unload().Wait(); this._application.Deploy(package).Wait(); this._application.ReStart().Wait(); Logger.Info(this, "Update complete"); }
public ActionResult AddSubmit(PackageAddModel model) { if (model.File != null && model.File.ContentLength > 0) { Logger.Info(this, "Received package upload " + model.File.FileName); Core.Package package = BytePackage.Create(model.File.InputStream.ReadAllBytes(), model.File.FileName); Persistence.Application fileSystemApplication = this._repository.GetApplication(model.Application); this._repository.CreatePackage(fileSystemApplication, package); } return(this.RedirectToAction("List", new { application = model.Application })); }
public PackageContent ExtractPackageInfo(Core.Package package) { string tempPath = Path.Combine(this.TempFolder, Guid.NewGuid().ToString("N").ToUpper()); package.Extract(tempPath); AppDomain tempDomain = ReflectionHelper.LoadAppDomain(tempPath, new Uri(this.GetType().Assembly.CodeBase).LocalPath); try { object handle; try { handle = tempDomain.CreateInstanceAndUnwrap(typeof(PackageScanner).Assembly.GetName().Name, typeof(PackageScanner).FullName); } catch (FileNotFoundException) { throw new AppServerException("Package does not contain required assembly " + typeof(PackageScanner).Assembly.Name()); } PackageScanner scanner = handle as PackageScanner; if (scanner == null) { throw new Exception("Could not load package scanner"); } PackageContent info = scanner.Run(); Logger.Info(this, "Scanner found " + info.Bootstrappers.Count + " bootstrapper(s) and " + info.Updaters.Count + " updater(s)"); string manifestFile = Path.Combine(tempPath, "manifest.xml"); if (File.Exists(manifestFile)) { Logger.Debug(this, "Loading package manifest " + manifestFile + "..."); try { using (FileStream stream = File.Open(manifestFile, FileMode.Open, FileAccess.Read)) { info.Manifest = XmlSerializer.Deserialize <Manifest>(stream); Logger.Debug(this, "Manifest loaded"); } } catch (Exception ex) { Logger.Error("Failed to load manifest: " + ex.Message); } } else { Logger.Debug(this, "Package contains no manifest"); } return(info); } finally { AppDomain.Unload(tempDomain); try { Directory.Delete(tempPath, true); } catch (Exception ex) { Logger.Warn(this, "Failed to remove temp folder " + tempPath + ": " + ex.Message); } } }
private void PackageManager_PackageAwaitingRestart(PackageManager sender, Package target) { if (this.IsLoggedIn == true && this.m_blEventsEnabled == true) { this.Game.SendRequest("procon.packages.onInstalled", target.Uid, Packet.bltos(true)); } }
private void PackageManager_PackageInstalling(PackageManager sender, Package target) { if (this.IsLoggedIn == true && this.m_blEventsEnabled == true) { this.Game.SendRequest("procon.packages.onInstalling", target.Uid); } }
private void PackageManager_PackageDownloadFail(PackageManager sender, Package target) { if (this.IsLoggedIn == true && this.m_blEventsEnabled == true) { this.Game.SendRequest("procon.packages.onDownloadError", target.Uid, target.Error); } }
private void PackageManager_PackageBeginningDownload(PackageManager sender, Package target) { if (this.IsLoggedIn == true && this.m_blEventsEnabled == true) { this.Game.SendRequest("procon.packages.onDownloading", target.Uid); } }
/// <summary> /// The physical moving of files in a <see cref="Package"/> to a location from where they can be executed. /// </summary> /// <param name="package"></param> /// <returns></returns> public Task Deploy(Package package) { return (this._server.Run(() => { // TODO [SAR] potential dead lock with the server action queue, is this lock required? lock(this._lock) { Logger.Info(this, "Deploying package from " + package.Source + "..."); this._deployment = new Deployment { PackageContent = this._packageRepository.ExtractPackageInfo(package) }; this._deployment.BinFolder = Path.Combine(this._context.AppFolder, this.Name, "bin", this._deployment.PackageContent.Bootstrapper.Assembly.Version); this._deployment.SettingsFolder = Path.Combine(this._context.AppFolder, this.Name, "conf"); package.Deploy(this._deployment); string deploymentInfoPath = Path.Combine(this._deployment.BinFolder, "deployment.info"); using(FileStream stream = File.Create(deploymentInfoPath)) { XmlSerializer.Serialize(this._deployment, stream, new NamespaceMapping { Prefix = "", Namespace = Serialization.NAMESPACE }); Logger.Info(this, "Saved deployment info to " + deploymentInfoPath); } this.RunUpdates(); this.Load(); Logger.Info(this, "Package deployed"); } })); }