modify directory structure for rpm packaging

This commit is contained in:
Shinsuke Sugaya 2015-12-13 20:29:25 +09:00
parent 5e08dc9a00
commit 59192ba831
12 changed files with 138 additions and 80 deletions

43
pom.xml
View file

@ -72,13 +72,13 @@
<tomcat.boot.version>0.4.0-RC2</tomcat.boot.version>
<!-- TODO: RPM build -->
<packaging.fess.home.dir>/opt/fess</packaging.fess.home.dir>
<packaging.fess.home.dir>/usr/share/fess</packaging.fess.home.dir>
<packaging.fess.app.dir>${packaging.fess.home.dir}/app</packaging.fess.app.dir>
<packaging.fess.bin.dir>${packaging.fess.home.dir}/bin</packaging.fess.bin.dir>
<packaging.fess.es.dir>${packaging.fess.home.dir}/es</packaging.fess.es.dir>
<packaging.fess.lib.dir>${packaging.fess.home.dir}/es</packaging.fess.lib.dir>
<packaging.fess.logs.dir>${packaging.fess.home.dir}/es</packaging.fess.logs.dir>
<packaging.fess.temp.dir>${packaging.fess.home.dir}/es</packaging.fess.temp.dir>
<packaging.fess.conf.dir>/etc/fess</packaging.fess.conf.dir>
<packaging.fess.lib.dir>${packaging.fess.home.dir}/lib</packaging.fess.lib.dir>
<packaging.fess.log.dir>/var/log/fess</packaging.fess.log.dir>
<packaging.fess.temp.dir>/var/tmp/fess</packaging.fess.temp.dir>
<packaging.fess.user>fess</packaging.fess.user>
<packaging.fess.group>fess</packaging.fess.group>
<packaging.fess.pid.dir>/var/run/fess</packaging.fess.pid.dir>
@ -371,8 +371,8 @@
<configuration>
<distribution>Fess</distribution>
<group>Application/Internet</group>
<packager>Fess</packager>
<prefix>/opt</prefix>
<packager>CodeLibs</packager>
<prefix>/usr</prefix>
<needarch>noarch</needarch>
<targetOS>linux</targetOS>
<changelogFile>src/changelog</changelogFile>
@ -400,17 +400,21 @@
</mapping>
<!-- app -->
<mapping>
<directory>${packaging.fess.home.dir}/app</directory>
<directory>${packaging.fess.app.dir}</directory>
<filemode>755</filemode>
<sources>
<source>
<location>${project.build.directory}/fess</location>
<excludes>
<exclude>**/fess_config.properties</exclude>
<exclude>**/fess_env*.properties</exclude>
</excludes>
</source>
</sources>
</mapping>
<!-- lib -->
<mapping>
<directory>${packaging.fess.home.dir}/lib/classes</directory>
<directory>${packaging.fess.lib.dir}/classes</directory>
<sources>
<source>
<location>${project.build.directory}/tomcat-lib</location>
@ -418,7 +422,7 @@
</sources>
</mapping>
<mapping>
<directory>${packaging.fess.home.dir}/lib/classes/org/codelibs/fess</directory>
<directory>${packaging.fess.lib.dir}/classes/org/codelibs/fess</directory>
<sources>
<source>
<location>${project.build.directory}/fess/WEB-INF/classes/org/codelibs/fess</location>
@ -429,7 +433,7 @@
</sources>
</mapping>
<mapping>
<directory>${packaging.fess.home.dir}/lib/classes</directory>
<directory>${packaging.fess.conf.dir}</directory>
<sources>
<source>
<location>${project.basedir}/src/main/assemblies/files</location>
@ -438,11 +442,18 @@
<include>tomcat_config.properties</include>
</includes>
</source>
<source>
<location>${project.build.directory}/fess/WEB-INF/classes</location>
<includes>
<include>fess_config.properties</include>
<include>fess_env_production.properties</include>
</includes>
</source>
</sources>
</mapping>
<!-- bin -->
<mapping>
<directory>${packaging.fess.home.dir}/bin</directory>
<directory>${packaging.fess.bin.dir}</directory>
<filemode>755</filemode>
<sources>
<source>
@ -456,11 +467,11 @@
</mapping>
<!-- logs (empty) -->
<mapping>
<directory>${packaging.fess.home.dir}/logs</directory>
<directory>${packaging.fess.log.dir}</directory>
</mapping>
<!-- temp (empty) -->
<mapping>
<directory>${packaging.fess.home.dir}/temp</directory>
<directory>${packaging.fess.temp.dir}</directory>
</mapping>
<!-- es/plugins -->
<mapping>
@ -471,10 +482,6 @@
</source>
</sources>
</mapping>
<!-- es/data (empty) -->
<mapping>
<directory>${packaging.fess.home.dir}/es/data</directory>
</mapping>
<!-- Add environment vars file -->
<mapping>
<directory>/etc/sysconfig/</directory>

