/// <summary>
        /// Entry point of the language worker.
        /// </summary>
        public async static Task Main(string[] args)
        {
            WorkerArguments arguments = null;

            Parser.Default.ParseArguments <WorkerArguments>(args)
            .WithParsed(ops => arguments = ops)
            .WithNotParsed(err => Environment.Exit(1));

            var msgStream        = new MessagingStream(arguments.Host, arguments.Port);
            var requestProcessor = new RequestProcessor(msgStream);

            // Send StartStream message
            var startedMessage = new StreamingMessage()
            {
                RequestId   = arguments.RequestId,
                StartStream = new StartStream()
                {
                    WorkerId = arguments.WorkerId
                }
            };

            await msgStream.WriteAsync(startedMessage);

            await requestProcessor.ProcessRequestLoop();
        }
Exemple #2
0
        /// <summary>
        /// Entry point of the language worker.
        /// </summary>
        public async static Task Main(string[] args)
        {
            RpcLogger.WriteSystemLog(
                LogLevel.Information,
                string.Format(PowerShellWorkerStrings.PowerShellWorkerVersion, typeof(Worker).Assembly.GetName().Version));

            WorkerArguments arguments = null;

            Parser.Default.ParseArguments <WorkerArguments>(args)
            .WithParsed(ops => arguments = ops)
            .WithNotParsed(err => Environment.Exit(1));

            var msgStream        = new MessagingStream(arguments.Host, arguments.Port);
            var requestProcessor = new RequestProcessor(msgStream);

            // Send StartStream message
            var startedMessage = new StreamingMessage()
            {
                RequestId   = arguments.RequestId,
                StartStream = new StartStream()
                {
                    WorkerId = arguments.WorkerId
                }
            };

            msgStream.Write(startedMessage);
            await requestProcessor.ProcessRequestLoop();
        }
        /// <summary>
        /// Entry point of the language worker.
        /// </summary>
        public async static Task Main(string[] args)
        {
            RpcLogger.WriteSystemLog(
                LogLevel.Information,
                string.Format(PowerShellWorkerStrings.PowerShellWorkerVersion, typeof(Worker).Assembly.GetName().Version));

            WorkerArguments arguments = null;

            Parser.Default.ParseArguments <WorkerArguments>(args)
            .WithParsed(ops => arguments = ops)
            .WithNotParsed(err => Environment.Exit(1));

            // Create the very first Runspace so the debugger has the target to attach to.
            // This PowerShell instance is shared by the first PowerShellManager instance created in the pool,
            // and the dependency manager (used to download dependent modules if needed).
            var firstPowerShellInstance = Utils.NewPwshInstance();

            LogPowerShellVersion(firstPowerShellInstance);
            WarmUpPowerShell(firstPowerShellInstance);

            var msgStream        = new MessagingStream(arguments.Host, arguments.Port);
            var requestProcessor = new RequestProcessor(msgStream, firstPowerShellInstance);

            // Send StartStream message
            var startedMessage = new StreamingMessage()
            {
                RequestId   = arguments.RequestId,
                StartStream = new StartStream()
                {
                    WorkerId = arguments.WorkerId
                }
            };

            msgStream.Write(startedMessage);
            await requestProcessor.ProcessRequestLoop();
        }