コード例 #1
0
 public Kaesereibe(PisstaubeDbContextFactory contextFactory, BeatmapSearchEngine searchEngine)
 {
     _pool           = new List <Thread>();
     _contextFactory = contextFactory;
     _searchEngine   = searchEngine;
     _workerThreads  = int.Parse(Environment.GetEnvironmentVariable("CRAWLER_THREADS"));
 }
コード例 #2
0
ファイル: PrivateAPIController.cs プロジェクト: Tiller431/yes
 public PrivateAPIController(PisstaubeDbContextFactory contextFactory,
                             Storage storage, BeatmapSearchEngine searchEngine, Crawler crawler, Cleaner cleaner,
                             PisstaubeCacheDbContextFactory cache, Kaesereibe reibe)
 {
     _contextFactory = contextFactory;
     _storage        = storage;
     _searchEngine   = searchEngine;
     _crawler        = crawler;
     _cleaner        = cleaner;
     _cache          = cache;
     _reibe          = reibe;
 }
コード例 #3
0
ファイル: SetDownloader.cs プロジェクト: Tiller431/yes
 public SetDownloader(Storage storage,
                      APIAccess apiAccess,
                      PisstaubeDbContextFactory factory,
                      PisstaubeCacheDbContextFactory cfactory,
                      Cleaner cleaner,
                      RequestLimiter limiter,
                      BeatmapSearchEngine search
                      )
 {
     _storage   = storage;
     _apiAccess = apiAccess;
     _factory   = factory;
     _cfactory  = cfactory;
     _cleaner   = cleaner;
     _limiter   = limiter;
     _search    = search;
 }
コード例 #4
0
ファイル: Crawler.cs プロジェクト: Tiller431/yes
 public Crawler(BeatmapSearchEngine search,
                APIAccess apiAccess,
                RulesetStore store,
                BeatmapDownloader downloader,
                PisstaubeCacheDbContextFactory cache,
                RequestLimiter rl,
                PisstaubeDbContextFactory contextFactory)
 {
     _pool           = new List <Thread>();
     _search         = search;
     _apiAccess      = apiAccess;
     _store          = store;
     _downloader     = downloader;
     _cache          = cache;
     _rl             = rl;
     _contextFactory = contextFactory;
     _workerThreads  = int.Parse(Environment.GetEnvironmentVariable("CRAWLER_THREADS"));
 }
コード例 #5
0
        public BMUpdater(PisstaubeDbContextFactory factory,
                         APIAccess apiAccess,
                         BeatmapDownloader bmDl,
                         PisstaubeCacheDbContextFactory cFactory,
                         RulesetStore store,
                         Storage storage,
                         BeatmapSearchEngine search,

                         int limit = 100 /* 100 beatmaps can be updated at the same time per minute! */)
        {
            _factory   = factory;
            _apiAccess = apiAccess;
            _bmDl      = bmDl;
            _cFactory  = cFactory;
            _store     = store;
            _storage   = storage;
            _search    = search;
            _rl        = new RequestLimiter(limit, TimeSpan.FromMinutes(1));
        }
コード例 #6
0
ファイル: Startup.cs プロジェクト: Tiller431/yes
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env,
                              Crawler crawler, APIAccess apiv2, Kaesereibe reibe, BeatmapSearchEngine searchEngine, BMUpdater bmUpdater)
        {
            if (Environment.GetEnvironmentVariable("LOG_LEVEL") != null)
            {
                if (Enum.TryParse(Environment.GetEnvironmentVariable("LOG_LEVEL"), out LogLevel level))
                {
                    Logger.Level = level;
                }
            }

            Logger.Storage = dataStorage.GetStorageForDirectory("logs");

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }

            if (searchEngine.Search("test") == null)
            {
                Logger.LogPrint("Failed to Connect to ElasticSearch!", LoggingTarget.Network, LogLevel.Error);
                Environment.Exit(0);
            }

            apiv2.Login(Environment.GetEnvironmentVariable("OSU_EMAIL"), Environment.GetEnvironmentVariable("OSU_PASSWORD"));

            DogStatsd.Configure(new StatsdConfig {
                Prefix = "pisstaube"
            });

            DogStatsd.ServiceCheck("crawler.is_crawling", Status.UNKNOWN);

            if (Environment.GetEnvironmentVariable("CRAWLER_DISABLED") != "true")
            {
                crawler.BeginCrawling();
            }
            else
            {
                DogStatsd.ServiceCheck("crawler.is_crawling", Status.CRITICAL);
            }

            if (Environment.GetEnvironmentVariable("CHEESEGULL_CRAWLER_DISABLED") != "true")
            {
                reibe.BeginCrawling();
            }
            else
            {
                DogStatsd.ServiceCheck("kaesereibe.is_crawling", Status.CRITICAL);
            }

            if (!Directory.Exists("data"))
            {
                Directory.CreateDirectory("data");
            }

            if (!Directory.Exists("data/cache"))
            {
                Directory.CreateDirectory("data/cache");
            }

            DogStatsd.ServiceCheck("is_active", Status.OK);

            if (Environment.GetEnvironmentVariable("UPDATER_DISABLED") != "true")
            {
                bmUpdater.BeginUpdaterAsync();
            }

            app.UseMvc(routes => routes.MapRoute("default", "{controller=Home}/{action=Index}/{id?}"));
        }
コード例 #7
0
 public SearchController(BeatmapSearchEngine searchEngine, Cache cache)
 {
     _searchEngine = searchEngine;
     _cache        = cache;
 }