Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

merge sbisbee's work + configurable root dirs #148

Open
wants to merge 23 commits into
from
Commits
Jump to file or symbol
Failed to load files and symbols.
+198 −127
Split
View
@@ -2,3 +2,4 @@
* Thanks to Adam Lofts for the performance boosting JSONDocumentAdapter et al.
* Thanks to Santiago M. Mola for the termvector option.
* Thanks to Joe Hillenbrand for adding default result limit to config.
+* Thanks to Sam Bisbee.
@rnewson

rnewson Dec 21, 2011

Owner

You should add yourself too :)

View
@@ -110,6 +110,13 @@
<tika-version>1.0</tika-version>
<jetty-version>6.1.20</jetty-version>
<http-version>4.0.1</http-version>
+ <env>default</env>
+ <destRootDir>/usr/local</destRootDir>
+ <destVarDir>${destRootDir}/var</destVarDir>
+ <destVarLibDir>${destVarDir}/lib</destVarLibDir>
+ <destEtcDir>${destRootDir}/etc</destEtcDir>
+ <destBinDir>${destRootDir}/bin</destBinDir>
+ <destDocDir>${destRootDir}/share/doc</destDocDir>
@rnewson

rnewson Dec 21, 2011

Owner

I'd keep destRootDir and to do the /var etc thing where it's used. The abstraction here isn't useful as these variables almost never vary. It's only the top-level that is altered and {root}/etc, {root}/bin are assumed.

</properties>
<issueManagement>
<system>github</system>
@@ -179,6 +186,7 @@
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
+ <mainClass>com.github.rnewson.couchdb.lucene.Main</mainClass>
</manifest>
</archive>
</configuration>
View
@@ -6,50 +6,54 @@
</formats>
<fileSets>
<fileSet>
+ <directory>${project.basedir}</directory>
+ <outputDirectory>${destDocDir}/couchdb-lucene</outputDirectory>
<includes>
- <include>${project.basedir}/README*</include>
- <include>${project.basedir}/LICENSE*</include>
- <include>${project.basedir}/NOTICE*</include>
+ <include>README*</include>
+ <include>LICENSE*</include>
+ <include>NOTICE*</include>
+ <include>BREAKING_CHANGES*</include>
+ <include>TODO*</include>
+ <include>THANKS*</include>
</includes>
- <outputDirectory>/</outputDirectory>
</fileSet>
</fileSets>
<files>
<file>
- <source>${project.basedir}/src/main/bin/run</source>
+ <source>${project.basedir}/src/main/bin/couchdb-lucene</source>
<fileMode>755</fileMode>
- <outputDirectory>/bin</outputDirectory>
+ <outputDirectory>${destBinDir}</outputDirectory>
@rnewson

rnewson Dec 21, 2011

Owner

i.e, ${destRootDir}/bin

</file>
<file>
<source>${project.basedir}/src/main/bin/kill_ppid</source>
<fileMode>755</fileMode>
- <outputDirectory>/bin</outputDirectory>
+ <outputDirectory>${destVarLibDir}/couchdb-lucene</outputDirectory>
</file>
<file>
<source>${project.basedir}/src/main/resources/couchdb-lucene.ini</source>
<fileMode>644</fileMode>
- <outputDirectory>/conf</outputDirectory>
+ <outputDirectory>${destEtcDir}/couchdb-lucene</outputDirectory>
</file>
<file>
<source>${project.basedir}/src/main/resources/log4j.xml</source>
<fileMode>644</fileMode>
- <outputDirectory>/conf</outputDirectory>
+ <outputDirectory>${destEtcDir}/couchdb-lucene</outputDirectory>
</file>
<file>
<source>${project.basedir}/couchdb-external-hook.py</source>
- <fileMode>777</fileMode>
- <outputDirectory>/tools</outputDirectory>
+ <fileMode>755</fileMode>
+ <outputDirectory>${destBinDir}</outputDirectory>
</file>
<file>
<source>${project.basedir}/src/main/tools/etc/init.d/couchdb-lucene</source>
<fileMode>755</fileMode>
- <outputDirectory>/tools/etc/init.d/couchdb-lucene</outputDirectory>
+ <outputDirectory>${destEtcDir}/init.d</outputDirectory>
</file>
</files>
<dependencySets>
<dependencySet>
<scope>runtime</scope>
- <outputDirectory>/lib</outputDirectory>
+ <outputDirectory>${destVarLibDir}/couchdb-lucene</outputDirectory>
</dependencySet>
</dependencySets>
</assembly>
@@ -0,0 +1,90 @@
+#!/bin/sh
+
+NAME="couchdb-lucene"
+BACKGROUND=false #whether to run in the background or not
+STDOUT_FILE="" #where to send background stdout to (defaults to &1)
+PID_FILE=/var/run/couchdb-lucene/couchdb-lucene.pid
@rnewson