View file

@ -73,6 +73,14 @@ case `uname` in
CYGWIN*)
FESS_CLASSPATH=`cygpath -p -w "$FESS_CLASSPATH"`
FESS_HOME=`cygpath -p -w "$FESS_HOME"`
if [ "x$FESS_CONF_PATH" != "x" ] ; then
FESS_CLASSPATH=`cygpath -p -w "$FESS_CONF_PATH"`":$FESS_CLASSPATH"
fi
;;
*)
if [ "x$FESS_CONF_PATH" != "x" ] ; then
FESS_CLASSPATH="$FESS_CONF_PATH:$FESS_CLASSPATH"
fi
;;
esac

View file

@ -25,11 +25,6 @@ if [ "x$FESS_HEAP_NEWSIZE" != "x" ]; then
JAVA_OPTS="$JAVA_OPTS -Xmn${FESS_HEAP_NEWSIZE}"
fi
# max direct memory
if [ "x$FESS_DIRECT_SIZE" != "x" ]; then
JAVA_OPTS="$JAVA_OPTS -XX:MaxDirectMemorySize=${FESS_DIRECT_SIZE}"
fi
# set to headless, just in case
JAVA_OPTS="$JAVA_OPTS -Djava.awt.headless=true"
@ -68,17 +63,35 @@ JAVA_OPTS="$JAVA_OPTS -XX:+DisableExplicitGC"
JAVA_OPTS="$JAVA_OPTS -Dfile.encoding=UTF-8"
# Application Configuration
APP_NAME=fess
ES_HOME=$FESS_HOME/es
if [ "x$APP_NAME" = "x" ]; then
APP_NAME=fess
fi
if [ "x$ES_HOME" = "x" ]; then
ES_HOME=$FESS_HOME/es
fi
if [ "x$FESS_TEMP_PATH" = "x" ]; then
FESS_TEMP_PATH=$FESS_HOME/temp
fi
if [ "x$FESS_LOG_PATH" = "x" ]; then
FESS_LOG_PATH=$FESS_HOME/logs
fi
FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.home=$FESS_HOME"
FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.context.path=/"
FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.port=8080"
FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.webapp.path=$FESS_HOME/app"
FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.temp.path=$FESS_HOME/temp"
FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.temp.path=$FESS_TEMP_PATH"
FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.log.name=$APP_NAME"
FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.log.path=$FESS_HOME/logs"
FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.log.path=$FESS_LOG_PATH"
FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.log.level=warn"
FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dlasta.env=production"
FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dtomcat.config.path=tomcat_config.properties"
# __RPM__ FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.es.transport_addresses=localhost:9300"
if [ "x$ES_HTTP_URL" != "x" ]; then
FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.es.http_address=$ES_HTTP_URL"
fi
if [ "x$ES_TRANSPORT_URL" != "x" ]; then
FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.es.transport_addresses=$ES_TRANSPORT_URL"
fi
if [ "x$FESS_DICTIONARY_PATH" != "x" ]; then
FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.dictionary.path=$FESS_DICTIONARY_PATH"
fi

View file

@ -5,6 +5,6 @@ java.util.logging.ConsoleHandler.level=INFO
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.FileHandler.level=INFO
java.util.logging.FileHandler.pattern=../../logs/server_%g.log
java.util.logging.FileHandler.pattern=${fess.log.path}/server_%g.log
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.FileHandler.count=10

View file

@ -72,10 +72,11 @@ public class FessBoot extends TomcatBoot {
}
tomcatBoot.logging(LOGGING_PROPERTIES, op -> {
op.ignoreNoFile();
final String fessHomeDir = System.getProperty("fess.home");
if (fessHomeDir != null) {
op.replace("fess.home", fessHomeDir);
String fessLogPath = System.getProperty("fess.log.path");
if (fessLogPath == null) {
fessLogPath = "../../logs";
}
op.replace("fess.log.path", fessLogPath);
}) // uses jdk14logger
.asDevelopment(isNoneEnv()).bootAwait();
}

View file

