private static int Main2(string [] arguments) { Lock process_lock; ReportBuildBotStatusResponse status_response; BuildBotStatus status; try { if (!Configuration.LoadConfiguration(arguments)) { Logger.Log("Could not load configuration."); return(1); } if (!Configuration.VerifyBuildBotConfiguration()) { Logger.Log("Configuration verification failed."); return(1); } process_lock = Lock.Create("MonkeyWrench.Builder"); if (process_lock == null) { Logger.Log("Builder could not acquire lock. Exiting"); return(1); } Logger.Log("Builder lock aquired successfully."); } catch (Exception ex) { Logger.Log("Could not aquire lock: {0}", ex.Message); return(1); } try { WebService = WebServices.Create(); WebService.CreateLogin(Configuration.Host, Configuration.WebServicePassword); status = new BuildBotStatus(); status.Host = Configuration.Host; status.FillInAssemblyAttributes(); status_response = WebService.ReportBuildBotStatus(WebService.WebServiceLogin, status); if (status_response.Exception != null) { Logger.Log("Failed to report status: {0}", status_response.Exception.Message); return(1); } if (!string.IsNullOrEmpty(status_response.ConfiguredVersion) && status_response.ConfiguredVersion != status.AssemblyVersion) { if (!Update(status, status_response)) { Console.Error.WriteLine("Automatic update to: {0} / {1} failed (see log for details). Please update manually.", status_response.ConfiguredVersion, status_response.ConfiguredRevision); return(2); /* Magic return code that means "automatic update failed" */ } else { Console.WriteLine("The builder has been updated. Please run 'make build' again."); return(1); } } response = WebService.GetBuildInfoMultiple(WebService.WebServiceLogin, Configuration.Host, true); if (!response.Host.enabled) { Logger.Log("This host is disabled. Exiting."); return(0); } Logger.Log("Builder will now build {0} lists of work items.", response.Work.Count); for (int i = 0; i < response.Work.Count; i++) { //foreach (var item in response.Work) Logger.Log("Building list #{0}/{1}", i + 1, response.Work.Count); Build(response.Work [i]); //item); } Logger.Log("Builder finished successfully."); return(0); } catch (Exception ex) { Logger.Log("An exception occurred: {0}", ex.ToString()); return(1); } finally { process_lock.Unlock(); } }
public static bool ExecuteScheduler(bool forcefullupdate) { DateTime start; Lock scheduler_lock = null; List <DBLane> lanes; List <DBHost> hosts; List <DBHostLane> hostlanes; List <XmlDocument> reports; try { scheduler_lock = Lock.Create("MonkeyWrench.Scheduler"); if (scheduler_lock == null) { log.Info("Could not aquire scheduler lock."); return(false); } log.Info("Scheduler lock aquired successfully."); is_executing = true; start = DateTime.Now; // SVNUpdater.StartDiffThread (); // Check reports reports = GetReports(forcefullupdate); using (DB db = new DB(true)) { lanes = db.GetAllLanes(); hosts = db.GetHosts(); hostlanes = db.GetAllHostLanes(); log.InfoFormat("Updater will now update {0} lanes.", lanes.Count); GITUpdater git_updater = null; // SVNUpdater svn_updater = null; foreach (DBLane lane in lanes) { if (!lane.enabled) { log.InfoFormat("Schedule: lane {0} is disabled, skipping it.", lane.lane); continue; } SchedulerBase updater; switch (lane.source_control) { /* * case "svn": * if (svn_updater == null) * svn_updater = new SVNUpdater (forcefullupdate); * updater = svn_updater; * break; * */ case "git": if (git_updater == null) { git_updater = new GITUpdater(forcefullupdate); } updater = git_updater; break; default: log.ErrorFormat("Unknown source control: {0} for lane {1}", lane.source_control, lane.lane); continue; } updater.Clear(); updater.AddChangeSets(reports); updater.UpdateRevisionsInDB(db, lane, hosts, hostlanes); } AddRevisionWork(db, lanes, hostlanes); AddWork(db, hosts, lanes, hostlanes); CheckDependencies(db, hosts, lanes, hostlanes); } // SVNUpdater.StopDiffThread (); log.InfoFormat("Update finished successfully in {0} seconds.", (DateTime.Now - start).TotalSeconds); return(true); } catch (Exception ex) { log.ErrorFormat("An exception occurred: {0}", ex); return(false); } finally { if (scheduler_lock != null) { scheduler_lock.Unlock(); } is_executing = false; } }