public bool Start() { if (_started) { return(false); } _started = true; DeleporterUtilities.SetWebAndRemotingPortsBasedOnAvailability(); if (!DeleporterUtilities.LocalPortIsAvailable(DeleporterConfiguration.WebHostPort)) { LoggerClient.Log("ERROR: IIS Express port {0} is being used. Attempt to start IIS Express has been aborted", DeleporterConfiguration.WebHostPort); return(false); } var fileName = FileUtilities.TryToFindProgramFile("iisexpress.exe", "IIS Express"); if (fileName == null) { throw new FileNotFoundException("IIS Express was not found on this machine."); } _iisExpressProcess = new Process { StartInfo = { FileName = fileName, Arguments = "/path:\"" + DeleporterConfiguration.FullyQualifiedPathToWebApp + "\" /port:" + DeleporterConfiguration.WebHostPort + " /trace:error", WindowStyle = ProcessWindowStyle.Hidden, UseShellExecute = false, CreateNoWindow = true, } }; LoggerClient.Log("IIS Express starting on port {0} using path {1}... ", DeleporterConfiguration.WebHostPort, DeleporterConfiguration.FullyQualifiedPathToWebApp); try { _iisExpressProcess.Start(); } catch (SocketException ex) { LoggerClient.Log("Couldn't start IIS Express ... {0}", ex.Message); return(false); } DeleporterUtilities.WaitForLocalPortToBecomeUnavailable(DeleporterConfiguration.WebHostPort); DeleporterUtilities.PrimeServerHomepage(); LoggerClient.Log("IIS Express Started"); return(true); }
public bool Start() { if (this._started) { return(false); } this._started = true; if (!DeleporterUtilities.LocalPortIsAvailable(DeleporterConfiguration.SeleniumServerPort)) { LoggerClient.Log("Selenium port {0} is being used. Attempt to start Selenium has been aborted. " + "A previous instance may be running in which case we will just use that.", DeleporterConfiguration.SeleniumServerPort); return(false); } var javaExecutable = FileUtilities.TryToFindProgramFile("java.exe", "java"); this.ThrowIfFilesDontExist(DeleporterConfiguration.SeleniumServerJar, javaExecutable); this._seleniumServer = new Process { StartInfo = { FileName = javaExecutable, Arguments = string.Format("-jar {0} -port {1}", DeleporterConfiguration.SeleniumServerJar, DeleporterConfiguration.SeleniumServerPort), UseShellExecute = false, CreateNoWindow = true } }; LoggerClient.Log("Selenium Instance starting on port {0} using jar {1}... ", DeleporterConfiguration.SeleniumServerPort, DeleporterConfiguration.SeleniumServerJar); try { this._seleniumServer.Start(); } catch (Exception ex) { LoggerClient.Log("Couldn't start Selenium ... {0}", ex.Message); return(false); } // 20 seconds max ... checking every 0.1 seconds DeleporterUtilities.WaitForLocalPortToBecomeUnavailable(DeleporterConfiguration.SeleniumServerPort, 100, 200); LoggerClient.Log("Selenium Started"); return(true); }
public bool Start() { if (_started) { return(false); } _started = true; DeleporterUtilities.SetWebAndRemotingPortsBasedOnAvailability(); if (!DeleporterUtilities.LocalPortIsAvailable(DeleporterConfiguration.WebHostPort)) { LoggerClient.Log("ERROR: Cassini port {0} is being used. Attempt to start Cassini has been aborted", DeleporterConfiguration.WebHostPort); throw new InvalidOperationException(string.Format("Cassini port {0} is being used by something else. Attempt to start Cassini has been aborted", DeleporterConfiguration.WebHostPort)); } LoggerClient.Log("Using web.config location {0} with port {1}", DeleporterConfiguration.FullyQualifiedPathToWebApp, DeleporterConfiguration.WebHostPort); _casinniServer = new Microsoft.VisualStudio.WebHost.Server(DeleporterConfiguration.WebHostPort, "/", DeleporterConfiguration.FullyQualifiedPathToWebApp); LoggerClient.Log("Cassini starting on port {0} using path {1}... ", DeleporterConfiguration.WebHostPort, DeleporterConfiguration.FullyQualifiedPathToWebApp); try { _casinniServer.Start(); } catch (Exception ex) { LoggerClient.Log("Couldn't start Cassini ... {0}", ex.Message); return(false); } DeleporterUtilities.WaitForLocalPortToBecomeUnavailable(DeleporterConfiguration.WebHostPort); LoggerClient.Log("Cassini Started"); DeleporterUtilities.PrimeServerHomepage(); return(true); }