/// <summary> /// Initializes the instance of the <see cref="QuartzServer" /> class. /// </summary> public virtual void Initialize(string angularFolder, string envName) { try { XTradeConfig config = Program.Container.Resolve <XTradeConfig>(); xtradeServer = Program.Container.Resolve <IMainService>(); xtradeServer.Init(Program.Container); Log.Info(String.Format("Inited with AngularFolder: {0}, Env: {1}", angularFolder, envName)); } catch (Exception e) { Log.Error("Server initialization failed:" + e.Message, e); throw; } }
public virtual bool Initialize() { log.Info("------- Initializing Scheduler -------------------"); try { XTradeConfig config = MainService.thisGlobal.Container.Resolve <XTradeConfig>(); var properties = config.Quartz(); // First we must get a reference to a scheduler sf = new StdSchedulerFactory(properties); sched = sf.GetScheduler().Result; // All of the jobs have been added to the scheduler, but none of the jobs // will run until the scheduler has been started sched.Start(); while (!sched.IsStarted) { log.Info("Waiting for scheduler to start."); Thread.Sleep(1000); } log.Info("IsStarted=" + sched.IsStarted); log.Info("InstanceId=" + sched.SchedulerInstanceId); log.Info("SchedulerName=" + sched.SchedulerName); SchedulerMetaData metadata = sched.GetMetaData().Result; log.Info("IS REMOTE (CLUSTERED )=" + metadata.SchedulerRemote); isClustered = metadata.SchedulerRemote; RunJobSupervisor(); } catch (Exception ex) { log.Error("Error Initializing Scheduler: " + ex.Message); bInitialized = false; return(bInitialized); } bInitialized = true; return(bInitialized); }
/// <summary> /// Main. /// </summary> public static void Main() { XmlConfigurator.Configure(); RegisterContainer(); var rc = HostFactory.Run(x => { x.SetDescription(Configuration.ServiceDescription); x.SetDisplayName(Configuration.ServiceDisplayName); x.SetServiceName(Configuration.ServiceName); x.RunAsLocalSystem(); //x.RunAsLocalService(); //x.RunAsNetworkService(); //if (Environment.UserInteractive && System.Diagnostics.Debugger.IsAttached) //{ // x.Service<QuartzServer>(factory => // { // factory.ConstructUsing(name => Container.Resolve<QuartzServer>()); // factory.WhenStarted(tc => tc.Start()); // factory.WhenStopped(tc => tc.Stop()); // }); //} else //{ x.Service(factory => { var server = Container.Resolve <QuartzServer>(); server.Initialize(XTradeConfig.WebPort()); //server.Start(); return(server); }); //} }); var exitCode = (int)Convert.ChangeType(rc, rc.GetTypeCode()); Environment.ExitCode = exitCode; }
public QuartzServer() { Initialize(XTradeConfig.WebPort()); }