/// <summary> /// Starts the service using the specified options. /// </summary> /// <param name="options">The configuration options.</param> public virtual void Start(ServiceElement options) { if (options == null) { throw new ArgumentNullException("options"); } this.localIP = NetworkInterface.GetLocalIPAddress(options.LocalRoute); Logger.Info(Strings.InitializingLogMessage, this.ServiceDescription()); this.nodeNats = ReactorFactory.GetReactor(typeof(Reactor)); this.nodeNats.OnError += new EventHandler <ReactorErrorEventArgs>(this.NatsErrorHandler); this.nodeNats.Start(new Uri(options.MBus)); this.OnConnectNode(); this.vcapComponent = new VCAPComponent(); this.vcapComponent.Register( new Dictionary <string, object> { { "nats", this.nodeNats }, { "type", this.ServiceDescription() }, { "host", this.localIP }, { "index", options.Index }, { "config", options }, { "statusPort", options.StatusPort } }); int zInterval = options.ZInterval; TimerHelper.RecurringCall( zInterval, delegate { this.UpdateVarz(); }); // give service a chance to wake up TimerHelper.DelayedCall( 5 * 1000, delegate { this.UpdateVarz(); }); }
/// <summary> /// Releases unmanaged and - optionally - managed resources /// </summary> /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param> protected virtual void Dispose(bool disposing) { if (disposing) { if (this.nodeNats != null) { this.nodeNats.Dispose(); this.nodeNats = null; } if (this.vcapComponent != null) { this.vcapComponent.Dispose(); this.vcapComponent = null; } } }
/// <summary> /// Starts the service using the specified options. /// </summary> /// <param name="options">The configuration options.</param> public virtual void Start(Options options) { if (options == null) { throw new ArgumentNullException("options"); } this.localIP = NetworkInterface.GetLocalIPAddress(); Logger.Info(Strings.InitializingLogMessage, this.ServiceDescription()); this.OrphanInstancesHash = new Dictionary<string, object>(); this.OrphanBindingHash = new Dictionary<string, object>(); this.nodeNats = ReactorFactory.GetReactor(typeof(Reactor)); this.nodeNats.OnError += new EventHandler<ReactorErrorEventArgs>(this.NatsErrorHandler); this.NodeNats.Start(options.Uri); this.OnConnectNode(); this.vcapComponent = new VCAPComponent(); this.vcapComponent.Register( new Dictionary<string, object> { { "nats", this.NodeNats }, { "type", this.ServiceDescription() }, { "host", this.localIP }, { "index", options.Index }, { "config", options }, { "statusPort", options.StatusPort } }); int zInterval = options.ZInterval; // give service a chance to wake up TimerHelper.DelayedCall( 5000, delegate { this.UpdateVarz(); }); TimerHelper.RecurringCall( zInterval, delegate { this.UpdateVarz(); }); // give service a chance to wake up TimerHelper.DelayedCall( 5000, delegate { this.UpdateHealthz(); }); TimerHelper.RecurringCall( zInterval, delegate { this.UpdateHealthz(); }); }