Пример #1
0
        static void Main()
        {
            VirtualRoot.SetOut(new ConsoleOut());
            NTMinerConsole.MainUiOk();
            NTMinerConsole.DisbleQuickEditMode();
            try {
                VirtualRoot.StartTimer();
                // 将服务器地址设为localhost从而使用内网ip访问免于验证用户名密码
                RpcRoot.SetOfficialServerAddress(NTKeyword.Localhost);
                NTMinerRegistry.SetAutoBoot("NTMiner.CalcConfigUpdater", true);
                VirtualRoot.BuildEventPath <Per10MinuteEvent>("每10分钟更新收益计算器", LogEnum.DevConsole, location: typeof(Program), PathPriority.Normal,
                                                              path: message => {
                    UpdateAsync();
                });
                UpdateAsync();
                NTMinerConsole.UserInfo("输入exit并回车可以停止服务!");

                while (Console.ReadLine() != "exit")
                {
                }

                NTMinerConsole.UserOk($"服务停止成功: {DateTime.Now.ToString()}.");
            }
            catch (Exception e) {
                Logger.ErrorDebugLine(e);
            }

            System.Threading.Thread.Sleep(1000);
        }
Пример #2
0
 public App()
 {
     VirtualRoot.SetOut(NotiCenterWindowViewModel.Instance);
     LogDir.SetDir(SpecialPath.LogsDirFullName);
     AppUtil.Init(this);
     InitializeComponent();
 }
Пример #3
0
 public App()
 {
     VirtualRoot.SetOut(NotiCenterWindowViewModel.Instance);
     WpfUtil.Init();
     AppUtil.Init(this);
     InitializeComponent();
 }
Пример #4
0
 public App()
 {
     VirtualRoot.SetOut(NotiCenterWindowViewModel.Instance);
     MainAssemblyInfo.SetHomeDirFullName(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "NTMiner"));
     LogDir.SetDir(SpecialPath.LogsDirFullName);
     AppUtil.Init(this);
     InitializeComponent();
 }
Пример #5
0
 public App()
 {
     Logger.Disable();
     Write.UIThreadId = Dispatcher.Thread.ManagedThreadId;
     VirtualRoot.SetOut(NotiCenterWindowViewModel.Instance);
     AppUtil.Init(this);
     InitializeComponent();
 }
Пример #6
0
 public App()
 {
     VirtualRoot.SetOut(NotiCenterWindowViewModel.Instance);
     Logger.SetDir(SpecialPath.LogsDirFullName);
     Write.UIThreadId = Dispatcher.Thread.ManagedThreadId;
     AppUtil.Init(this);
     InitializeComponent();
 }
Пример #7
0
 public App()
 {
     Logger.Disable();
     Write.Disable();
     VirtualRoot.SetOut(NotiCenterWindowViewModel.Instance);
     AppUtil.Init(this);
     InitializeComponent();
 }
Пример #8
0
 public App()
 {
     HomePath.SetHomeDirFullName(AppDomain.CurrentDomain.BaseDirectory);
     VirtualRoot.SetOut(NotiCenterWindowViewModel.Instance);
     WpfUtil.Init();
     AppUtil.Init(this);
     InitializeComponent();
 }
