public virtual ServiceProvider InitServiceProvider()

in src/KernelApplication.cs [608:659]


        public virtual ServiceProvider InitServiceProvider(IServiceCollection serviceCollection) =>
            serviceCollection.BuildServiceProvider();

        /// <summary>
        /// This method is called to start the servers and the execution engine
        /// and the mail execution loop.
        /// </summary>
        public virtual int StartKernel(ServiceProvider serviceProvider)
        {
            var logger = serviceProvider.GetService<ILogger<KernelApplication>>();
            logger.LogDebug("Starting kernel services...");

            // Minimally, we need to start a server for each of the heartbeat,
            // control and shell sockets.
            // We start by launching a heartbeat server, which echoes whatever
            // input it gets from the client. Clients can use this to ensure
            // that the kernel is still alive and responsive.
            using (logger.BeginScope("Starting kernel services"))
            {
                logger.LogDebug("Getting and starting heartbeat service.");
                serviceProvider.GetService<IHeartbeatServer>().Start();

                logger.LogDebug("Getting and starting shell service.");
                var shellServer = serviceProvider.GetService<IShellServer>();
                shellServer.ShutdownRequest += OnShutdownRequest;
                shellServer.Start();

                // Tell the client that we are starting the engine.
                shellServer.SendIoPubMessage(
                    new Message
                    {
                        Header = new MessageHeader
                        {
                            MessageType = "status"
                        },
                        Content = new KernelStatusContent
                        {
                            ExecutionState = ExecutionState.Starting
                        }
                    }
                );

                logger.LogDebug("Getting engine service.");
                var engine = serviceProvider.GetService<IExecutionEngine>();
                logger.LogDebug("Starting engine service.");
                engine.Start();
            }

            KernelStarted?.Invoke(serviceProvider);

            return 0;
        }