rnewson Dec 21, 2011

Owner

This is absolute, but should be relative to ${destRootDir} too.

+
+SCRIPT_OK=0
+SCRIPT_ERROR=1
+
+printUsage()
+{
+ cat << EOF
+Usage: `$basename $0` [OPTIONS]
+
+Starts the couchdb-lucene server component.
+
+Options:
+
+ -h displays this short help message and exits
+
+ -b spawn as a background process
+ -o FILE redirect background process's stdout to FILE (defaults to none)
+ -p FILE set the background process's PID FILE
+EOF
+}
+
+getPid()
+{
+ [ -f $PID_FILE ] && PID=`cat $PID_FILE`
+ echo $PID
+}
+
+start()
+{
+ CLASSPATH="$CL_BASEDIR/etc/couchdb-lucene:$CL_BASEDIR/lib/couchdb-lucene/*"
+ JAVA_OPTS="-server -Xmx1g -cp $CLASSPATH"
+
+ command="java $JAVA_OPTS $JAR com.github.rnewson.couchdb.lucene.Main"
+
+ if [ "$BACKGROUND" != "true" ]
+ then
+ eval $command
+ else
+ PID=`getPid`
+
+ if [ -z "$PID" ]
+ then
+ [ -n $STDOUT_FILE ] && command="$command >> $STDOUT_FILE"
+
+ eval "$command &"
+ echo $! > $PID_FILE
+ else
+ echo "$NAME is already running ($PID_FILE)."
+ fi
+ fi
+}
+
+checkEnvironment()
+{
+ prepend="couchdb-lucene needs write access to"
+ [ ! -w $STDOUT_FILE ] && echo "$prepend output file $STDOUT_FILE" && exit $SCRIPT_ERROR
+ unset prepend
+}
+
+parseOptions()
+{
+ opts=`getopt o:hbp: $@`
+ set -- $opts
+ while [ $# -gt 0 ]
+ do
+ case "$1" in
+ -h) shift; printUsage; exit $SCRIPT_OK;;
+ -o) shift; STDOUT_FILE="$1"; shift;;
+ -b) shift; BACKGROUND=true;;
+ -p) shift; PID_FILE="$1"; shift;;
+ --) shift; break;;
+ *) echo "Unknown option: $1" >&2; exit $SCRIPT_ERROR;;
+ esac
+ done
+}
+
+parseOptions $@
+checkEnvironment
+
+[ -z $CL_BASEDIR ] && CL_BASEDIR=`dirname "$0"`"/.."
+cd $CL_BASEDIR
+
+start
+
@@ -1,6 +1,6 @@
[lucene]
# The output directory for Lucene indexes.
-dir=indexes
+dir=/var/lib/couchdb-lucene/indexes
@rnewson

rnewson Dec 21, 2011

Owner

This is absolute, but should be relative to ${destRootDir} too.

# The local host name that couchdb-lucene binds to
host=localhost
Oops, something went wrong.