public bool Start(HostControl hctrl)
        {
            Log.Debug("Rhino system directory: {Path}", RhinoInside.Resolver.RhinoSystemDirectory);
            Log.Information("Launching RhinoCore library as {User}", Environment.UserName);
            Program.RhinoCore = new Rhino.Runtime.InProcess.RhinoCore(null, Rhino.Runtime.InProcess.WindowStyle.NoWindow);

            Environment.SetEnvironmentVariable("RHINO_TOKEN", null, EnvironmentVariableTarget.Process);

            Rhino.Runtime.HostUtils.OnExceptionReport += (source, ex) => {
                Log.Error(ex, "An exception occurred while processing request");
                if (Config.Debug)
                {
                    Logging.LogExceptionData(ex);
                }
            };

            StartOptions options = new StartOptions();

            foreach (var url in _bind)
            {
                options.Urls.Add(url);
            }

            Log.Information("Starting listener(s): {Urls}", _bind);

            // start listener and unpack HttpListenerException if thrown
            // (missing urlacl or lack of permissions)
            try
            {
                _host = WebApp.Start <Startup>(options);
            }
            catch (TargetInvocationException ex) when(ex.InnerException is HttpListenerException hle)
            {
                Log.Error("Exception: " + hle.Message);
                throw hle;
            }
            catch (Exception ex)
            {
                Log.Error("Exception: " + ex.Message);
                throw ex;
            }

            Log.Information("Listening on {Urls}", _bind);

            // when running in a console (not as a service), i.e. when launched as a child process of hops
            // update console title to differentiate windows (ports) and start parent process shutdown timer
            if (hctrl is Topshelf.Hosts.ConsoleRunHost)
            {
                Shutdown.StartTimer(hctrl);
            }

            return(true);
        }
示例#2
0
        public bool Start(HostControl hctrl)
        {
            Log.Debug("Rhino system directory: {Path}", RhinoInside.Resolver.RhinoSystemDirectory);
            Log.Information("Launching RhinoCore library as {User}", Environment.UserName);
            Program.RhinoCore = new Rhino.Runtime.InProcess.RhinoCore(null, Rhino.Runtime.InProcess.WindowStyle.NoWindow);

            Rhino.Runtime.HostUtils.OnExceptionReport += (source, ex) => {
                Log.Error(ex, "An exception occured while processing request");
                if (Config.Debug)
                {
                    Logging.LogExceptionData(ex);
                }
            };

            StartOptions options = new StartOptions();

            foreach (var url in _bind)
            {
                options.Urls.Add(url);
            }

            Log.Information("Starting listener(s): {Urls}", _bind);

            // start listener and unpack HttpListenerException if thrown
            // (missing urlacl or lack of permissions)
            try
            {
                _host = WebApp.Start <Startup>(options);
            }
            catch (TargetInvocationException ex) when(ex.InnerException is HttpListenerException hle)
            {
                throw hle;
            }
            catch
            {
                throw;
            }

            Log.Information("Listening on {Urls}", _bind);

            var chunks = _bind[0].Split(new char[] { ':' });

            Console.Title = $"rhino.compute:{chunks[chunks.Length-1]}";
            Shutdown.StartTimer(hctrl);

            return(true);
        }