예제 #1
0
        private void run()
        {
            _host = new FubuOwinHost(_application);
            _host.RunApplication(_input.PortFlag, watchAssetFiles);

            _reset.Set();
        }
예제 #2
0
        public InMemoryHost(FubuRuntime runtime)
        {
            _runtime = runtime;

            _func = FubuOwinHost.ToAppFunc(runtime);

            _services = _runtime.Factory.Get <IServiceLocator>();
        }
예제 #3
0
        private static void Main(string[] args)
        {
            // TODO -- convert to FubuCommand's
            // How do they get at the application?
            // Have to spin up a separate AppDomain?  Ick-y

            var host = new FubuOwinHost(new OwinApplication(), new SchedulerDelegate());

            host.RunApplication(5500, r => { });
        }
예제 #4
0
        private void startServer(OwinSettings settings, string physicalPath, int port)
        {
            var parameters = new StartOptions {
                Port = port
            };

            parameters.Urls.Add("http://*:" + port); //for netsh http add urlacl


            if (physicalPath != null)
            {
                FubuMvcPackageFacility.PhysicalRootPath = physicalPath;
            }

            var context = new StartContext(parameters)
            {
                App = FubuOwinHost.ToAppFunc(_runtime, settings),
            };

            settings.EnvironmentData.ToDictionary().Each(pair => context.EnvironmentData.Add(pair));


            settings.EnvironmentData[OwinConstants.AppMode] = FubuMode.Mode().ToLower();
            context.EnvironmentData.AddRange(settings.EnvironmentData.ToDictionary());

            var engine = new HostingEngine(new AppBuilderFactory(), new TraceOutputFactory(),
                                           new AppLoader(new IAppLoaderFactory[0]),
                                           new ServerFactoryLoader(new ServerFactoryActivator(new ServiceProvider())));

            try
            {
                _server = engine.Start(context);
            }
            catch (TargetInvocationException e)
            {
                if (e.InnerException != null && e.InnerException.Message.Contains("Access is denied"))
                {
                    throw new KatanaRightsException(e.InnerException);
                }

                throw;
            }
        }
예제 #5
0
        private void startServer(OwinSettings settings, IList <RouteBase> routes, string physicalPath, int port)
        {
            var parameters = new StartOptions {
                Port = port
            };

            parameters.Urls.Add("http://*:" + port); //for netsh http add urlacl

            // Adding the static middleware
            settings.AddMiddleware <StaticFileMiddleware>(_services.GetInstance <IFubuApplicationFiles>(), settings);

            if (physicalPath != null)
            {
                FubuMvcPackageFacility.PhysicalRootPath = physicalPath;
            }
            Action <IAppBuilder> startup = FubuOwinHost.ToStartup(settings, routes);

            var context = new StartContext(parameters)
            {
                Startup = startup,
            };

            settings.EnvironmentData[OwinConstants.AppMode] = FubuMode.Mode().ToLower();
            context.EnvironmentData.AddRange(settings.EnvironmentData.ToDictionary());

            var engine = new HostingEngine(new AppBuilderFactory(), new TraceOutputFactory(),
                                           new AppLoader(new IAppLoaderFactory[0]),
                                           new ServerFactoryLoader(new ServerFactoryActivator(new ServiceProvider())));

            try
            {
                _server = engine.Start(context);
            }
            catch (TargetInvocationException e)
            {
                if (e.InnerException != null && e.InnerException.Message.Contains("Access is denied"))
                {
                    throw new KatanaRightsException(e.InnerException);
                }

                throw;
            }
        }
예제 #6
0
        public bool RunAllSpecs()
        {
            var title = "Running Jasmine specs for project at " + _input.SerenityFile;

            Console.WriteLine(title);
            var line = "".PadRight(title.Length, '-');

            Console.WriteLine(line);

            buildApplication();
            var returnValue = true;

            _host = new FubuOwinHost(_application);
            _host.RunApplication(_input.PortFlag, runtime =>
            {
                _driver.NavigateTo <JasminePages>(x => x.AllSpecs());

                var browser  = _applicationUnderTest.Driver;
                var failures = browser.FindElements(By.CssSelector("div.suite.failed"));


                if (failures.Any())
                {
                    returnValue = false;

                    Console.WriteLine(line);
                    writeFailures(failures);
                }

                Console.WriteLine();
                Console.WriteLine(line);
                writeTotals(browser);

                _host.Stop();

                browser.Quit();
            });


            return(returnValue);
        }
