static void Main(string[] args)
        {
            var parsedArgs = Parser.Default.ParseArguments<Options> (args);

            if (!parsedArgs.Errors.Any () && parsedArgs.Value != null) {
                var options = parsedArgs.Value;

                var domain = options.Domain ?? ConfigurationManager.AppSettings.Get ("Nancy.Host") ?? "127.0.0.1";
                var port = options.Port ?? ConfigurationManager.AppSettings.Get ("Nancy.Port") ?? "9999";

                var uri = new Uri ("http://" + domain + ":" + port);

                var configuration = new HostConfiguration();
                configuration.UnhandledExceptionCallback = HandleException;

                // initialize an instance of NancyHost (found in the Nancy.Hosting.Self package)
                var nancyHost = new NancyHost (new Bootstrapper (), uri);

                nancyHost.Start (); // start hosting

                while (true) {
                    Thread.Sleep (10000000);
                }

                nancyHost.Stop (); // stop hosting
            }
        }
Exemple #2
0
        public static void Main(string[] args)
        {
            Config.LoadFromAppSettings();
            GenericFileResponse.SafePaths.Add(Config.PackageRepositoryPath);

            HostConfiguration hostConfigs = new HostConfiguration()
            {
                UrlReservations = new UrlReservations() { CreateAutomatically = true }
            };

            using (var host = new NancyHost(new Uri(string.Format("http://localhost:{0}", Config.Port)), new NusharpBootstrapper(), hostConfigs))
            {
                host.Start();

                //Under mono if you daemonize a process a Console.ReadLine will cause an EOF
                //so we need to block another way
                if (args.Any(s => s.Equals("-d", StringComparison.CurrentCultureIgnoreCase)))
                {
                    Thread.Sleep(Timeout.Infinite);
                }
                else
                {
                    Console.ReadKey();
                }

                host.Stop();
            }
        }
