/// <summary> /// Loads the dataset into an external application and returns when the dataset application has started. /// </summary> /// <param name="endpointId">The endpoint ID for the owner.</param> /// <param name="channelType">The type of channel on which the dataset should be contacted.</param> /// <param name="address">The channel address for the owner.</param> /// <returns>The ID number of the newly created endpoint.</returns> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="endpointId"/> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="address"/> is <see langword="null" />. /// </exception> public EndpointId ActivateDataset(EndpointId endpointId, ChannelType channelType, Uri address) { { Lokad.Enforce.Argument(() => endpointId); Lokad.Enforce.Argument(() => address); } var deploymentDir = DeployLocation(); m_Diagnostics.Log( LevelToLog.Debug, BaseConstants.LogPrefix, string.Format(CultureInfo.InvariantCulture, "Deploying to: {0}", deploymentDir)); DeployApplication(deploymentDir); var fullFilePath = Path.Combine(deploymentDir, DatasetApplicationFileName); var arguments = string.Format( CultureInfo.InvariantCulture, @"--host={0} --channeltype=""{1}"" --channeluri={2}", endpointId, channelType, address); var startInfo = new ProcessStartInfo { FileName = fullFilePath, Arguments = arguments, // Create no window for the process. It doesn't need one // and we don't want the user to have a window they can // kill. If the process has to die then the user will have // to put in some effort. CreateNoWindow = true, // Do not use the shell to create the application // This means we can only start executables. UseShellExecute = false, // Do not display an error dialog if startup fails // We'll deal with that ourselves ErrorDialog = false, // Do not redirect any of the input or output streams // We don't really care about them because we won't be using // them anyway. RedirectStandardInput = false, RedirectStandardOutput = false, RedirectStandardError = false, // Set the working directory to something sane. Mostly the // directory of the file that we're trying to read. WorkingDirectory = deploymentDir, }; using (var exec = new Process()) { exec.StartInfo = startInfo; exec.Start(); // Link to the current process so that the datasets die if we die s_ProcessTrackingJob.LinkChildProcessToJob(exec); return exec.CreateEndpointIdForProcess(); } }
private EndpointId StartExecutorApplication(EndpointId endpointId, Uri address) { var localInstallDir = Assembly.GetExecutingAssembly().LocalDirectoryPath(); var fullFilePath = Path.Combine(localInstallDir, "Sherlock.Executor.exe"); var arguments = string.Format( CultureInfo.InvariantCulture, @"--host={0} --channeltype=""{1}"" --channeluri={2}", endpointId, ChannelType.NamedPipe, address); var startInfo = new ProcessStartInfo { FileName = fullFilePath, Arguments = arguments, // Create no window for the process. It doesn't need one // and we don't want the user to have a window they can // kill. If the process has to die then the user will have // to put in some effort. CreateNoWindow = true, // Do not use the shell to create the application // This means we can only start executables. UseShellExecute = false, // Do not display an error dialog if startup fails // We'll deal with that ourselves ErrorDialog = false, // Do not redirect any of the input or output streams // We don't really care about them because we won't be using // them anyway. RedirectStandardInput = false, RedirectStandardOutput = false, RedirectStandardError = false, // Set the working directory to something sane. Mostly the // directory of the file that we're trying to read. WorkingDirectory = localInstallDir, }; var exec = new Process { StartInfo = startInfo }; exec.Exited += HandleOnExecutorApplicationExit; exec.Start(); return exec.CreateEndpointIdForProcess(); }