Пример #9
0
        static void Main()
        {
            VirtualRoot.SetOut(new ConsoleOut());
            NTMinerConsole.MainUiOk();
            NTMinerConsole.DisbleQuickEditMode();
            DevMode.SetDevMode();

            Windows.ConsoleHandler.Register(Exit);

            string thisServerAddress = ServerRoot.HostConfig.ThisServerAddress;

            Console.Title = $"{ServerAppType.WsServer.GetName()}_{thisServerAddress}";
            // 用本节点的地址作为队列名,消费消息时根据路由键区分消息类型
            string queue        = $"{ServerAppType.WsServer.GetName()}.{thisServerAddress}";
            string durableQueue = queue + MqKeyword.DurableQueueEndsWith;

            AbstractMqMessagePath[] mqMessagePaths = new AbstractMqMessagePath[] {
                new ReadOnlyUserMqMessagePath(durableQueue),
                new MinerSignMqMessagePath(queue),
                new WsServerNodeMqMessagePath(queue),
                new OperationMqMessagePath(queue),
                new MinerClientMqMessagePath(queue, thisServerAddress),
                new ClientTestIdMqMessagePath(queue)
            };
            if (!MqRedis.Create(ServerAppType.WsServer, mqMessagePaths, out IMqRedis mqRedis))
            {
                NTMinerConsole.UserError("启动失败,无法继续,因为服务器上下文创建失败");
                return;
            }
            MinerClientMqSender    = new MinerClientMqSender(mqRedis);
            SpeedDataRedis         = new SpeedDataRedis(mqRedis);
            WsServerNodeRedis      = new WsServerNodeRedis(mqRedis);
            OperationMqSender      = new OperationMqSender(mqRedis);
            UserMqSender           = new UserMqSender(mqRedis);
            _wsServerNodeMqSender  = new WsServerNodeMqSender(mqRedis);
            WsServerNodeAddressSet = new WsServerNodeAddressSet(WsServerNodeRedis, _wsServerNodeMqSender);
            var minerRedis = new MinerDataRedis(mqRedis);
            var userRedis  = new ReadOnlyUserDataRedis(mqRedis);

            VirtualRoot.StartTimer();
            // 构造函数中异步访问redis初始化用户列表,因为是异步的所以提前构造
            UserSet               = new ReadOnlyUserSet(userRedis);
            MinerSignSet          = new MinerSignSet(minerRedis);
            _wsServer             = new SharpWsServerAdapter(ServerRoot.HostConfig);
            MinerClientSessionSet = new MinerClientSessionSet(_wsServer.MinerClientWsSessions);
            MinerStudioSessionSet = new MinerStudioSessionSet(_wsServer.MinerStudioWsSessions);
            _started              = _wsServer.Start();
            if (!_started)
            {
                NTMinerConsole.UserError("启动失败,无法继续,因为_wsServer启动失败");
                return;
            }
            VirtualRoot.RaiseEvent(new WebSocketServerStatedEvent());

            Console.ReadKey(true);
            Exit();
        }
Пример #10
0
 public App()
 {
     VirtualRoot.SetOut(NotiCenterWindowViewModel.Instance);
     Logger.SetDir(MinerClientTempPath.TempLogsDirFullName);
     WpfUtil.Init();
     AppUtil.Init(this);
     AppUtil.IsHotKeyEnabled = true;
     InitializeComponent();
 }
Пример #11
0
 public App()
 {
     HomePath.SetHomeDirFullName(System.IO.Path.Combine(HomePath.AppDomainBaseDirectory, "NTMiner"));
     VirtualRoot.SetOut(NotiCenterWindowViewModel.Instance);
     Logger.SetDir(HomePath.HomeLogsDirFullName);
     WpfUtil.Init();
     AppUtil.Init(this);
     InitializeComponent();
 }
Пример #12
0
 public App()
 {
     EntryAssemblyInfo.SetHomeDirFullName(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "NTMiner"));
     VirtualRoot.SetOut(NotiCenterWindowViewModel.Instance);
     Logger.SetDir(SpecialPath.LogsDirFullName);
     Write.UIThreadId = Dispatcher.Thread.ManagedThreadId;
     AppUtil.Init(this);
     InitializeComponent();
 }
Пример #13
0
 public App()
 {
     Hub.MessagePathHub.SetNotifyProperty();
     // 群控客户端独立一个子目录,从而挖矿客户端和群控客户端放在同一个目录时避免路径重复。
     HomePath.SetHomeDirFullName(System.IO.Path.Combine(HomePath.AppDomainBaseDirectory, "NTMiner"));
     VirtualRoot.SetOut(NotiCenterWindowViewModel.Instance);
     Logger.SetDir(HomePath.HomeLogsDirFullName);
     WpfUtil.Init();
     AppUtil.Init(this);
     InitializeComponent();
 }