Exemple #3
0
        static void Main(string[] args)
        {
            var url = "https://localhost:44388";

            var uri =
                new Uri(url);

            var config = new HostConfiguration
            {
                UrlReservations = new UrlReservations
                {
                    CreateAutomatically = true
                }
            };

            using (WebApp.Start<Startup>(url))
            {
                Console.WriteLine("Running on {0}", url);
                Console.WriteLine("Press enter to exit");
                Console.ReadLine();
            }

            //using (var host = new NancyHost(config, uri))
            //{
            //    host.Start();

            //    Console.WriteLine("Your application is running on " + uri);
            //    Console.WriteLine("Press any [Enter] to close the host.");
            //    Console.ReadLine();
            //}
        }
        public static void Main (string[] args)
        {
            var hostConfiguration = new HostConfiguration
            {
                UrlReservations = new UrlReservations() { CreateAutomatically = true }
            };

            var nancyHost = new NancyHost(hostConfiguration,
                new Uri("http://localhost:8080/"));

            nancyHost.Start();
            
            Console.WriteLine("Nancy now listening at http://localhost:8080/. Press enter to stop");
            ConsoleKeyInfo key = Console.ReadKey();
            if ((int)key.Key == 0) 
            {
                // Mono returns a ConsoleKeyInfo with a Key value of 0 when stdin is redirected
                // See https://bugzilla.xamarin.com/show_bug.cgi?id=12551
                // For now, just sleep, so that we can run in background with nohup
                Thread.Sleep(Timeout.Infinite);
            }
            
            nancyHost.Stop();
            Console.WriteLine("Stopped. Good bye!");
        }
        public void Configure(NancyServiceConfiguration nancyServiceConfiguration)
        {
            var nancyHostConfiguration = new HostConfiguration();

            if (nancyServiceConfiguration.NancyHostConfigurator != null)
            {
              nancyServiceConfiguration.NancyHostConfigurator(nancyHostConfiguration);
            }

            NancyServiceConfiguration = nancyServiceConfiguration;
            NancyHostConfiguration = nancyHostConfiguration;

            _urlReservationsHelper = new UrlReservationsHelper(NancyServiceConfiguration.Uris, NancyHostConfiguration);


            NancyHost = new Lazy<NancyHost>(() => {
                if (NancyServiceConfiguration.Bootstrapper != null)
                {
                  return new NancyHost(NancyServiceConfiguration.Bootstrapper, NancyHostConfiguration, NancyServiceConfiguration.Uris.ToArray());
                }
                else
                {
                  return new NancyHost(NancyHostConfiguration, NancyServiceConfiguration.Uris.ToArray());
                }
              });
        }
        public static void Main(string[] args)
        {
            var logger = LogManager.GetLogger("ServerStartup");

            try
            {
                LoadApplicationConfiguration(args);
            }
            catch(Exception ex) when (ex is FileNotFoundException || ex is InvalidOperationException || ex is JsonReaderException) 
            {
                logger.Error("Cannot load configuration file!");
                logger.Error(ex);
                return;
            }

            logger.Info($"Using {Configuration.ConfigFileName} configuration file.");

            Uri nancyUri = new Uri(Configuration.MockUri);
            //Starting Nancy self-hosted process
            HostConfiguration nancyConfig = new HostConfiguration() { RewriteLocalhost = false };
            using(var host = new NancyHost(nancyConfig, nancyUri))
            {
                host.Start();
                logger.Info($"Nancy server is listening on \"{nancyUri}\". Press [anything] Enter to stop the server!");
                Console.ReadLine();
            }
        }
        static void Main(string[] args)
        {
            int port = args.Length > 0
                ? int.Parse(args[0])
                : TestingPort;
            StartupKey = args.Length > 1
                ? args[1]
                : null;

            var address = string.Format("http://localhost:{0}", port);

            var hostConfig = new HostConfiguration
            {
                UrlReservations = new UrlReservations
                {
                    CreateAutomatically = true
                }
            };
            using (var host = new NancyHost(hostConfig, new Uri(address)))
            {
                host.Start();

                Console.WriteLine("started {0} {1}", port, StartupKey);

                while (true)
                {
                    Thread.Sleep(1000);
                }
            }
        }
Exemple #8
0
        private void ThreadBegin()
        {
            HostConfiguration config = new HostConfiguration();
            config.UrlReservations.CreateAutomatically = true;

            // TODO: Allow user to change the port
            using (var host = new NancyHost(config, new Uri("http://localhost:8957")))
            {
                try
                {
                    host.Start();

                    // Keep the server thread alive
                    while (true);
                }
                catch (AutomaticUrlReservationCreationFailureException ex)
                {
                    Logger.Log("Couldn't start HTTP server on this port");

                    MessageBox.Show(
                        "Couldn't start HTTP server on this port",
                        "Error",
                        MessageBoxButton.OK,
                        MessageBoxImage.Error
                    );
                }
            }
        }
Exemple #9
0
        /// <summary>
        /// Start hosting the application.
        /// </summary>
        /// <param name="arguments">
        /// The arguments.
        /// </param>
        public static void Main(string[] arguments)
        {
            var url = new Uri(ConfigurationManager.AppSettings["HostUrl"]);

            var configuration = new HostConfiguration
            {
                UnhandledExceptionCallback = exception => Console.WriteLine(exception)
            };

            var host = new NancyHost(configuration, url);

            host.Start();

            if (arguments.Any(s => s.Equals("-d", StringComparison.CurrentCultureIgnoreCase)))
            {
                Thread.Sleep(Timeout.Infinite);
            }
            else
            {
                Console.WriteLine("Server running on {0}, press Enter to exit...", url);

                Console.ReadLine();
            }

            host.Stop();
        }
        public static void Main(string[] args)
        {
            // bool from configuration files.
            OsmSharp.Service.Tiles.ApiBootstrapper.BootFromConfiguration();

            // start listening.
            var uri = new Uri("http://localhost:1234");
            HostConfiguration configuration = new HostConfiguration();
            configuration.UrlReservations.CreateAutomatically = true;
            using (var host = new NancyHost(configuration, uri))
            {
                try
                {
                    host.Start();

                    Console.WriteLine("The OsmSharp routing service is running at " + uri);
                    Console.WriteLine("Press [Enter] to close the host.");
                    Console.ReadLine();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    Console.WriteLine("Press [Enter] to close the host.");
                    Console.ReadLine();
                }
            }
        }
