重构注册中心,简化注册与发现
大石头 authored at 2021-03-16 23:09:16
830.00 B
Stardust
using System.Threading;
using System.Threading.Tasks;
using Stardust.Data;

namespace StarGateway
{
    class InitService : IHostedService
    {
        public Task StartAsync(CancellationToken cancellationToken)
        {
            //await Task.Yield();

            Task.Run(() =>
            {
                // 配置
                var set = NewLife.Setting.Current;
                if (set.IsNew)
                {
                    set.DataPath = "../Data";
                    set.Save();
                }

                // 初始化数据库
                var n = App.Meta.Count;
                //AppStat.Meta.Session.Dal.Db.ShowSQL = false;
            });

            return Task.CompletedTask;
        }

        public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
    }
}