internal static void Main(string[] args) { if (args.Length > 0 && (args[0].ToLower() == "-console" || args[0].ToLower() == "-c")) { System.Console.WriteLine("---------------------------------------------------------------------------"); System.Console.WriteLine("BITS State Manager"); System.Console.WriteLine("Started at [" + System.DateTime.Now.ToLongTimeString() + "]"); System.Console.WriteLine("---------------------------------------------------------------------------"); _service = new StateManagerService(); _service.Start(args); Console.WriteLine("Waiting for tasks, press enter to stop service..."); Console.ReadLine(); Console.WriteLine("Service stopping..."); _service.StopService(); Console.WriteLine("Service stopped."); } else { // setup the working directory so that edit can find the channels files System.Environment.CurrentDirectory = System.AppDomain.CurrentDomain.BaseDirectory; // kick off the service code System.ServiceProcess.ServiceBase[] ServicesToRun; ServicesToRun = new System.ServiceProcess.ServiceBase[] { new StateManagerService() }; System.ServiceProcess.ServiceBase.Run(ServicesToRun); } }
public static void Startup(string[] args) { if (args.Length > 0 && (args[0].ToLower() == "-console" || args[0].ToLower() == "-c")) { isConsole = true; } else if (args.Length > 0 && (args[0].ToLower() == "-test")) { isRegressionTest = true; } log.Info("---------------------------------------------------------------------------"); log.Info("BITS Shell"); log.Info("Started at [" + System.DateTime.Now.ToLongTimeString() + "]"); log.Info("---------------------------------------------------------------------------"); log.Info("Loading configuration..."); try { ConfigUtils.GlobalConfig = (GlobalConfigDetails)ConfigurationManager.GetSection("BitsConfig"); GetCentralConfig(ref ConfigUtils.GlobalConfig); GetNbConfig(); log.Info("Initializing persistence layer..."); Repository.SetFactory(new LocalRepositoryFactory()); Repository.SetContext(new ContextUser()); } catch (Exception ex) { log.Error(ex); log.ErrorFormat("Terminating..."); return; } log.Info("Starting dependent service(s)..."); fileManagerService = new FileManagerService(); timeManagerService = new TimeManagerService(); stateManagerService = new StateManagerService(); datamonitorManager = DataMonitorManager.InstanceOf(ConfigUtils.GlobalConfig); if (isConsole) { IFlatFileLoader ffLoader = fileManagerService.Start(args, ConfigUtils.GlobalConfig); ITimeManager tManager = timeManagerService.Start(args, ConfigUtils.GlobalConfig); if (StateManagerService.Start(args, ffLoader, tManager, datamonitorManager)) { Console.WriteLine("Waiting for tasks, press enter to stop service..."); Console.ReadLine(); Console.WriteLine("Service stopping..."); } try { StopFileManagerService(); StopTimeManagerService(); StopStateManagerService(); StopDataMonitorService(); } catch (Exception ex) { log.Error(ex); } Console.WriteLine("Service stopped."); } else if (isRegressionTest) { //ScheduledJobsTest test = new ScheduledJobsTest(); //test.RunAllScheduledJobs(); } else { bitsShellService = new BitsShellService(); ServiceBase.Run(bitsShellService); } }