Beispiel #1
0
        public void Start()
        {
            if (isStarted) throw new Exception("Server has already been started!");
            isStarted = true;

            Log.Debug("Starting Server...");

            // Load existing or default server configuration
            ServerConfiguration.Load();

            UserMgr.Directory = Configuration.Directory;
            
            if (!UserMgr.Initialize())
                DefaultSecurityGroups.Initialize(UserMgr);

            Http.Initialize();

            MessageRegistry.Scan(Assembly.GetExecutingAssembly());
            MessageRegistry.Scan(typeof(ILibraryAssembly).Assembly);
            MessageRegistry.Scan(typeof(IFrameworkAssembly).Assembly);

            // TODO: Cache Project Package Index?
            //ProjectPackages.Initialize();

            Sessions.Start();
            Queue.Start();

            var taskVariables = Task.Run(() => Variables.Load(Configuration.VariablesDirectory));
            var taskHttp = Task.Run(() => Http.Start());
            var taskAgents = Task.Run(() => Agents.Load());
            var taskProjects = Task.Run(() => Projects.Load());

            Task.WaitAll(
                taskVariables,
                taskAgents,
                taskProjects,
                taskHttp);

            ProjectPackageCache.Initialize()
                .GetAwaiter().GetResult();

            HealthChecks.Start();

            Log.Info("Server started.");
        }