@ -40,8 +40,8 @@ import org.codelibs.fess.api.BaseApiManager;
import org.codelibs.fess.app.web.base.login.FessLoginAssist;
import org.codelibs.fess.exception.FessSystemException;
import org.codelibs.fess.exception.WebApiException;
import org.codelibs.fess.mylasta.direction.FessConfig;
import org.codelibs.fess.util.ComponentUtil;
import org.codelibs.fess.util.ResourceUtil;
import org.lastaflute.web.servlet.session.SessionManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -93,9 +93,8 @@ public class EsApiManager extends BaseApiManager {
}
protected void processRequest(final HttpServletRequest request, final HttpServletResponse response, final String path) {
final FessConfig fessConfig = ComponentUtil.getFessConfig();
final Method httpMethod = Method.valueOf(request.getMethod().toUpperCase(Locale.ROOT));
final CurlRequest curlRequest = new CurlRequest(httpMethod, fessConfig.getElasticsearchHttpUrl() + path);
final CurlRequest curlRequest = new CurlRequest(httpMethod, ResourceUtil.getElasticsearchHttpUrl() + path);
request.getParameterMap().entrySet().stream().forEach(entry -> {
if (entry.getValue().length > 1) {
curlRequest.param(entry.getKey(), String.join(",", entry.getValue()));

View file

@ -32,8 +32,7 @@ import org.codelibs.core.misc.DynamicProperties;
import org.codelibs.elasticsearch.runner.net.Curl;
import org.codelibs.elasticsearch.runner.net.CurlResponse;
import org.codelibs.fess.Constants;
import org.codelibs.fess.mylasta.direction.FessConfig;
import org.codelibs.fess.util.ComponentUtil;
import org.codelibs.fess.util.ResourceUtil;
import org.dbflute.optional.OptionalEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -54,9 +53,8 @@ public class DictionaryManager {
}
public DictionaryFile<? extends DictionaryItem>[] getDictionaryFiles() {
final FessConfig fessConfig = ComponentUtil.getFessConfig();
try (CurlResponse response =
Curl.get(fessConfig.getElasticsearchHttpUrl() + "/_configsync/file").param("fields", "path,@timestamp").execute()) {
Curl.get(ResourceUtil.getElasticsearchHttpUrl() + "/_configsync/file").param("fields", "path,@timestamp").execute()) {
final Map<String, Object> contentMap = response.getContentAsMap();
@SuppressWarnings("unchecked")
final List<Map<String, Object>> fileList = (List<Map<String, Object>>) contentMap.get("file");
@ -94,7 +92,6 @@ public class DictionaryManager {
}
public void store(final DictionaryFile<? extends DictionaryItem> dictFile, final File file) {
final FessConfig fessConfig = ComponentUtil.getFessConfig();
getDictionaryFile(dictFile.getId()).ifPresent(currentFile -> {
if (currentFile.getTimestamp().getTime() > dictFile.getTimestamp().getTime()) {
throw new DictionaryException(dictFile.getPath() + " was updated.");
@ -102,7 +99,7 @@ public class DictionaryManager {
// TODO use stream
try (CurlResponse response =
Curl.post(fessConfig.getElasticsearchHttpUrl() + "/_configsync/file").param("path", dictFile.getPath())
Curl.post(ResourceUtil.getElasticsearchHttpUrl() + "/_configsync/file").param("path", dictFile.getPath())
.body(FileUtil.readUTF8(file)).execute()) {
final Map<String, Object> contentMap = response.getContentAsMap();
if (!Constants.TRUE.equalsIgnoreCase(contentMap.get("acknowledged").toString())) {
@ -118,9 +115,8 @@ public class DictionaryManager {
}
public InputStream getContentInputStream(final DictionaryFile<? extends DictionaryItem> dictFile) {
final FessConfig fessConfig = ComponentUtil.getFessConfig();
try {
return Curl.get(fessConfig.getElasticsearchHttpUrl() + "/_configsync/file").param("path", dictFile.getPath()).execute()
return Curl.get(ResourceUtil.getElasticsearchHttpUrl() + "/_configsync/file").param("path", dictFile.getPath()).execute()
.getContentAsStream();
} catch (final IOException e) {
throw new DictionaryException("Failed to access " + dictFile.getPath(), e);

View file

@ -29,6 +29,7 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
@ -309,44 +310,42 @@ public class FessEsClient implements Client {
// ignore
}
if (!exists) {
if (runner != null) {// TODO replace with url
configListMap.getOrDefault(configIndex, Collections.emptyList()).forEach(
path -> {
String source = null;
final String filePath = indexConfigPath + "/" + configIndex + "/" + path;
try {
source = FileUtil.readUTF8(filePath);
try (CurlResponse response =
Curl.post(runner.node(), "_configsync/file").param("path", path).body(source).execute()) {
if (response.getHttpStatusCode() == 200) {
logger.info("Register " + path + " to " + configIndex);
} else {
logger.warn("Invalid request for " + path);
}
configListMap.getOrDefault(configIndex, Collections.emptyList()).forEach(
path -> {
String source = null;
final String filePath = indexConfigPath + "/" + configIndex + "/" + path;
try {
source = FileUtil.readUTF8(filePath);
try (CurlResponse response =
Curl.post(org.codelibs.fess.util.ResourceUtil.getElasticsearchHttpUrl() + "/_configsync/file")
.param("path", path).body(source).execute()) {
if (response.getHttpStatusCode() == 200) {
logger.info("Register " + path + " to " + configIndex);
} else {
logger.warn("Invalid request for " + path);
}
} catch (final Exception e) {
logger.warn("Failed to register " + filePath, e);
}
});
try (CurlResponse response = Curl.post(runner.node(), "_configsync/flush").execute()) {
if (response.getHttpStatusCode() == 200) {
logger.info("Flushed config files.");
} else {
logger.warn("Failed to flush config files.");
}
} catch (final Exception e) {
logger.warn("Failed to flush config files.", e);
} catch (final Exception e) {
logger.warn("Failed to register " + filePath, e);
}
});
try (CurlResponse response =
Curl.post(org.codelibs.fess.util.ResourceUtil.getElasticsearchHttpUrl() + "/_configsync/flush").execute()) {
if (response.getHttpStatusCode() == 200) {
logger.info("Flushed config files.");
} else {
logger.warn("Failed to flush config files.");
}
} catch (final Exception e) {
logger.warn("Failed to flush config files.", e);
}
String source = null;
final String indexConfigFile = indexConfigPath + "/" + configIndex + ".json";
try {
String source = null;
final String indexConfigFile = indexConfigPath + "/" + configIndex + ".json";
try {
source = FileUtil.readUTF8(indexConfigFile);
} catch (final Exception e) {
logger.warn(indexConfigFile + " is not found.", e);
}
source = FileUtil.readUTF8(indexConfigFile);
final String dictionaryPath = System.getProperty("fess.dictionary.path", StringUtil.EMPTY);
source = source.replaceAll(Pattern.quote("${fess.dictionary.path}"), dictionaryPath);
final CreateIndexResponse indexResponse =
client.admin().indices().prepareCreate(configIndex).setSource(source).execute().actionGet();
if (indexResponse.isAcknowledged()) {
@ -356,6 +355,8 @@ public class FessEsClient implements Client {
}
} catch (final IndexAlreadyExistsException e) {
// ignore
} catch (final Exception e) {
logger.warn(indexConfigFile + " is not found.", e);
}
}

View file

@ -26,6 +26,7 @@ import java.util.regex.Pattern;
import javax.servlet.ServletContext;
import org.codelibs.core.lang.StringUtil;
import org.codelibs.fess.mylasta.direction.FessConfig;
import org.lastaflute.di.core.SingletonLaContainer;
import org.lastaflute.web.util.LaServletContextUtil;
@ -34,6 +35,15 @@ public class ResourceUtil {
// nothing
}
public static String getElasticsearchHttpUrl() {
final String url = System.getProperty("fess.es.http_address");
if (url != null) {
return url;
}
FessConfig fessConfig = ComponentUtil.getFessConfig();
return fessConfig.getElasticsearchHttpUrl();
}
public static Path getConfPath(final String... names) {
return getPath("conf", names);
}

View file

@ -9,7 +9,7 @@
"char_filter": {
"mapping_ja_cfilter": {
"type": "mapping",
"mappings_path": "ja/mapping.txt"
"mappings_path": "${fess.dictionary.path}ja/mapping.txt"
}
},
"filter": {
@ -22,14 +22,14 @@
"kuromoji_neologd_tokenizer": {
"type": "reloadable_kuromoji_neologd_tokenizer",
"mode": "normal",
"user_dictionary": "ja/kuromoji.txt",
"user_dictionary": "${fess.dictionary.path}ja/kuromoji.txt",
"discard_punctuation": false,
"reload_interval":"1m"
},
"2gram_synonym_tokenizer": {
"type": "ngram_synonym",
"n": "2",
"synonyms_path": "synonym.txt",
"synonyms_path": "${fess.dictionary.path}synonym.txt",
"dynamic_reload":true,
"reload_interval":"1m"
}

View file

@ -1,3 +1,21 @@
################################
# Fess
################################
# Fess Path
FESS_TEMP_PATH=/var/tmp/fess
FESS_LOG_PATH=/var/log/fess
FESS_CONF_PATH=/etc/fess
FESS_DICTIONARY_PATH=/var/lib/elasticsearch/config/
# Heap Memory
FESS_HEAP_SIZE=512m
# Elasticsearch Path
ES_HOME=/usr/share/elasticsearch/
# Elasticsearch URL
ES_HTTP_URL=http://localhost:9200
ES_TRANSPORT_URL=localhost:9300

View file

@ -48,9 +48,14 @@ exec="$FESS_HOME/bin/fess"
prog="fess"
pidfile="$PID_DIR/${prog}.pid"
export FESS_TEMP_PATH
export FESS_LOG_PATH
export FESS_CONF_PATH
export FESS_DICTIONARY_PATH
export FESS_HEAP_SIZE
export FESS_HEAP_NEWSIZE
export FESS_DIRECT_SIZE
export ES_HOME
export ES_HTTP_URL
export ES_TRANSPORT_URL
export FESS_JAVA_OPTS
export JAVA_HOME