Пример #14
0
 public App()
 {
     if ((NTMinerRegistry.GetIsAutoStart() || CommandLineArgs.IsAutoStart) && NTMinerRegistry.GetIsNoUi())
     {
         NTMinerConsole.Disable();
     }
     VirtualRoot.SetOut(NotiCenterWindowViewModel.Instance);
     Logger.SetDir(MinerClientTempPath.TempLogsDirFullName);
     WpfUtil.Init();
     AppUtil.Init(this);
     AppUtil.IsHotKeyEnabled = true;
     InitializeComponent();
 }
Пример #15
0
 public App()
 {
     Hub.MessagePathHub.SetNotifyProperty();
     if (NTMinerRegistry.GetIsNoUi())
     {
         NTMinerConsole.Disable();
     }
     VirtualRoot.SetOut(NotiCenterWindowViewModel.Instance);
     Logger.SetDir(TempPath.TempLogsDirFullName);
     WpfUtil.Init();
     AppUtil.Init(this);
     AppUtil.IsHotKeyEnabled = true;
     InitializeComponent();
 }
Пример #16
0
        static void Main(string[] args)
        {
            VirtualRoot.SetOut(new ConsoleOut());
            NTMinerConsole.MainUiOk();
            NTMinerConsole.DisbleQuickEditMode();
            DevMode.SetDevMode();
            Console.Title = $"{NTKeyword.WoLiuDao}-开源矿工外网群控服务端{NTKeyword.VersionBuild}";
            var defaultColor = Console.ForegroundColor;

            Console.ForegroundColor = ConsoleColor.Gray;
            Console.WriteLine("这是开源矿工外网群控服务端程序,和官方运行的服务端功能上完全一样,唯一的区别是官方程序运行在集群上,这个程序运行在用户自己的比如阿里云服务器上,如果您没有上千台矿机建议您直接连接官方的外网群控服务器。");
            Console.ForegroundColor = defaultColor;
            // TODO:搁置,以后再实现,只要能保证官方外网服务器集群的可用性就不需要用户自己部署外网服务器
            Console.WriteLine();
            Console.WriteLine("按任意键退出");
            Console.ReadKey();
        }
Пример #17
0
        public App()
        {
            VirtualRoot.SetOut(NotiCenterWindowViewModel.Instance);
            AppDomain.CurrentDomain.UnhandledException += (object sender, UnhandledExceptionEventArgs e) => {
                if (e.ExceptionObject is Exception exception)
                {
                    Handle(exception);
                }
            };

            DispatcherUnhandledException += (object sender, DispatcherUnhandledExceptionEventArgs e) => {
                Handle(e.Exception);
                e.Handled = true;
            };

            UIThread.InitializeWithDispatcher();
            UIThread.StartTimer();
            Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("zh-CN");
            InitializeComponent();
        }
