Exemple #1
0
        private static void Start()
        {
            // 启动数据收集服务
            _collectionServiceManager = new ServiceManager();
            _collectionServiceManager.StartService();
            CollectionServiceHandler.Manager = _collectionServiceManager;
            Console.WriteLine("Collection Service is started...");

            // 启动WebApi
            _webApiServer = new WebApiServer(_webApiPort);
            if(_webApiServer.Open())
            {
                Console.WriteLine(string.Format("WebApi is listening at {0}", _webApiServer.BasicAddress));
            }
            else
            {
                Console.WriteLine(string.Format("WebApi startup failed at port:{0}", _webApiPort));
            }
        }
Exemple #2
0
        private static void Stop()
        {
            /*Stop操作顺序与启动顺序相反*/

            if(_webApiServer != null)
            {
                _webApiServer.Close();
                _webApiServer.Dispose();
                _webApiServer = null;
            }

            CollectionServiceHandler.Manager = null;
            if(_collectionServiceManager != null)
            {
                _collectionServiceManager.StopService();
                _collectionServiceManager.Dispose();
                _collectionServiceManager = null;
            }
        }