예제 #7
0
        private void startServer(IList <RouteBase> routes, string physicalPath, int port)
        {
            var parameters = new StartOptions {
                Port = port
            };

            parameters.Urls.Add("http://*:" + port); //for netsh http add urlacl

            FubuMvcPackageFacility.PhysicalRootPath = physicalPath ?? AppDomain.CurrentDomain.BaseDirectory;
            Action <IAppBuilder> startup = FubuOwinHost.ToStartup(routes);

            var context = new StartContext(parameters)
            {
                Startup = startup
            };

            var engine = new HostingEngine(new AppBuilderFactory(), new TraceOutputFactory(),
                                           new AppLoader(new IAppLoaderFactory[0]),
                                           new ServerFactoryLoader(new ServerFactoryActivator(new ServiceProvider())));

            _server = engine.Start(context);
        }
예제 #8
0
        public EmbeddedFubuMvcServer(FubuRuntime runtime, string physicalPath = null, int port = 5500, StartParameters parameters = null)
        {
            _runtime = runtime;

            parameters      = parameters ?? new StartParameters();
            parameters.Port = port;

            FubuMvcPackageFacility.PhysicalRootPath = physicalPath ?? AppDomain.CurrentDomain.BaseDirectory;

            //_server = WebApplication.Start<Starter>(port: port, verbosity: 1);

            var context = new StartContext
            {
                Parameters = parameters,
            };

            var settings = new KatanaSettings
            {
                LoaderFactory = () => (s => builder => {
                    var host = new FubuOwinHost(_runtime.Routes);
                    builder.Run(host);
                }),
            };

            var engine = new KatanaEngine(settings);

            _server = engine.Start(context);

            _baseAddress = "http://localhost:" + port;

            _urls = _runtime.Factory.Get <IUrlRegistry>();
            _urls.As <UrlRegistry>().RootAt(_baseAddress);

            UrlContext.Stub(_baseAddress);

            _services  = _runtime.Factory.Get <IServiceLocator>();
            _endpoints = new EndpointDriver(_urls);
        }
예제 #9
0
        public FubuRuntime(FubuRegistry registry)
        {
            _registry = registry;

            _appFunc = new Lazy <AppFunc>(() => FubuOwinHost.ToAppFunc(this));

            RouteTable.Routes.Clear();

            _diagnostics = new ActivationDiagnostics();

            _perfTimer = _diagnostics.Timer;
            _perfTimer.Start("FubuRuntime Bootstrapping");


            var packageAssemblies = AssemblyFinder.FindModuleAssemblies(_diagnostics);

            var applicationPath = registry.RootPath ?? DefaultApplicationPath();

            _files = new FubuApplicationFiles(applicationPath);

            _perfTimer.Record("Applying IFubuRegistryExtension's",
                              () => applyFubuExtensionsFromPackages(_diagnostics, packageAssemblies, registry));

            _container = registry.ToContainer();

            var graph = _perfTimer.Record("Building the BehaviorGraph",
                                          () => BehaviorGraphBuilder.Build(registry, _perfTimer, packageAssemblies, _diagnostics, _files));

            _perfTimer.Record("Registering services into the IoC Container",
                              () => registry.Config.RegisterServices(Mode, _container, graph));

            _factory = new StructureMapServiceFactory(_container);

            var routeTask = _perfTimer.RecordTask("Building Routes", () =>
            {
                var routes = buildRoutes(_factory, graph);
                routes.Each(r => RouteTable.Routes.Add(r));

                return(routes);
            });

            var library = HtmlConventionCollator.BuildHtmlConventions(graph);

            _container.Configure(_ =>
            {
                _.Policies.OnMissingFamily <SettingPolicy>();

                _.For <IFubuApplicationFiles>().Use(_files);
                _.For <IServiceLocator>().Use <StructureMapServiceLocator>();
                _.For <FubuRuntime>().Use(this);
                _.For <IServiceFactory>().Use(_factory);
                _.For <HtmlConventionLibrary>().Use(library);
            });


            Activate();

            _routes = routeTask.Result();



            if (registry.Host != null)
            {
                startHosting();
            }

            _perfTimer.Stop();
            Restarted = DateTime.Now;

            _diagnostics.AssertNoFailures();
        }
예제 #10
0
            public void Configuration(IAppBuilder builder)
            {
                var host = new FubuOwinHost(_routes);

                builder.Run(host);
            }