Esempio n. 1
0
        public static void Main()
        {
            // Start the Nancy server
            HostFactory.Run(x =>
            {
                x.UseLinuxIfAvailable();
                x.Service <NancyHost>(s =>
                {
                    s.ConstructUsing(name => new NancyHost(new Uri("http://localhost:8888")));
                    s.WhenStarted(tc => {
                        _service = DeployService();
                        _service.Deployed.ContinueWith(Console.WriteLine);

                        Console.WriteLine("The service " + MyServiceId + " has been deployed.");

                        tc.Start();
                    });
                    s.WhenStopped(async tc => {
                        Console.WriteLine("Closing the server...");

                        await _service.UndeployService();
                        Console.WriteLine("Server closed and service undeployed.");

                        tc.Stop();
                    });
                });

                x.RunAsLocalSystem();
                x.SetDescription("Nancy-SelfHost example");
                x.SetDisplayName("Nancy-SelfHost Service");
                x.SetServiceName("Nancy-SelfHost");
            });
        }
Esempio n. 2
0
        public static void Main()
        {
            var parameters = new DeployParameters {
                Id       = MyServiceId,
                Path     = "/" + MyServiceId + "/api",
                BasePath = "http://docker.for.mac.localhost:8000",
                Versions = new Versions {
                    Client = "0.0.0",
                    Server = "0.0.1"
                },
                Ui = new UserInterfaceProperties {
                    visible  = true,
                    iconName = "fas fa-hashtag",
                    weight   = 30,
                    label    = new Dictionary <string, string> {
                        { "en-US", "C Sharp" },
                        { "fr-FR", "C Sharp" }
                    }
                }
            };

            var service = new Library.Service(parameters);

            service.Deployed.ContinueWith(Console.WriteLine);
        }