Exemple #11
0
        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
            _container = container;

            var configuration = new HostConfiguration() { UrlReservations = { CreateAutomatically = true } };
            container.Register(configuration);

            //register dependencies

            IRepository<User> userRepository = new UserRepository(_mongoEndpoint);
            IRepository<Meeting> meetingRepository = new MeetingRepository(_mongoEndpoint);

            IUserService userService = new UserService(userRepository);
            IMeetingService meetingService = new MeetingService(meetingRepository,userService);

            container.Register(userService);
            container.Register(meetingService);

            pipelines.AfterRequest += (ctx) =>
            {
                ctx.Response.Headers.Add("Access-Control-Allow-Origin", "*");
                ctx.Response.Headers.Add("Access-Control-Allow-Methods", "POST,GET,PUT,DELETE,OPTIONS");
                ctx.Response.Headers.Add("Access-Control-Allow-Headers", "Accept, Origin, Content-type,Authorization");
            };

            base.ApplicationStartup(container, pipelines);
        }
        static int Main(string[] args)
        {
            if (args.Length == 0 ||
                string.IsNullOrEmpty(UserKey = args[0]))
            {
                Console.WriteLine("userKey argument is required");
                return 1;
            }

            const int port = 40001;
            var address = string.Format("http://localhost:{0}", port);

            var hostConfig = new HostConfiguration
            {
                UrlReservations = new UrlReservations
                {
                    CreateAutomatically = true
                }
            };

            using (var host = new NancyHost(hostConfig, new Uri(address)))
            {
                host.Start();
                var scheduler = ApiBootstrapper.Container.Resolve<Scheduler>();

                Console.WriteLine("started {0}", port);

                while (scheduler.State != SystemState.Finished)
                {
                    Thread.Sleep(1000);
                }
            }

            return 0;
        }
