public Watcher(DaemonConfiguration configuration, IBus bus) { Configuration = configuration.BootStrapConfiguration; SystemObservers = new List <IDisposable>(); Watchers = new List <FileSystemWatcher>(); Bus = bus; }
private static IFullNode GetSideChainFullNode(NodeSettings nodeSettings) { DbType dbType = nodeSettings.GetDbType(); IFullNodeBuilder nodeBuilder = new FullNodeBuilder() .UseNodeSettings(nodeSettings, dbType) .UseBlockStore(dbType) .UseMempool() .AddSmartContracts(options => { options.UseReflectionExecutor(); options.UsePoAWhitelistedContracts(); }) .AddPoAFeature() .UsePoAConsensus(dbType) .CheckCollateralCommitment() // This needs to be set so that we can check the magic bytes during the Strat to Strax changeover. // Perhaps we can introduce a block height check rather? .SetCounterChainNetwork(StraxNetwork.MainChainNetworks[nodeSettings.Network.NetworkType]()) .UseSmartContractWallet() .AddSQLiteWalletRepository() .UseApi() .UseUnity3dApi() .AddRPC() .AddSignalR(options => { DaemonConfiguration.ConfigureSignalRForCirrus(options); }) .UseDiagnosticFeature(); return(nodeBuilder.Build()); }
public ServiceCoordinator(DaemonConfiguration configuration, IBootStrapper bootStrapper) { Services = new List <IServiceController>(); Configuration = configuration; RegisterServices(); BootStrap = bootStrapper; }
async Task ConfigureAsync(string deviceConnectionString, Option <Uri> proxy, CancellationToken token) { string hostname = (await File.ReadAllTextAsync("/proc/sys/kernel/hostname", token)).Trim(); IotHubConnectionStringBuilder builder = IotHubConnectionStringBuilder.Create(deviceConnectionString); var properties = new object[] { hostname, builder.DeviceId }; string message = "Configured edge daemon for device '{Device}' registered as '{Id}'"; proxy.ForEach( p => { message += " with proxy '{ProxyUri}'"; properties = properties.Concat(new object[] { p }).ToArray(); }); await Profiler.Run( async() => { await this.InternalStopAsync(token); var yaml = new DaemonConfiguration(); yaml.SetDeviceConnectionString(deviceConnectionString); yaml.SetDeviceHostname(hostname); proxy.ForEach(p => yaml.AddHttpsProxy(p)); yaml.Update(); await this.InternalStartAsync(token); }, message, properties); }
public Watcher( DaemonConfiguration configuration, IBus bus ) { Configuration = configuration.BootStrapConfiguration; SystemObservers = new List<IDisposable>(); Watchers = new List<FileSystemWatcher>(); Bus = bus; }
public static ServiceProcessInstaller GetProcessInstaller(this DaemonConfiguration configuration) { return(new ServiceProcessInstaller { Account = configuration.PrincipalType, Username = configuration.Principal, Password = configuration.Password }); }
public BootStrapper(DaemonConfiguration configuration, IBus bus, Watcher minionWatcher) { Configuration = configuration.BootStrapConfiguration; Bus = bus; MinionWatcher = minionWatcher; bus.AddLocalChannel(x => x .CorrelateBy <NewApplication>(m => m.DirectoryPath) .CorrelateBy <ApplicationChanged>(m => m.DirectoryPath) .CorrelateBy <ApplicationDeleted>(m => m.DirectoryPath)); }
public static void UpdateRegistry(this DaemonConfiguration configuration) { using (RegistryKey system = Registry.LocalMachine.OpenSubKey(SYSTEM)) using (RegistryKey currentControlSet = system.OpenSubKey(CURRENT_CONTROL_SET)) using (RegistryKey services = currentControlSet.OpenSubKey(SERVICES)) using (RegistryKey service = services.OpenSubKey(configuration.Name, true)) { service.SetValue(DESCRIPTION, configuration.Description); } }
public static ServiceInstaller GetServiceInstaller(this DaemonConfiguration configuration) { return(new ServiceInstaller { ServiceName = configuration.Name, Description = configuration.Description, DisplayName = configuration.DisplayName, StartType = configuration.StartMode }); }
public BootStrapper( DaemonConfiguration configuration, IBus bus, Watcher minionWatcher ) { Configuration = configuration.BootStrapConfiguration; Bus = bus; MinionWatcher = minionWatcher; bus.AddLocalChannel( x => x .CorrelateBy<NewApplication>( m => m.DirectoryPath ) .CorrelateBy<ApplicationChanged>( m => m.DirectoryPath ) .CorrelateBy<ApplicationDeleted>( m => m.DirectoryPath ) ); }
public static async Task Main(string[] args) { try { var nodeSettings = new NodeSettings(networksSelector: Networks.Strax, protocolVersion: ProtocolVersion.PROVEN_HEADER_VERSION, args: args) { MinProtocolVersion = ProtocolVersion.PROVEN_HEADER_VERSION }; // Set the console window title to identify this as a Strax full node (for clarity when running Strax and Cirrus on the same machine). Console.Title = $"Strax Full Node {nodeSettings.Network.NetworkType}"; DbType dbType = nodeSettings.GetDbType(); IFullNodeBuilder nodeBuilder = new FullNodeBuilder() .UseNodeSettings(nodeSettings, dbType) .UseBlockStore(dbType) .UsePosConsensus(dbType) .UseMempool() .UseColdStakingWallet() .AddSQLiteWalletRepository() .AddPowPosMining(true) .UseApi() .UseUnity3dApi() .AddRPC() .AddSignalR(options => { DaemonConfiguration.ConfigureSignalRForStrax(options); }) .UseDiagnosticFeature() .AddExternalApi(); IFullNode node = nodeBuilder.Build(); if (node != null) { await node.RunAsync(); } } catch (Exception ex) { Console.WriteLine("There was a problem initializing the node. Details: '{0}'", ex); } }
Task ConfigureAsync(Option <Uri> proxy, CancellationToken token) { return(proxy.ForEachAsync( p => { return Profiler.Run( async() => { await this.InternalStopAsync(token); var yaml = new DaemonConfiguration(); yaml.AddHttpsProxy(p); yaml.Update(); await this.InternalStartAsync(token); }, "Configured edge daemon with proxy '{ProxyUri}'", p); })); }
private static IFullNode BuildDevCirrusMiningNode(string[] args) { string[] devModeArgs = new[] { "-bootstrap=1", "-defaultwalletname=cirrusdev", "-defaultwalletpassword=password" }.Concat(args).ToArray(); var network = new CirrusDev(); var nodeSettings = new NodeSettings(network, protocolVersion: ProtocolVersion.CIRRUS_VERSION, args: devModeArgs) { MinProtocolVersion = ProtocolVersion.ALT_PROTOCOL_VERSION }; DbType dbType = nodeSettings.GetDbType(); IFullNode node = new FullNodeBuilder() .UseNodeSettings(nodeSettings, dbType) .UseBlockStore(dbType) .AddPoAFeature() .UsePoAConsensus(dbType) .AddPoAMiningCapability <SmartContractPoABlockDefinition>() .UseTransactionNotification() .UseBlockNotification() .UseApi() .UseMempool() .AddRPC() .AddSmartContracts(options => { options.UseReflectionExecutor(); options.UsePoAWhitelistedContracts(true); }) .UseSmartContractWallet() .AddSQLiteWalletRepository() .AddSignalR(options => { DaemonConfiguration.ConfigureSignalRForCirrus(options); }) .Build(); return(node); }
public DaemonInstaller(DaemonConfiguration configuration) { Configuration = configuration; }
public static bool Installed(this DaemonConfiguration configuration) { return(ServiceController .GetServices() .Any(x => x.ServiceName == configuration.Name)); }
static async Task <int> Main(string[] args) { args = args ?? Array.Empty <string>(); if (args.Length == 0) { Do_Help(); return(0); } int r; if (HasUnique(args, "-h", "--help", Do_Help, out r)) { return(r); } if (HasUnique(args, "-V", "--version", Do_Version, out r)) { return(r); } var daemon = Has(args, "-d", "--daemon"); if (daemon == false) { Do_Help("No -d argument found"); return(1); } var ip = Dns.GetHostAddresses(HasStr(args, "-s", "--server") ?? "localhost").FirstOrDefault(a => a.AddressFamily == AddressFamily.InterNetwork); var configuracion = new DaemonConfiguration() { Test = Has(args, "-t", "--test"), Server = ip, Port = int.Parse(HasStr(args, "-p", "--port") ?? "514", CultureInfo.InvariantCulture), Level = HasStr(args, "-l", "--level"), Verbose = Has(args, "-v", "--verbose") }; if (string.IsNullOrEmpty(configuracion.Level)) { configuracion.Level = "Error"; } if (configuracion.Verbose) { Do_Version(); Console.WriteLine("Configuration:"); Console.WriteLine($"Test:\t{configuracion.Test}"); Console.WriteLine($"Server:\t{configuracion.Server}"); Console.WriteLine($"Port:\t{configuracion.Port}"); Console.WriteLine($"Level:\t{configuracion.Level}"); // ReSharper disable once ConditionIsAlwaysTrueOrFalse Console.WriteLine($"Verbose:\t{configuracion.Verbose}"); } using (_service = new Winlogd(configuracion)) { Console.CancelKeyPress += DoCancel; CreateConsoleKeyTask(); Console.WriteLine("CTRL+C to interrupt the daemon."); Console.WriteLine("T to test the syslog destiny."); Console.WriteLine("E to test the eventlog."); int exitresult = await _service.Run().ConfigureAwait(false); Console.WriteLine("Closing the daemon"); _cancelKey.Cancel(); _keyTask.Wait(200); return(exitresult); } }
public Task <int> RunAsync(Args args) => Profiler.Run( "Running tempSensor test", async() => { using (var cts = new CancellationTokenSource(TimeSpan.FromMinutes(5))) { CancellationToken token = cts.Token; // ** setup var iotHub = new IotHub(args.ConnectionString, args.Endpoint, args.Proxy); var device = await EdgeDevice.GetOrCreateIdentityAsync( args.DeviceId, iotHub, token); var daemon = new EdgeDaemon(args.InstallerPath); await daemon.UninstallAsync(token); await daemon.InstallAsync( device.ConnectionString, args.PackagesPath, args.Proxy, token); await args.Proxy.Match( async p => { await daemon.StopAsync(token); var yaml = new DaemonConfiguration(); yaml.AddHttpsProxy(p); yaml.Update(); await daemon.StartAsync(token); }, () => daemon.WaitForStatusAsync(EdgeDaemonStatus.Running, token)); var agent = new EdgeAgent(device.Id, iotHub); await agent.WaitForStatusAsync(EdgeModuleStatus.Running, token); await agent.PingAsync(token); // ** test var config = new EdgeConfiguration(device.Id, args.AgentImage, iotHub); args.Registry.ForEach( r => config.AddRegistryCredentials(r.address, r.username, r.password)); config.AddEdgeHub(args.HubImage); args.Proxy.ForEach(p => config.AddProxy(p)); config.AddTempSensor(args.SensorImage); await config.DeployAsync(token); var hub = new EdgeModule("edgeHub", device.Id, iotHub); var sensor = new EdgeModule("tempSensor", device.Id, iotHub); await EdgeModule.WaitForStatusAsync( new[] { hub, sensor }, EdgeModuleStatus.Running, token); await sensor.WaitForEventsReceivedAsync(token); var sensorTwin = new ModuleTwin(sensor.Id, device.Id, iotHub); await sensorTwin.UpdateDesiredPropertiesAsync( new { properties = new { desired = new { SendData = true, SendInterval = 10 } } }, token); await sensorTwin.WaitForReportedPropertyUpdatesAsync( new { properties = new { reported = new { SendData = true, SendInterval = 10 } } }, token); // ** teardown await daemon.StopAsync(token); await device.MaybeDeleteIdentityAsync(token); } return(0); }, "Completed tempSensor test");
public CommandProvider(DaemonConfiguration configuration) { Configuration = configuration; }
public Winlogd(DaemonConfiguration configuration) { Configuration = configuration; _exitevent = new AutoResetEvent(false); EndPoint = new IPEndPoint(Configuration.Server, Configuration.Port); }
public DaemonInstaller( DaemonConfiguration configuration ) { Configuration = configuration; }
public CommandProvider( DaemonConfiguration configuration ) { Configuration = configuration; }
public ServiceCoordinator( DaemonConfiguration configuration, IBootStrapper bootStrapper ) { Services = new List<IServiceController>(); Configuration = configuration; RegisterServices(); BootStrap = bootStrapper; }
public async Task <int> RunAsync(Args args) { LogEventLevel consoleLevel = args.Verbose ? LogEventLevel.Verbose : LogEventLevel.Information; var loggerConfig = new LoggerConfiguration() .MinimumLevel.Verbose() .WriteTo.Console(consoleLevel); args.LogFile.ForEach(f => loggerConfig.WriteTo.File(f)); Log.Logger = loggerConfig.CreateLogger(); try { using (var cts = new CancellationTokenSource(TimeSpan.FromMinutes(5))) { Log.Information("Running tempSensor test"); await Profiler.Run( async() => { CancellationToken token = cts.Token; // ** setup var iotHub = new IotHub(args.ConnectionString, args.Endpoint, args.Proxy); EdgeDevice device = await EdgeDevice.GetOrCreateIdentityAsync( args.DeviceId, iotHub, token); var daemon = new EdgeDaemon(args.InstallerPath); await daemon.UninstallAsync(token); await daemon.InstallAsync( device.ConnectionString, args.PackagesPath, args.Proxy, token); await args.Proxy.Match( async p => { await daemon.StopAsync(token); var yaml = new DaemonConfiguration(); yaml.AddHttpsProxy(p); yaml.Update(); await daemon.StartAsync(token); }, () => daemon.WaitForStatusAsync(EdgeDaemonStatus.Running, token)); var agent = new EdgeAgent(device.Id, iotHub); await agent.WaitForStatusAsync(EdgeModuleStatus.Running, token); await agent.PingAsync(token); // ** test var config = new EdgeConfiguration(device.Id, args.AgentImage, iotHub); args.Registry.ForEach( r => config.AddRegistryCredentials(r.address, r.username, r.password)); config.AddEdgeHub(args.HubImage); args.Proxy.ForEach(p => config.AddProxy(p)); config.AddTempSensor(args.SensorImage); await config.DeployAsync(token); var hub = new EdgeModule("edgeHub", device.Id, iotHub); var sensor = new EdgeModule("tempSensor", device.Id, iotHub); await EdgeModule.WaitForStatusAsync( new[] { hub, sensor }, EdgeModuleStatus.Running, token); await sensor.WaitForEventsReceivedAsync(token); var sensorTwin = new ModuleTwin(sensor.Id, device.Id, iotHub); await sensorTwin.UpdateDesiredPropertiesAsync( new { properties = new { desired = new { SendData = true, SendInterval = 10 } } }, token); await sensorTwin.WaitForReportedPropertyUpdatesAsync( new { properties = new { reported = new { SendData = true, SendInterval = 10 } } }, token); // ** teardown await daemon.StopAsync(token); await device.MaybeDeleteIdentityAsync(token); }, "Completed tempSensor test"); } } catch (Exception e) { Log.Error(e, "Failed tempSensor test"); return(1); } finally { Log.CloseAndFlush(); } return(0); }