void OnWebServerStartedEvent(XspResult result) { if (WebServerStartedEvent != null) { WebServerStartedEvent(this, new WebServerStartedEventArgs(result)); } }
void GetXspInfo(HttpListenerContext context) { XspResult result; if (xsp == null) { result = new XspResult("Not a web project!"); } else { xsp.WaitHandle.WaitOne(); result = xsp.Result ?? new XspResult("Cannot start xsp: Unknown error"); } using (StringWriter sw = new StringWriter()) { using (XmlWriter xw = new XmlTextWriter(sw)) { result.Serialize(xw); } context.WriteString(sw.ToString()); } }
public static void Main(string[] args) { XmlDocument doc = new XmlDocument(); doc.Load(Console.In); XmlNode node = doc.SelectSingleNode("/xsp-options"); var opts = new XspOptions(node); var source = new MonoWebSource(opts); Environment.CurrentDirectory = opts.LocalDirectory; var server = new ApplicationServer(source); server.AddApplicationsFromCommandLine("/:."); XspResult result; try { if (server.Start(false)) { result = new XspResult(source.EndPoint); } else { result = new XspResult("Cannot start xsp."); } } catch (Exception ex) { var msg = String.Format("Cannot start xsp: {0}", ex.Message); result = new XspResult(msg); } Console.Out.WriteLine(result.ToXml()); Console.Out.Flush(); }
public bool Start() { process = Process.Start(psi); bool started = false; process.OutputDataReceived += delegate(object sender, DataReceivedEventArgs e) { Console.WriteLine("OUTPUT: {0}", e.Data ?? "null"); if (started) { return; } //if (string.IsNullOrEmpty (e.Data)) // return; started = true; process.CancelOutputRead(); // SDB port in use if (e.Data == null) { Logger.LogDebug("e.Data is null"); SdbPortInUse = true; ready_event.Set(); Logger.LogDebug("ready_event set"); return; } XmlDocument doc = new XmlDocument(); doc.LoadXml(e.Data); Logger.LogDebug("loaded e.Data doc"); var node = doc.SelectSingleNode("/xsp-result"); Result = new XspResult(node); ready_event.Set(); OnWebServerStartedEvent(Result); }; // See if sdb port is in use before going on if (process.WaitForExit(1000)) { return(false); } // The process may have already exited due to sdb port in use try { Logger.LogDebug("sending xsp: {0}", options.ToXml()); process.StandardInput.WriteLine(options.ToXml()); process.StandardInput.Close(); } catch { Logger.LogDebug("Couldn't write to xsp standardinput"); } Logger.LogDebug("going to begin output readline"); process.BeginOutputReadLine(); Logger.LogDebug("beginoutreadline finished"); return(true); }