예제 #1
0
        static void Main(string[] args)
        {
            CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();

            XmlConfigurator.Configure();

            _log.Info("===== NODE STARTED =====");

            ConfigureUnhandledExceptions();

            NodeBootstrapper nodeBootstrapper = new NodeBootstrapper(cancellationTokenSource.Token);

            nodeBootstrapper.Run(new Dictionary <string, string> {
                { "secretKey", LoadModuleBase.GetRandomSeed().ToHexString() }
            });

            string command = null;

            do
            {
                command = System.Console.ReadLine();
            } while (command?.ToLower() != "exit");

            cancellationTokenSource.Cancel();

            //TODO: add code for graceful shutdown
        }
예제 #2
0
        static void Main(string[] args)
        {
            //int minWorkerThreads, minCompletionPortThreads;
            //int maxWorkerThreads, maxCompletionPortThreads;
            //ThreadPool.GetMinThreads(out minWorkerThreads, out minCompletionPortThreads);
            //ThreadPool.GetMaxThreads(out maxWorkerThreads, out maxCompletionPortThreads);
            //ThreadPool.SetMaxThreads(minWorkerThreads * 100, minCompletionPortThreads);

            CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();

            XmlConfigurator.Configure(_log.Logger.Repository);

            _log.Info("===== NODE STARTED =====");

            ConfigureUnhandledExceptions();

            string secretKey = null;

            if ((args?.Length ?? 0) == 0)
            {
                if (Debugger.IsAttached)
                {
                    byte[] seed = CryptoHelper.GetRandomSeed();
                    secretKey = seed.ToHexString();
                }
                else
                {
                    throw new NoSecretKeyProvidedException();
                }
            }
            else
            {
                secretKey = args[0];
            }

            Dictionary <string, string> bootArgs = new Dictionary <string, string>
            {
                { "secretKey", secretKey }
            };

            NodeBootstrapper nodeBootstrapper = new NodeBootstrapper(cancellationTokenSource.Token);

            nodeBootstrapper.Run(bootArgs);

            string command = null;

            do
            {
                command = System.Console.ReadLine();
            } while (command?.ToLower() != "exit");

            cancellationTokenSource.Cancel();

            //TODO: add code for graceful shutdown
        }