Exemplo n.º 1
0
        public static async Task MainAsync(string[] args)
        {
            var assemblyPath   = (new Uri(Assembly.GetExecutingAssembly().CodeBase)).AbsolutePath;
            var directory      = new FileInfo(assemblyPath).Directory.FullName;
            var twitterMetaDir = Path.Combine(directory, "metatw");
            var jobMetaDir     = Path.Combine(directory, "metajob");

            Directory.CreateDirectory(twitterMetaDir);
            Directory.CreateDirectory(jobMetaDir);

            var builder = new DataAcquisitionServiceWebApiBuilder(args)
                          .AddSingletonService <IDataAcquirer, TwitterDataAcquirer>()
                          .AddSingletonService <IDataAcquirerMetadataContextProvider, TwitterMetadataContextProvider>()
                          .AddSingletonService <TwitterBatchLoaderFactory>()
                          .AddSingletonService <ITwitterContextProvider, TwitterContextProvider>()
                          .AddSingletonService <IDataAcquirerMetadataContext, TwitterMetadataContext>()
                          .ConfigureSpecificOptions <MetadataStorageProxyOptions>("DataAcquisitionService:MetadataStorageProxyOptions")
                          .ConfigureSpecificOptions <FileJsonStorageOptions>("DataAcquisitionService:FileJsonStorageOptions")
                          .PostConfigure <FileJsonStorageOptions>(o => o.Directory = twitterMetaDir)
                          .ConfigureSpecificOptions <DataAcquirerJobFileStorageOptions>("DataAcquisitionService:DataAcquirerJobFileStorageOptions")
                          .ConfigureSpecificOptions <TwitterBatchLoaderOptions>("DataAcquisitionService:TwitterBatchLoaderOptions")
                          .PostConfigure <DataAcquirerJobFileStorageOptions>(o => o.Directory = jobMetaDir);


            var app = builder.BuildWebHost(false);

            await InitializeApplication(app);

            await app.RunAsync();
        }
Exemplo n.º 2
0
        public static async Task MainAsync(string[] args)
        {
            if (args.Contains("--sleep_on_startup"))
            {
                await Task.Delay(TimeSpan.FromSeconds(60));
            }

            //var assemblyPath = (new Uri(Assembly.GetExecutingAssembly().CodeBase)).AbsolutePath;

            var builder = new DataAcquisitionServiceWebApiBuilder(args)
                          .AddSingletonService <IDataAcquirer, RedditDataAcquirer>()
                          //.AddSingletonService<IDataAcquirerMetadataContextProvider, TwitterMetadataContextProvider>()
                          //.AddSingletonService<IDataAcquirerMetadataStorage, TwitterJsonFileMetadataStorage>()
                          .AddSingletonService <RedditContextProvider>()
                          //    .ConfigureSpecificOptions<DataAcquirerJobFileStorageOptions>("DataAcquisitionService:DataAcquirerJobFileStorageOptions")
                          //.PostConfigure<DataAcquirerJobFileStorageOptions>(o => o.Directory = jobMetaDir);
            ;

            var app = builder.BuildWebHost(false);

            await InitializeApplication(app);

            await app.RunAsync();
        }