예제 #1
0
        public override void Start(System.Net.HttpListenerContext context)
        {
            Logger.LogDebug("Starting sdb web site");

            XmlDocument options = context.GetRequestDataAsXml();

            int start_port = MonoToolsConfigurationManager.ApplicationPortRangeStart;
            int end_port   = MonoToolsConfigurationManager.ApplicationPortRangeEnd;

            host = context.Request.LocalEndPoint.Address;

            for (sdb_port = start_port; sdb_port <= end_port; sdb_port++)
            {
                Logger.LogDebug("  Trying to start with sdb port: {0}", sdb_port);
                XspSession session = StartXspSession(options);

                if (session == null)
                {
                    Logger.LogDebug("    sdb on port {0} failed", sdb_port);
                    continue;
                }

                Logger.LogDebug("    sdb port {0} is good, returning to VS", sdb_port);
                is_started = true;
                context.WriteString(ToXml());
                return;
            }

            Logger.LogDebug("    Ran out of sdb ports to use: {0}-{1}.", start_port, end_port);

            context.ReturnException(new ApplicationException("Could not find an available sdb port to use."));
        }
예제 #2
0
        protected virtual XspSession StartXspSession(XmlDocument options)
        {
            // See if VS sent us a XspOptions
            var xsp_node = options.SelectSingleNode("/options/xsp-options");

            if (xsp_node != null)
            {
                xsp_options = new XspOptions(xsp_node);
            }
            else
            {
                xsp_options = new XspOptions(
                    host,
                    MonoToolsConfigurationManager.ApplicationPortRangeStart,
                    MonoToolsConfigurationManager.ApplicationPortRangeEnd);
            }

            xsp_options.LocalDirectory = RemotePath;

            // Set debug = true and RemoteErrors = off in web.config
            bool custom_errors_off = false;

            if (xsp_options.CustomErrorsOff != null)
            {
                custom_errors_off = (bool)xsp_options.CustomErrorsOff;
            }

            if (options.DocumentElement["customerrorsoff"] != null)
            {
                custom_errors_off = bool.Parse(options.DocumentElement["customerrorsoff"].InnerText);
            }

            Utilities.ModifyWebConfig(RemotePath, true, custom_errors_off);

            // Get environment variables and arguments for Mono
            StringDictionary env_vars = new StringDictionary();

            SetEnvironmentVariables(env_vars, options);

            List <string> mono_args = new List <string> ();

            AddMonoArguments(mono_args);

            if (options.DocumentElement["monoarguments"] != null)
            {
                mono_args.Add(options.DocumentElement["monoarguments"].InnerText);
            }

            // Fire up the session
            xsp = new XspSession(xsp_options, RemotePath, mono_args, env_vars);

            if (xsp.Start() == false)
            {
                return(null);
            }

            WaitForXspPort();

            return(xsp);
        }