/// <summary>
        /// Spins a in-process webserver.
        /// </summary>
        /// <param name="path"></param>
        public static void Serve(DirectoryInfo path)
        {
            // Load the project and fetch the files
            using (var project = SiteProject.FromDisk(path))
            {
                // Rebuid everything first
                SiteProject.Bake(path, BakeMode.Fast);

                // Register the handler
                Service.Http.Register(new SiteHandler(project));

                // Spin Spike Engine on this thread
                Service.Listen(
                    new TcpBinding(IPAddress.Any, project.Configuration.Port)
                    );
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            var options = new Options();

            if (args.Length == 0)
            {
                Console.Write(options.GetUsage());
            }

            if (CommandLine.Parser.Default.ParseArguments(args, options))
            {
                try
                {
                    if (options.Bake != null)
                    {
                        // Bake is requested
                        SiteProject.Bake(new DirectoryInfo(options.Bake), BakeMode.Optimized);
                    }
                    else if (options.Serve != null)
                    {
                        // Serve is requested
                        SiteProject.Serve(new DirectoryInfo(options.Serve));
                    }
                    else if (Debugger.IsAttached)
                    {
                        // Under debugger, just serve
                        SiteProject.Serve(new DirectoryInfo(@"..\..\..\Test\"));
                    }
                }
                catch (Exception ex)
                {
                    Tracing.Error("Baker", ex.Message);
                    Tracing.Error("Baker", ex.StackTrace);
                }
            }
        }