本文整理汇总了C#中Nancy.Hosting.Self.NancyHost类的典型用法代码示例。如果您正苦于以下问题:C# NancyHost类的具体用法?C# NancyHost怎么用?C# NancyHost使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NancyHost类属于Nancy.Hosting.Self命名空间,在下文中一共展示了NancyHost类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
NancyHost host = new NancyHost(new Uri("http://localhost:8812"));
host.Start();
Console.ReadKey();
}
示例2: OnStart
protected override void OnStart(string[] args)
{
base.OnStart(args);
ConfigureBindings();
var boundUris = HostnameUtil.GetUriParams(4567);
_host = new NancyHost(boundUris);
_host.Start();
_core = _kernel.Get<IMuroCore>();
try
{
if (args.Any())
{
_core.Initialise(args[0]);
}
else
{
_core.Initialise();
}
}
catch (Exception)
{
_core.Shutdown();
throw;
}
}
示例3: Main
static void Main(string[] args)
{
JsonConvert.DefaultSettings = () => new JsonSerializerSettings { Formatting = Formatting.Indented };
using (ActionScheduler scheduler = new ActionScheduler())
using (var host = new NancyHost(new Uri("http://localhost:8090")))
{
host.Start();
Console.WriteLine("Nancy Running at http://localhost:8090");
Console.WriteLine("Press any key to exit");
Process.Start("http://localhost:8090/metrics/");
SampleMetrics.RunSomeRequests();
scheduler.Start(TimeSpan.FromMilliseconds(500), () =>
{
SetCounterSample.RunSomeRequests();
SetMeterSample.RunSomeRequests();
UserValueHistogramSample.RunSomeRequests();
UserValueTimerSample.RunSomeRequests();
SampleMetrics.RunSomeRequests();
});
HealthChecksSample.RegisterHealthChecks();
Console.ReadKey();
}
}
示例4: Start
/// <summary>
/// 监听端口 启动站点
/// </summary>
/// <param name="urls">监听ip端口列表</param>
public static NancyHost Start(int port)
{
try
{
_host = new NancyHost(new Uri(string.Format("http://localhost:{0}", port)));
_host.Start();
LogHelper.WriteLog("Web管理站点启动成功,请打开 http://127.0.0.1:" + port + "进行浏览");
if (SystemConfig.WebPort != port)
{
//更新系统参数配置表监听端口
SystemConfig.WebPort = port;
ConfigManager.UpdateValueByKey("SystemConfig", "WebPort", port.ToString());
}
return _host;
}
catch (HttpListenerException ex)
{
LogHelper.WriteLog("Web管理站点启动失败", ex);
Random random = new Random();
port = random.Next(port - 1000, port + 1000);
Console.WriteLine(ex.Message);
Console.WriteLine(" 重新尝试端口:" + port);
return Start(port);
}
catch (Exception ex)
{
LogHelper.WriteLog("Web管理站点启动失败", ex);
throw ex;
}
}
示例5: Main
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();
}
}
}
示例6: Main
static void Main(string[] args)
{
var ip = "10.0.1.15";
var port = "3580";
var selection = "";
Console.WriteLine("Enter IP address. Default is 10.0.1.15");
selection = Console.ReadLine();
if (!string.IsNullOrEmpty(selection))
ip = selection;
Console.WriteLine("Enter port. Default is 3580");
selection = Console.ReadLine();
if (!string.IsNullOrEmpty(selection))
port = selection;
var uri = new Uri(string.Format("http://{0}:{1}",ip, port));
RegisterService(ip, port);
using (var host1 = new NancyHost(uri))
//using (var customerService = new CustomerServiceReciever(busFactory, translationService))
{
host1.Start();
Console.WriteLine("Your application is running on " + uri);
Console.ReadLine();
}
}
示例7: Main
static void Main(string[] args)
{
// Note: The URI must *exactly* match the one specified in the URL ACL.
// This leads to a problem when you use +, because the Uri constructor doesn't like it.
var uri = "http://localhost:1234/";
if (args.Length != 0)
uri = args[0];
var stop = new ManualResetEvent(false);
Console.CancelKeyPress += (sender, e) =>
{
Console.WriteLine("^C");
stop.Set();
};
var host = new NancyHost(new Uri(uri));
host.Start();
Console.WriteLine("Nancy Self Host listening on {0}", uri);
Console.WriteLine("Press Ctrl+C to quit.");
stop.WaitOne();
host.Stop();
}
示例8: Main
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;
}
示例9: Main
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++;
}
}
}
示例10: Init
public void Init()
{
_host = new NancyHost(new Uri(RestBaseUrl));
_host.Start();
StartHub();
}
示例11: Start
public void Start()
{
Log.Debug("Starting self hosted website");
_nancyHost = new Nancy.Hosting.Self.NancyHost(new Uri("http://localhost:1234"));
_nancyHost.Start();
Log.Debug("Done starting self hosted website");
}
示例12: Run
public void Run()
{
EnsureInstallation();
foreach (var service in _services)
{
Console.WriteLine("Starting service {0}", service.ServiceName);
service.Start();
}
_nancy = new NancyHost(_uris);
_nancy.Start();
Console.WriteLine("Running server at {0}", string.Join(", ", _uris
.Select(u => u.ToString())
));
Console.ReadLine();
Console.WriteLine("Stopping server");
_nancy.Stop();
foreach (var service in _services)
{
Console.WriteLine("Stopping service {0}", service.ServiceName);
service.Stop();
}
}
示例13: Run
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();
}
示例14: WebServer
public WebServer(INancyBootstrapper bootstrapper)
{
_nancyHost = new NancyHost(new Uri("http://localhost:1234"), bootstrapper, new HostConfiguration
{
RewriteLocalhost = false
});
}
示例15: Main
static void Main(string[] args)
{
/***
* Note:
* When using multiple network interfaces, you should not use localhost but a fully qualified ip (v4)
*
***/
//SSL: For SSL on Windows rewrite http to https
var uri = new Uri("http://localhost:"+ConvenienceSystemBackendServer.ConvenienceServer.getPort());
//var uri = new Uri("http://192.168.1.39:" + ConvenienceSystemBackendServer.ConvenienceServer.getPort());
using (var host = new NancyHost(uri))
{
host.Start();
Console.WriteLine("Your application is running on " + uri);
/*Console.WriteLine("Enter 'q' and press [Enter] to close the host.");
while (true)
{
string line = Console.ReadLine();
if (line == "q")
break;
}*/
while (true)
Thread.Sleep(50000);
/*
* Remark:
* using Sleep here because ReadLine/yield on Unix/Linux often has problems with nohup execution resulting in continously high load on the server
*/
}
}