Exemple #13
0
        static void Main(string[] args)
        {
            var port = 3400;
            HostConfiguration hostConfigs = new HostConfiguration();
            hostConfigs.UrlReservations.CreateAutomatically = true;

            while (true)
            {
                try
                {
                    using (var host = new NancyHost(hostConfigs, new Uri("http://localhost:" + port)))
                    {
                        host.Start();

                        Console.WriteLine("Your application is running on port " + port);
                        Console.WriteLine("Press any key to close the host.");
                        Console.ReadKey();
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    port++;
                }
            }
        }
Exemple #14
0
        private static void Main(string[] args)
        {
            if (args.Length != 2 && args.Length != 3)
            {
                Console.WriteLine("WelcomePage.WebServer url root-directory [-open]");
                return;
            }

            var url = new Uri(args[0]);
            var rootDirectory = args[1];
            bool openBrowser = args.Length == 3 && args[2].Equals("-open", StringComparison.InvariantCultureIgnoreCase);

            var stop = new ManualResetEvent(false);
            Console.CancelKeyPress += (sender, e) =>
                {
                    Console.WriteLine("^C");
                    stop.Set();
                };

            var bootstrapper = new Bootstrapper(rootDirectory);
            var configuration = new HostConfiguration { RewriteLocalhost = false };
            var host = new NancyHost(bootstrapper, configuration, url);
            host.Start();
            Console.WriteLine("Nancy host listening on '{0}'. Press Ctrl+C to quit.", url);

            if (openBrowser)
                Process.Start(url.ToString());

            stop.WaitOne();

            host.Stop();
        }
Exemple #15
0
        static void Main(string[] args) {

#if DEBUG
            var db = Data.DbContent.GetInstance();
            if (db.GetAll<Data.Models.ArticlecModel>().Count() < 1) {
                var ariclecsContent = System.IO.File.ReadAllText("Test.md");
                for (int i = 0; i < 5; i++) {
                    db.Insert(new Data.Models.ArticlecModel {
                        Id = Guid.NewGuid(),
                        Title = $"Cozy{i}",
                        SubTitle = $"Cozy-readme{i}",
                        Content = ariclecsContent,
                        CreateDate = DateTime.Now,
                        UpdateDate = DateTime.Now
                    });
                }
            }
#endif

            var baseUrl = "http://localhost:1024/";

            HostConfiguration hostconfig = new HostConfiguration() {
                UrlReservations = new UrlReservations { CreateAutomatically = true }
            };

            using (var host = new NancyHost(new Url(baseUrl), new DefaultNancyBootstrapper(), hostconfig)) {
                host.Start();
                //Process.Start(baseUrl);
                Console.WriteLine("CozyMarkdown is runing , Press enter to stop");
                Console.ReadKey();

            }

        }
        public void Run(CancellationToken cancellationToken)
        {
            if (cancellationToken.IsCancellationRequested)
                return;

            var nancyConfig = new HostConfiguration
            {
                UrlReservations = new UrlReservations
                {
                    CreateAutomatically = true
                }
            };

            var bootstrapper = new ApiBootstrapper(_repository);

            var host = new NancyHost(bootstrapper, nancyConfig, _baseUri);
            cancellationToken.Register(() =>
            {
                Log.InfoFormat("Stopping Nancy host at \"{0}\".", _baseUri);
                host.Stop();
                Log.InfoFormat("Nancy host at \"{0}\" successfully stopped.", _baseUri);
            });

            Log.InfoFormat(CultureInfo.InvariantCulture, "Starting Nancy host at \"{0}\".", _baseUri);
            host.Start();
        }
Exemple #17
0
 static void Main(string[] args)
 {
     var config = new HostConfiguration()
     {
         UrlReservations = new UrlReservations
         {
             CreateAutomatically = true
         }
     };
     var container = MainContainer.Instance.Container;
     var serverUrl = container.Resolve<IApplicationParameters>().ServerURL;
     try
     {
         using (var host = new NancyHost(config, new Uri(serverUrl)))
         {
             host.Start();
             Console.WriteLine("Server is running: {0}", serverUrl);
             var backgroundTask = new BgTask(MainContainer.Instance);
             backgroundTask.Start();
             Console.WriteLine("Background process started");
             Console.WriteLine("Press ENTER to stop the server...");
             Console.ReadLine();
             Console.WriteLine("Exiting...");
             backgroundTask.Stop();
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("Couldn't start the server with this Url: {0}", serverUrl);
     }
 }
Exemple #18
0
 public void Start()
 {
     if (mutex.WaitOne(TimeSpan.Zero, true))
     {
         try
         {
             Log.Write("Starting on " + ServiceUrl);
             var config = new HostConfiguration
             {
                 UnhandledExceptionCallback = e => Log.Error("Self Host Exception", e)
             };
             nancyHost = new NancyHost(config, new Uri(ServiceUrl));
             nancyHost.Start();
         }
         catch (Exception ex)
         {
             Log.Error("Starting ThumbsUp", ex);
         }
         finally
         {
             mutex.ReleaseMutex();
         }
     }
     else
     {
         Log.Write("Cannot start multiple instances. The ThumbsUp Service is already running on " + ServiceUrl);
         Environment.Exit(0);
     }
 }
Exemple #19
0
        internal string StartWebService()
        {
            var config = new HostConfiguration();
            config.UrlReservations.CreateAutomatically = false;
            config.RewriteLocalhost = false;

            var freeTcpPort = FreeTcpPort(90210);

            var networkAddress = InterNetworkAddress();

            HostBase = String.Format("http://{0}:{1}", networkAddress, freeTcpPort);

            var baseUri = new Uri(HostBase);
            Host = new NancyHost(baseUri, new WebBootstrapper(), config);

            try
            {

                Host.Start();

            }
            catch (Exception)
            {
                networkAddress = "localhost";
                HostBase = String.Format("http://{0}:{1}", networkAddress, freeTcpPort);
                baseUri = new Uri(HostBase);
                Host = new NancyHost(baseUri, new WebBootstrapper(), config);
                Host.Start();
            }

            Debug.Print("Web server running...");

            return HostBase;
        }
Exemple #20
0
        static void Main(string[] args)
        {
            system = ActorSystem.Create("MySystem");
            system.ActorOf <DummyActor>("greeter");
            var sqs = system.ActorOf <SqsActor> ("sqs");

            sqs.Tell("aaa");

            var hostconfig = new Nancy.Hosting.Self.HostConfiguration();

            hostconfig.UrlReservations.CreateAutomatically = true;
            var nancyHost = new NancyHost(hostconfig, new Uri("http://localhost:80/nancy/"));

            nancyHost.Start();

            Console.WriteLine("Nancy now listening - navigating to http://localhost:80/nancy/. Press enter to stop");
            //Process.Start("http://localhost:8888/nancy/");
            string a = "none";

            while (a != "quit")
            {
                a = Console.ReadLine();
            }

            nancyHost.Stop();

            Console.WriteLine("Stopped. Good bye!");
        }
Exemple #21
0
        public static void Main(string[] args)
        {
            string adminSecret;
            if (args.Length > 0) {
                adminSecret = args.First();
            } else {
                adminSecret = null;//Make admin inaccessible
            }
            Console.WriteLine("Admin access {0}abled.", adminSecret != null ? "en" : "di");
            var bindUri = new Uri("http://localhost:3000");
            var bootstrapper = new Bootstrapper(adminSecret);
            var hostConfiguration = new HostConfiguration {
                RewriteLocalhost = true,
            };

            StaticConfiguration.EnableHeadRouting = true;
            hostConfiguration.UrlReservations.CreateAutomatically = true;
            using (var host = new NancyHost(baseUri: bindUri, bootstrapper: bootstrapper, configuration: hostConfiguration)) {
                host.Start();
                Console.WriteLine("Host running...");
                while (Console.ReadKey(true).KeyChar != 'q') {
                    Thread.Sleep(250);
                };
            }
        }
Exemple #22
0
        static void Main(string[] args)
        {
            Logging.Log.Info("Starting AnimeRecs web app");

            HostConfiguration config = new HostConfiguration()
            {
                RewriteLocalhost = false
            };

            string portString = ConfigurationManager.AppSettings["Hosting.Port"];
            uint port;
            if (!uint.TryParse(portString, out port))
            {
                throw new Exception("Hosting.Port is not a valid port number.");
            }

            using (var host = new NancyHost(config, new Uri(string.Format("http://localhost:{0}", port))))
            {
                host.Start();
                Logging.Log.InfoFormat("Started listening on port {0}", port);
            #if MONO
                    WaitForUnixStopSignal();
            #else
                Console.ReadLine();
            #endif
                Logging.Log.Info("Got stop signal, stopping web app");
            }
        }
        protected TestsBase()
        {
            var config = new HostConfiguration { UrlReservations = { CreateAutomatically = true } };

            ServerUrl = "http://localhost:50502";
            _host = new NancyHost(config, new Uri(ServerUrl));
            _host.Start();
        }
        public static void Start(string url, ushort port)
        {
            var config = new HostConfiguration {RewriteLocalhost = false};

            Server?.Stop();
            Server = new NancyHost(config, new Uri($"http://{url}:{port}/"));
            Server.Start();
        }
 public void TestFixtureSetUp()
 {
     var hostConfiguration = new HostConfiguration {UrlReservations = new UrlReservations {CreateAutomatically = true}};
     var baseAddress = new Uri("http://127.0.0.1:1337/");
     host = new NancyHost(hostConfiguration, baseAddress);
     host.Start();
     AsyncClient = new AsyncClient(baseAddress);
 }
Exemple #26
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NancyHost"/> class for the specfied <paramref name="baseUris"/>, using
        /// the provided <paramref name="bootstrapper"/>.
        /// Uses the specified configuration.
        /// </summary>
        /// <param name="bootstrapper">The bootstrapper that should be used to handle the request.</param>
        /// <param name="configuration">Configuration to use</param>
        /// <param name="baseUris">The <see cref="Uri"/>s that the host will listen to.</param>
        public NancyHost(INancyBootstrapper bootstrapper, HostConfiguration configuration, params Uri[] baseUris)
        {
            this.configuration = configuration ?? new HostConfiguration();
            this.baseUriList = baseUris;

            bootstrapper.Initialise();
            this.engine = bootstrapper.GetEngine();
        }
Exemple #27
0
 public static void Run(string uri)
 {
     HostConfiguration hostConfigs = new HostConfiguration()
     {
         UrlReservations = new UrlReservations() { CreateAutomatically = true }
     };
     var host = new NancyHost(new Uri(uri), new DefaultNancyBootstrapper(), hostConfigs);
     host.Start();
 }
Exemple #28
0
        static void Main(string[] args)
        {
            #region cmd 파싱
            if (args.Length > 0)
            {
                try
                {
                    port = Convert.ToUInt16(args[0]);
                }
                catch
                {
                    Console.WriteLine("○ 잘못된 인자 \"" + args[0] + "\"");
                    Console.WriteLine("  포트번호를 입력해야합니다. ( ex: 64401 )");
                }
            }
            #endregion

            #region 호스팅 루프
            // NancyHost 인스턴스 초기화 (Nancy.Hosting.Self 패키지 안에있음)
            var uri = new Uri(string.Format("http://localhost:{0}/", port));
            var config = new HostConfiguration();
            config.UrlReservations.CreateAutomatically = true;

            var host = new NancyHost(config, uri);

            try
            {
                // 호스팅 시작
                host.Start();
                Console.WriteLine("● 호스팅 시작 ─ \"" + uri + "\"");

                // Under mono if you deamonize a process a Console.ReadLine with cause an EOF
                // so we need to block another way
                if (args.Any(s => s.Equals("-d", StringComparison.CurrentCultureIgnoreCase)))
                {
                    Thread.Sleep(Timeout.Infinite);
                }
                else
                {
                    Console.WriteLine("○ 프로세스를 종료하려면 \"" + escapeCmd + "\"를 입력하세요.");
                    while (Console.ReadLine() != escapeCmd) ;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("◎ 예외 발생!");
                Console.WriteLine(e.Message);
                Console.ReadKey(true);
            }
            finally
            {
                // 호스팅 멈춤
                host.Stop();
            }
            #endregion
        }
Exemple #29
0
        static void Main(string[] args) {
            var hostConfiguration = new HostConfiguration();
            hostConfiguration.UrlReservations.CreateAutomatically = true;

            using (var host = new NancyHost(hostConfiguration, new Uri(url))) {
                host.Start();
                Console.WriteLine("Running on " + url);
                Console.ReadLine();
            }
        }
Exemple #30
0
        public void Starten()
        {
            var endpunktAdresse = ConfigurationManager.AppSettings.Get("servicedesk.endpunkt");
            _ts.TraceEvent(TraceEventType.Information, 0, "Serverportal des service desk starten auf {0}", endpunktAdresse);

            var nancyCfg = new HostConfiguration { UrlReservations = { CreateAutomatically = true } };
            _server = new NancyHost(nancyCfg, new Uri(endpunktAdresse));
            _server.Start();
            _ts.TraceEvent(TraceEventType.Start, 1, "Serverportal des service desk gestartet");
        }
Exemple #31
0
        public void Setup() {
            var hostConfiguration = new HostConfiguration();
            hostConfiguration.UrlReservations.CreateAutomatically = true;

            host = new NancyHost(hostConfiguration, new Uri("http://localhost:3579"));
            host.Start();
            new UrlMapping();  // Force assembly shorty.exe to load by referencing one of its types

            edgeDriver = new EdgeDriver();
        }
Exemple #32
0
    public void RunWebService()
    {
        int port = 50005;

        int.TryParse(BauerLib.Registry.ServicePort, out port);

        if (PortInUse(port))
        {
            log.ErrorFormat("Error {0} in use !", port);
            return;
        }

        string baseAddress = string.Format("http://localhost:{0}/", port);

        DotLiquid.Template.NamingConvention = new DotLiquid.NamingConventions.CSharpNamingConvention();

        Nancy.Hosting.Self.HostConfiguration hostConfigs = new Nancy.Hosting.Self.HostConfiguration();

        // netsh http add urlacl url=http://+:50005/ user=EVERYONE
        // netsh http add urlacl url=http://+:50005/ user=JEDER
        hostConfigs.UrlReservations.CreateAutomatically = false;
        hostConfigs.RewriteLocalhost = true;

        int retries = 6;

        while (retries > 0)
        {
            try
            {
                host = new Nancy.Hosting.Self.NancyHost(hostConfigs, new Uri(baseAddress));
                host.Start();

                retries = -1;
            }
            catch (Exception ex)
            {
                log.Error($"Error starting web-service ({ex.Message})", ex);
                retries--;
                if (retries <= 3)
                {
                    hostConfigs.UrlReservations.CreateAutomatically = true;
                }

                System.Threading.Thread.Sleep(500);
            }
        }
        log.InfoFormat("Running on {0}", baseAddress);

        if (Environment.UserInteractive)
        {
            System.Diagnostics.Process.Start(baseAddress);
        }
    }
        public RestApiServer(SimVarWrapper sim)
        {
            _sim = sim;

            RestModule.Sim = sim;

            var config = new Nancy.Hosting.Self.HostConfiguration();

            config.UrlReservations.CreateAutomatically = true;

            _host = new NancyHost(config, new Uri("http://localhost:29785"));

            _host.Start();
        }
Exemple #34
0
        public void Start()
        {
            Nancy.Hosting.Self.HostConfiguration nancyConfig = new Nancy.Hosting.Self.HostConfiguration()
            {
                UrlReservations = new UrlReservations()
                {
                    CreateAutomatically = true
                }
            };

            _nancyHost = new NancyHost(_bootstrapper, nancyConfig, new Uri(
                                           $"http{(_config.Hosting.UseSSL ? "s" : "")}://{_config.Hosting.HostName}:{_config.Hosting.Port}"));

            // Create the VSIX feed
            _vsixStorageWatcher = new VsixStorageWatcher(_config.Storage, _config.Gallery);
            _vsixStorageWatcher.Start();
            _nancyHost.Start();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="NancyHost"/> class for the specified <paramref name="baseUris"/>.
 /// Uses the specified configuration.
 /// </summary>
 /// <param name="baseUris">The <see cref="Uri"/>s that the host will listen to.</param>
 /// <param name="configuration">Configuration to use</param>
 public NancyHost(HostConfiguration configuration, params Uri[] baseUris)
     : this(NancyBootstrapperLocator.Bootstrapper, configuration, baseUris)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="NancyHost"/> class for the specified <paramref name="baseUri"/>, using
 /// the provided <paramref name="bootstrapper"/>.
 /// Uses the specified configuration.
 /// </summary>
 /// <param name="baseUri">The <see cref="Uri"/> that the host will listen to.</param>
 /// <param name="bootstrapper">The bootstrapper that should be used to handle the request.</param>
 /// <param name="configuration">Configuration to use</param>
 public NancyHost(Uri baseUri, INancyBootstrapper bootstrapper, HostConfiguration configuration)
     : this(bootstrapper, configuration, baseUri)
 {
 }