Esempio n. 1
0
        public void Start(string url)
        {
            serverUrl = url;
            this.Server = new Server(serverUrl);
            // Map the default hub url (/signalr)
            this.Server.MapHubs();

            // Start the server
            this.Server.Start();
            if (SysVars.isConsole)
                Console.WriteLine("Server running on {0}", serverUrl);
        }
Esempio n. 2
0
        public ServerStartup(ServerConfig config, bool enableDiagnostics = false, string diagnosticsPassword = "")
        {
            serverConfig = config;
            sites = new Dictionary<string, WikiSite>();

            // TODO: Investigate event ordering if these two schedulers are in fact the same (slow handling seems to cause notifications out of order)
            notificationScheduler = new EventLoopScheduler(threadStart => new Thread(threadStart) { Name = "NotificationScheduler" });
            modelSyncScheduler = new EventLoopScheduler(threadStart => new Thread(threadStart) { Name = "ModelSyncScheduler" });

            foreach (var wikiConfig in config.AllConfig)
            {
                // get the relevant repositories
                MasterRepository masterRepository;
                IPageCache pageCache;
                if (serverConfig.TryGetMasterRepository(wikiConfig.SiteName, out masterRepository) &&
                    serverConfig.TryGetPageCache(wikiConfig.SiteName, out pageCache))
                {
                    var sourceWatcher = new SourceWatcher(wikiConfig.RootSourcePath, wikiConfig.Convertor.FileSearchString);

                    // create site
                    var site = new WikiSite(wikiConfig, masterRepository, sourceWatcher, pageCache);

                    // subscribe to all the sites events for notification purposes
                    EventHelper.SubscribeToWikiEvent<WikiSiteEventArgs>(site, "PageAdded", notificationScheduler, (args) => HandleEvent(site.Name, args.WikiUrl));
                    EventHelper.SubscribeToWikiEvent<WikiSiteEventArgs>(site, "PageUpdated", notificationScheduler, (args) => HandleEvent(site.Name, args.WikiUrl));
                    EventHelper.SubscribeToWikiEvent<WikiSiteEventArgs>(site, "PageDeleted", notificationScheduler, (args) => HandleEvent(site.Name, args.WikiUrl));
                    EventHelper.SubscribeToWikiEvent<WikiSiteEventArgs>(site, "PageMoved", notificationScheduler, (args) => HandleEvent(site.Name, args.WikiUrl));
                    EventHelper.SubscribeToWikiEvent<WikiSiteEventArgs>(site, "DirectoryAdded", notificationScheduler, (args) => HandleEvent(site.Name, args.WikiUrl));
                    EventHelper.SubscribeToWikiEvent<WikiSiteEventArgs>(site, "DirectoryUpdated", notificationScheduler, (args) => HandleEvent(site.Name, args.WikiUrl));
                    EventHelper.SubscribeToWikiEvent<WikiSiteEventArgs>(site, "DirectoryDeleted", notificationScheduler, (args) => HandleEvent(site.Name, args.WikiUrl));
                    EventHelper.SubscribeToWikiEvent<WikiSiteEventArgs>(site, "DirectoryMoved", notificationScheduler, (args) => HandleEvent(site.Name, args.WikiUrl));

                    // store
                    sites[wikiConfig.SiteName] = site;
                }
            }

            WikiBootstrapper bootstrapper = new WikiBootstrapper(config, enableDiagnostics, diagnosticsPassword);

            nancyHost = new NancyHost(new Uri("http://localhost:8070/"), bootstrapper);
            signalrHost = new Server("http://localhost:8071/");
        }