static void Main(string[] args) { // You may need to configure the Windows Namespace reservation to assign // rights to use the port that you set below. // See: https://github.com/NancyFx/Nancy/wiki/Self-Hosting-Nancy // Use cmd.exe or PowerShell in Administrator mode with the following command: // netsh http add urlacl url=http://+:80/ user=Everyone // netsh http add urlacl url=https://+:443/ user=Everyone #if DEBUG int port = 80; bool https = false; #else int port = 443; bool https = true; #endif Topshelf.HostFactory.Run(x => { x.AddCommandLineDefinition("port", p => port = int.Parse(p)); x.AddCommandLineDefinition("https", b => https = bool.Parse(b)); x.ApplyCommandLine(); x.SetStartTimeout(new TimeSpan(0, 1, 0)); x.Service <NancySelfHost>(s => { s.ConstructUsing(name => new NancySelfHost()); s.WhenStarted(tc => tc.Start(https, port)); s.WhenStopped(tc => tc.Stop()); }); x.RunAsPrompt(); //x.RunAsLocalService(); x.SetDisplayName("RhinoCommon Geometry Server"); x.SetServiceName("RhinoCommon Geometry Server"); }); RhinoLib.ExitInProcess(); }
static void Main(string[] args) { try { RhinoLib.LaunchInProcess(RhinoLib.LoadMode.Headless, 0); MeshABrep(); } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.WriteLine("press any key to exit"); Console.ReadKey(); RhinoLib.ExitInProcess(); }
public void Start(bool https, int port) { Console.WriteLine($"Launching RhinoCore library as {Environment.UserName}"); RhinoLib.LaunchInProcess(RhinoLib.LoadMode.Headless, 0); var config = new HostConfiguration(); string address = $"http://localhost:{port}"; if (https) { RunningHttps = true; address = $"https://localhost:{port}"; _nancyHost = new NancyHost(config, new Uri(address), new Uri("http://localhost:80")); } else { _nancyHost = new NancyHost(config, new Uri(address)); } _nancyHost.Start(); Console.WriteLine("Running on " + address); }
public void Start(int http_port) { Log.Information("Launching RhinoCore library as {User}", Environment.UserName); RhinoLib.LaunchInProcess(RhinoLib.LoadMode.Headless, 0); var config = new HostConfiguration(); #if DEBUG config.RewriteLocalhost = false; // Don't require URL registration since geometry service always runs on localhost #endif var listenUriList = new List <Uri>(); if (http_port > 0) { listenUriList.Add(new Uri($"http://localhost:{http_port}")); } if (listenUriList.Count > 0) { _nancyHost = new NancyHost(config, listenUriList.ToArray()); } else { Log.Error("Neither COMPUTE_HTTP_PORT nor COMPIUTE_HTTPS_PORT are set. Not listening!"); } try { _nancyHost.Start(); foreach (var uri in listenUriList) { Log.Information("compute.geometry running on {Uri}", uri.OriginalString); } } catch (AutomaticUrlReservationCreationFailureException) { Log.Error(GetAutomaticUrlReservationCreationFailureExceptionMessage(listenUriList)); Environment.Exit(1); } }
static void Main(string[] args) { Logging.Init(); int backendPort = Env.GetEnvironmentInt("COMPUTE_BACKEND_PORT", 8081); Topshelf.HostFactory.Run(x => { x.UseSerilog(); x.ApplyCommandLine(); x.SetStartTimeout(new TimeSpan(0, 1, 0)); x.Service <NancySelfHost>(s => { s.ConstructUsing(name => new NancySelfHost()); s.WhenStarted(tc => tc.Start(backendPort)); s.WhenStopped(tc => tc.Stop()); }); x.RunAsPrompt(); //x.RunAsLocalService(); x.SetDisplayName("compute.geometry"); x.SetServiceName("compute.geometry"); }); RhinoLib.ExitInProcess(); }