Пример #18
0
        static void Main()
        {
            VirtualRoot.SetOut(new ConsoleOut());
            NTMinerConsole.MainUiOk();
            NTMinerConsole.DisbleQuickEditMode();
            DevMode.SetDevMode();

            Windows.ConsoleHandler.Register(Exit);

            try {
                bool mutexCreated;
                try {
                    // 锁名称上带上本节点的端口号,从而允许一个服务器上运行多个WebApiServer节点,这在软升级服务端程序时有用。
                    // 升级WebApiServer程序的时候步骤是:
                    // 1,在另一个端口启动新版本的程序;
                    // 2,让Widnows将来自旧端口的所有tcp请求转发到新端口;
                    // 3,退出旧版本的程序并更新到新版本;
                    // 4,删除第2步添加的Windows的端口转发;
                    // 5,退出第1步运行的节点;
                    // TODO:实现软升级策略
                    _sMutexApp = new Mutex(true, $"NTMinerServicesMutex{ServerRoot.HostConfig.GetServerPort().ToString()}", out mutexCreated);
                }
                catch {
                    mutexCreated = false;
                }
                if (mutexCreated)
                {
                    try {
                        // 用本节点的地址作为队列名,消费消息时根据路由键区分消息类型
                        string queue         = $"{nameof(ServerAppType.WebApiServer)}.{ServerRoot.HostConfig.ThisServerAddress}";
                        string durableQueue  = queue + MqKeyword.DurableQueueEndsWith;
                        string wsBreathQueue = queue + MqKeyword.WsBreathQueueEndsWith;
                        AbstractMqMessagePath[] mqMessagePaths = new AbstractMqMessagePath[] {
                            new UserMqMessagePath(durableQueue),
                            new CalcConfigMqMessagePath(queue),
                            new MinerClientMqMessagePath(queue),
                            new WsBreathMqMessagePath(wsBreathQueue),
                            new OperationMqMessagePath(queue),
                            new MqCountMqMessagePath(queue),
                            new ClientTestIdMqMessagePath(queue)
                        };
                        if (!MqRedis.Create(ServerAppType.WebApiServer, mqMessagePaths, out IMqRedis mqRedis))
                        {
                            NTMinerConsole.UserError("启动失败,无法继续,因为服务器上下文创建失败");
                            return;
                        }
                        Console.Title = $"{nameof(ServerAppType.WebApiServer)}_{ServerRoot.HostConfig.ThisServerAddress}";
                        // 阿里云OSS坑爹比七牛Kodo贵一半
                        CloudFileUrlGenerater = new AliCloudOSSFileUrlGenerater();
                        IRedis redis = mqRedis;
                        IMq    mq    = mqRedis;
                        AdminMqSender         = new AdminMqSender(mq);
                        ClientTestIdDataRedis = new ClientTestIdDataRedis(redis);
                        var minerClientMqSender = new MinerClientMqSender(mq);
                        var userMqSender        = new UserMqSender(mq);
                        var calcConfigMqSender  = new CalcConfigMqSender(mq);

                        var minerRedis          = new MinerDataRedis(redis);
                        var clientActiveOnRedis = new ClientActiveOnRedis(redis);
                        var speedDataRedis      = new SpeedDataRedis(redis);
                        var userRedis           = new UserDataRedis(redis);
                        var captchaRedis        = new CaptchaDataRedis(redis);
                        var calcConfigRedis     = new CalcConfigDataRedis(redis);

                        MqCountSet             = new MqCountSet();
                        WsServerNodeRedis      = new WsServerNodeRedis(redis);
                        WsServerNodeAddressSet = new WsServerNodeAddressSet(WsServerNodeRedis);
                        UserSet           = new UserSet(userRedis, userMqSender);
                        UserAppSettingSet = new UserAppSettingSet();
                        CaptchaSet        = new CaptchaSet(captchaRedis);
                        CalcConfigSet     = new CalcConfigSet(calcConfigRedis, calcConfigMqSender);
                        NTMinerWalletSet  = new NTMinerWalletSet();
                        GpuNameSet        = new GpuNameSet();
                        ClientDataSet clientDataSet = new ClientDataSet(minerRedis, clientActiveOnRedis, speedDataRedis, minerClientMqSender);
                        ClientDataSet = clientDataSet;
                        var operationMqSender = new OperationMqSender(mq);
                        MineWorkSet            = new UserMineWorkSet(operationMqSender);
                        MinerGroupSet          = new UserMinerGroupSet();
                        NTMinerFileSet         = new NTMinerFileSet();
                        OverClockDataSet       = new OverClockDataSet();
                        KernelOutputKeywordSet = new KernelOutputKeywordSet(SpecialPath.LocalDbFileFullName);
                        ServerMessageSet       = new ServerMessageSet(SpecialPath.LocalDbFileFullName);
                        if (VirtualRoot.LocalAppSettingSet.TryGetAppSetting(nameof(KernelOutputKeywordTimestamp), out IAppSetting appSetting) && appSetting.Value is DateTime value)
                        {
                            KernelOutputKeywordTimestamp = value;
                        }
                        else
                        {
                            KernelOutputKeywordTimestamp = Timestamp.UnixBaseTime;
                        }
                    }
                    catch (Exception e) {
                        NTMinerConsole.UserError(e.Message);
                        NTMinerConsole.UserError(e.StackTrace);
                        NTMinerConsole.UserInfo("按任意键退出");
                        Console.ReadKey();
                        return;
                    }
                    VirtualRoot.StartTimer();
                    NTMinerRegistry.SetAutoBoot("NTMinerServices", true);
                    Type thisType = typeof(AppRoot);
                    Run();
                }
            }
            catch (Exception e) {
                Logger.ErrorDebugLine(e);
            }
        }