Ejemplo n.º 1
0
        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.
            var heartbeatServer = serviceProvider.GetService <IHeartbeatServer>();
            var shellServer     = serviceProvider.GetService <IShellServer>();
            var engine          = serviceProvider.GetService <IExecutionEngine>();

            shellServer.ShutdownRequest += OnShutdownRequest;

            // 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.
            engine.Start();
            heartbeatServer.Start();
            shellServer.Start();

            KernelStarted?.Invoke(serviceProvider);

            return(0);
        }
Ejemplo n.º 2
0
        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);
        }