/** Run couchdb-lucene. */ public static void main(String[] args) throws Exception { final HierarchicalINIConfiguration configuration = new HierarchicalINIConfiguration( Main.class.getClassLoader().getResource("couchdb-lucene.ini")); configuration.setReloadingStrategy(new FileChangedReloadingStrategy()); final File dir = new File(configuration.getString("lucene.dir", "indexes")); if (dir == null) { LOG.error("lucene.dir not set."); System.exit(1); } if (!dir.exists() && !dir.mkdir()) { LOG.error("Could not create " + dir.getCanonicalPath()); System.exit(1); } if (!dir.canRead()) { LOG.error(dir + " is not readable."); System.exit(1); } if (!dir.canWrite()) { LOG.error(dir + " is not writable."); System.exit(1); } LOG.info("Index output goes to: " + dir.getCanonicalPath()); final Server server = new Server(); final SelectChannelConnector connector = new SelectChannelConnector(); connector.setHost(configuration.getString("lucene.host", "localhost")); connector.setPort(configuration.getInt("lucene.port", 5985)); LOG.info("Accepting connections with " + connector); server.setConnectors(new Connector[] {connector}); server.setStopAtShutdown(true); server.setSendServerVersion(false); HttpClientFactory.setIni(configuration); final HttpClient httpClient = HttpClientFactory.getInstance(); final LuceneServlet servlet = new LuceneServlet(httpClient, dir, configuration); final Context context = new Context(server, "/", Context.NO_SESSIONS | Context.NO_SECURITY); context.addServlet(new ServletHolder(servlet), "/*"); context.addFilter(new FilterHolder(new GzipFilter()), "/*", Handler.DEFAULT); context.setErrorHandler(new JSONErrorHandler()); server.setHandler(context); server.start(); server.join(); }