Beispiel #1
0
        static public void Run(CommandLineArguments args)
        {
#if DEBUG
            StaticConfiguration.DisableErrorTraces = false;
#endif

            var f = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
            var version = String.Format("{0}.{1}.{2}.{3}", f.ProductMajorPart, f.ProductMinorPart, f.ProductBuildPart, f.ProductPrivatePart);

            IScheduler scheduler = SetupScheduler();
            var url = "http://localhost:2000";

            if (args.UseDebugProfile)
            {
                logger.Info("Using debug profile");
                url = "http://localhost:4000";
                Preferences.UseDebugFolders = true;
                // Nlog to a different file / folder ???
            }

            var config = new HostConfiguration();
//            config.UnhandledExceptionCallback = e => logger.Warn("Nancy exception: {0}", e.ToString());
            using (var nancyHost = new NancyHost(config, new Url(url)))
            {
                try
                {
                    nancyHost.Start();
                }
                catch (SocketException e)
                {
                    logger.Info("Failed starting web service {0}: {1}", e.SocketErrorCode, e.Message);
                    return;
                }
                logger.Info("FindAPhoto {1} listening at {0}", url, version);
                Rangic.Utilities.Geo.OpenStreetMapLookupProvider.UrlBaseAddress = Preferences.Instance.BaseLocationLookup;
                logger.Info("Retrieving location information from {0}", Rangic.Utilities.Geo.OpenStreetMapLookupProvider.UrlBaseAddress);

                if (args.RunAsService)
                {
                    logger.Info("Running as a service");

                    while (true)
                        Thread.Sleep(100);
                }

                Console.ReadLine();
                scheduler.Shutdown();
            }
        }
Beispiel #2
0
        static public void Run(CommandLineArguments args)
        {
            var f = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
            var version = String.Format("{0}.{1}.{2}.{3}", f.ProductMajorPart, f.ProductMinorPart, f.ProductBuildPart, f.ProductPrivatePart);

            Rangic.Utilities.Geo.OpenStreetMapLookupProvider.UrlBaseAddress = Preferences.Instance.MapquestLookupUrl;
            logger.Info("FindAPhoto {0}; Retrieving location information from {1}", version, Rangic.Utilities.Geo.OpenStreetMapLookupProvider.UrlBaseAddress);

            // For each path/alias pair, scan the folder to see what should be added/removed
            if (!Directory.Exists(args.Path))
            {
                logger.Error("Path does not exist: '{0}'", args.Path);
                throw new IndexerException(IndexerException.PathDoesNotExist, "Path does not exist: '{0}'", args.Path);
            }


            logger.Info("Updating repository at {0} with files from {1}", args.Server, args.Path);

            Preferences.Instance.DevelopmentMode = args.Development;
            if (Preferences.Instance.DevelopmentMode)
            {
                Media.IndexName = "dev-" + Media.IndexName;
                logger.Warn("Running with development settings. Index={0}", Media.IndexName);
            }

            // Throw an exception if we can't connect to the server - no need to index in that case
//            var client = FindAPhotoConnectionSettings.Client(args.Server);
//            client.DoRequest<string>("HEAD", "/");
//            var searchQuery = new { query = new { term = new { _id = "2\\DSCN1732.JPG" } } };
//            client.Search<string>(searchQuery);
//
//logger.Error("Finished server check");

            var indexer = new Indexer(args.Server, args.Path, args.Alias, 8);
            indexer.Run();

            logger.Info("[{3} msecs, first search {5} msecs] Scanned {0} folders, {1} files. Examined {2}, indexed {4}.", 
                indexer.FolderCount, 
                indexer.FileCount, 
                indexer.SupportedFileCount,
                indexer.ElapsedMsec,
                indexer.IndexedFileCount,
                indexer.FirstSearchMsec);
        }