public void GetBuildpack(StagingStartMessageRequest message, string gitPath, string buildpacksDir) { try { this.CreatePrison(); if (message.Properties.Buildpack != null) { Logger.Info("Staging task {0}: Downloading buildpack from {1}", this.Properties.TaskId, message.Properties.Buildpack); Directory.CreateDirectory(Path.Combine(this.Workspace.TempDir, "buildpacks")); string buildpackPath = Path.Combine(this.Workspace.TempDir, "buildpacks", Path.GetFileName(new Uri(message.Properties.Buildpack).LocalPath)); string command = string.Format("\"{0}\" clone --quiet --recursive {1} {2}", gitPath, message.Properties.Buildpack, buildpackPath); Logger.Debug(command); int success = Command.ExecuteCommand(command, this.Workspace.TempDir); if (success != 0) { throw new Exception(string.Format("Failed to git clone buildpack. Exit code: {0}", success)); } this.Buildpack = new Buildpack(buildpackPath, Path.Combine(this.Workspace.StagedDir, "app"), this.Workspace.Cache, this.Workspace.StagingLogPath); bool detected = this.Buildpack.Detect(this.Prison); if (!detected) { throw new Exception("Buildpack does not support this application."); } } else { Logger.Info("Staging task {0}: Detecting buildpack", this.Properties.TaskId); foreach (string dir in Directory.EnumerateDirectories(buildpacksDir)) { DEAUtilities.DirectoryCopy(dir, Path.Combine(this.Workspace.TempDir, "buildpack"), true); Buildpack bp = new Buildpack(Path.Combine(this.Workspace.TempDir, "buildpack"), Path.Combine(this.Workspace.StagedDir, "app"), this.Workspace.Cache, this.Workspace.StagingLogPath); bool success = bp.Detect(this.Prison); if (success) { this.Buildpack = bp; break; } else { Directory.Delete(Path.Combine(this.Workspace.TempDir, "buildpack"), true); } } if (this.Buildpack == null) { throw new Exception("Unable to detect a supported application type"); } Logger.Info("Staging task {0}: Detected buildpack {1}", this.Properties.TaskId, this.Buildpack.Name); } this.Properties.DetectedBuildpack = this.Buildpack.Name; } finally { if (this.Prison.Created) { this.Prison.Destroy(); } } }
private void Stage() { string appDir = Path.Combine(this.workspace.StagedDir, "app"); string logsDir = Path.Combine(this.workspace.StagedDir, "logs"); string tmpDir = Path.Combine(this.workspace.StagedDir, "tmp"); Directory.CreateDirectory(appDir); Directory.CreateDirectory(logsDir); Directory.CreateDirectory(tmpDir); DEAUtilities.DirectoryCopy(this.workspace.UnstagedDir, appDir, true); Buildpack buildpack = null; if (this.Message.Properties.Buildpack != null) { Logger.Info("Staging task {0}: Downloading buildpack from {1}", this.TaskId, this.Message.Properties.Buildpack); Directory.CreateDirectory(Path.Combine(this.workspace.TempDir, "buildpacks")); string buildpackPath = Path.Combine(this.workspace.TempDir, "buildpacks", Path.GetFileName(new Uri(this.Message.Properties.Buildpack).LocalPath)); string command = string.Format("\"{0}\" clone --recursive {1} {2}", this.gitExe, this.Message.Properties.Buildpack, buildpackPath); int success = Command.ExecuteCommand(command); if (success != 0) { throw new Exception("Failed to git clone buildpack"); } buildpack = new Buildpack(buildpackPath, appDir, this.workspace.Cache, this.workspace.StagingLogPath); bool detected = buildpack.Detect(this.prison); if (!detected) { throw new Exception("Buildpack does not support this application"); } } else { Logger.Info("Staging task {0}: Detecting buildpack", this.TaskId); foreach (string dir in Directory.EnumerateDirectories(this.buildpacksDir)) { Buildpack bp = new Buildpack(dir, appDir, this.workspace.Cache, this.workspace.StagingLogPath); bool success = bp.Detect(this.prison); if (success) { buildpack = bp; break; } } if (buildpack == null) { throw new Exception("Unable to detect a supported application type"); } Logger.Info("Staging task {0}: Detected buildpack {1}", this.TaskId, buildpack.Name); } Logger.Info("Staging task {0}: Running compilation script", this.TaskId); buildpack.Compile(this.prison, this.stagingTimeout); Logger.Info("Staging task {0}: Saving buildpackInfo", this.TaskId); StagingInfo.SaveBuildpackInfo(Path.Combine(this.workspace.StagedDir, StagingWorkspace.StagingInfo), buildpack.Name, GetStartCommand(buildpack)); }
private string GetStartCommand(Buildpack buildpack) { if (this.Message.Properties.Meta != null) { if (this.Message.Properties.Meta.Command != null) { return(this.Message.Properties.Meta.Command); } } ReleaseInfo info = buildpack.GetReleaseInfo(this.prison); if (info.defaultProcessType != null) { if (info.defaultProcessType.Web != null) { return(info.defaultProcessType.Web); } } throw new Exception("Please specify a web start command in your manifest.yml"); }
private string GetStartCommand(Buildpack buildpack) { if (this.Message.Properties.Meta != null) { if (this.Message.Properties.Meta.Command != null) { return this.Message.Properties.Meta.Command; } } ReleaseInfo info = buildpack.GetReleaseInfo(this.prison); if (info.defaultProcessType != null) { if (info.defaultProcessType.Web != null) { return info.defaultProcessType.Web; } } throw new Exception("Please specify a web start command in your manifest.yml"); }