fix #2103 add gcLogging
This commit is contained in:
parent
6ed6c399a6
commit
09b2f7a542
5 changed files with 67 additions and 37 deletions
|
@ -15,7 +15,6 @@
|
|||
*/
|
||||
package org.codelibs.fess.job;
|
||||
|
||||
import static org.codelibs.core.stream.StreamUtil.split;
|
||||
import static org.codelibs.core.stream.StreamUtil.stream;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -216,7 +215,7 @@ public class CrawlJob extends ExecJob {
|
|||
buf.append(File.separator);
|
||||
buf.append("env");
|
||||
buf.append(File.separator);
|
||||
buf.append("crawler");
|
||||
buf.append(getExecuteType());
|
||||
buf.append(File.separator);
|
||||
buf.append("resources");
|
||||
buf.append(cpSeparator);
|
||||
|
@ -236,8 +235,8 @@ public class CrawlJob extends ExecJob {
|
|||
appendJarFile(cpSeparator, buf, new File(servletContext.getRealPath("/WEB-INF/lib")), "WEB-INF" + File.separator + "lib"
|
||||
+ File.separator);
|
||||
// WEB-INF/env/crawler/lib
|
||||
appendJarFile(cpSeparator, buf, new File(servletContext.getRealPath("/WEB-INF/env/crawler/lib")), "WEB-INF" + File.separator
|
||||
+ "env" + File.separator + "crawler" + File.separator + "lib" + File.separator);
|
||||
appendJarFile(cpSeparator, buf, new File(servletContext.getRealPath("/WEB-INF/env/" + getExecuteType() + "/lib")), "WEB-INF"
|
||||
+ File.separator + "env" + File.separator + getExecuteType() + File.separator + "lib" + File.separator);
|
||||
final File targetLibDir = new File(targetDir, "fess" + File.separator + "WEB-INF" + File.separator + "lib");
|
||||
if (targetLibDir.isDirectory()) {
|
||||
appendJarFile(cpSeparator, buf, targetLibDir, targetLibDir.getAbsolutePath() + File.separator);
|
||||
|
@ -254,7 +253,7 @@ public class CrawlJob extends ExecJob {
|
|||
final String systemLastaEnv = System.getProperty("lasta.env");
|
||||
if (StringUtil.isNotBlank(systemLastaEnv)) {
|
||||
if (systemLastaEnv.equals("web")) {
|
||||
cmdList.add("-Dlasta.env=crawler");
|
||||
cmdList.add("-Dlasta.env=" + getExecuteType());
|
||||
} else {
|
||||
cmdList.add("-Dlasta.env=" + systemLastaEnv);
|
||||
}
|
||||
|
@ -263,9 +262,9 @@ public class CrawlJob extends ExecJob {
|
|||
}
|
||||
|
||||
addSystemProperty(cmdList, Constants.FESS_CONF_PATH, null, null);
|
||||
cmdList.add("-Dfess.crawler.process=true");
|
||||
cmdList.add("-Dfess." + getExecuteType() + ".process=true");
|
||||
cmdList.add("-Dfess.log.path=" + (logFilePath != null ? logFilePath : systemHelper.getLogFilePath()));
|
||||
addSystemProperty(cmdList, "fess.log.name", "fess-crawler", "-crawler");
|
||||
addSystemProperty(cmdList, "fess.log.name", "fess-" + getExecuteType(), "-" + getExecuteType());
|
||||
if (logLevel == null) {
|
||||
addSystemProperty(cmdList, "fess.log.level", null, null);
|
||||
} else {
|
||||
|
@ -291,8 +290,8 @@ public class CrawlJob extends ExecJob {
|
|||
|
||||
cmdList.add(ComponentUtil.getThumbnailManager().getThumbnailPathOption());
|
||||
|
||||
if (StringUtil.isNotBlank(jvmOptions)) {
|
||||
split(jvmOptions, " ").of(stream -> stream.filter(StringUtil::isNotBlank).forEach(s -> cmdList.add(s)));
|
||||
if (!jvmOptions.isEmpty()) {
|
||||
jvmOptions.stream().filter(StringUtil::isNotBlank).forEach(cmdList::add);
|
||||
}
|
||||
|
||||
cmdList.add(Crawler.class.getCanonicalName());
|
||||
|
@ -322,7 +321,7 @@ public class CrawlJob extends ExecJob {
|
|||
File propFile = null;
|
||||
try {
|
||||
cmdList.add("-p");
|
||||
propFile = File.createTempFile("crawler_", ".properties");
|
||||
propFile = File.createTempFile(getExecuteType() + "_", ".properties");
|
||||
cmdList.add(propFile.getAbsolutePath());
|
||||
try (FileOutputStream out = new FileOutputStream(propFile)) {
|
||||
final Properties prop = new Properties();
|
||||
|
@ -374,4 +373,9 @@ public class CrawlJob extends ExecJob {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getExecuteType() {
|
||||
return "crawler";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,9 +17,11 @@ package org.codelibs.fess.job;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -27,8 +29,6 @@ public abstract class ExecJob {
|
|||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ExecJob.class);
|
||||
|
||||
protected static final String REMOTE_DEBUG_OPTIONS = "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=localhost:8000";
|
||||
|
||||
protected JobExecutor jobExecutor;
|
||||
|
||||
protected String sessionId;
|
||||
|
@ -39,12 +39,14 @@ public abstract class ExecJob {
|
|||
|
||||
protected String logLevel;
|
||||
|
||||
protected String jvmOptions;
|
||||
protected List<String> jvmOptions = new ArrayList<>();
|
||||
|
||||
protected String lastaEnv;
|
||||
|
||||
public abstract String execute();
|
||||
|
||||
protected abstract String getExecuteType();
|
||||
|
||||
public ExecJob jobExecutor(final JobExecutor jobExecutor) {
|
||||
this.jobExecutor = jobExecutor;
|
||||
return this;
|
||||
|
@ -71,11 +73,27 @@ public abstract class ExecJob {
|
|||
}
|
||||
|
||||
public ExecJob remoteDebug() {
|
||||
return jvmOptions(REMOTE_DEBUG_OPTIONS);
|
||||
return jvmOptions("-Xdebug", "-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=localhost:8000");
|
||||
}
|
||||
|
||||
public ExecJob jvmOptions(final String option) {
|
||||
this.jvmOptions = option;
|
||||
public ExecJob gcLogging() {
|
||||
final StringBuilder buf = new StringBuilder(100);
|
||||
buf.append("-Xlog:gc*,gc+age=trace,safepoint:file=");
|
||||
if (logFilePath != null) {
|
||||
buf.append(logFilePath);
|
||||
} else {
|
||||
buf.append(ComponentUtil.getSystemHelper().getLogFilePath());
|
||||
}
|
||||
buf.append(File.separator);
|
||||
buf.append("gc-").append(getExecuteType()).append(".log");
|
||||
buf.append(":utctime,pid,tags:filecount=32,filesize=64m");
|
||||
return jvmOptions(buf.toString());
|
||||
}
|
||||
|
||||
public ExecJob jvmOptions(final String... options) {
|
||||
for (final String s : options) {
|
||||
this.jvmOptions.add(s);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
*/
|
||||
package org.codelibs.fess.job;
|
||||
|
||||
import static org.codelibs.core.stream.StreamUtil.split;
|
||||
import static org.codelibs.core.stream.StreamUtil.stream;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -113,7 +112,7 @@ public class GenerateThumbnailJob extends ExecJob {
|
|||
buf.append(File.separator);
|
||||
buf.append("env");
|
||||
buf.append(File.separator);
|
||||
buf.append("thumbnail");
|
||||
buf.append(getExecuteType());
|
||||
buf.append(File.separator);
|
||||
buf.append("resources");
|
||||
buf.append(cpSeparator);
|
||||
|
@ -133,8 +132,8 @@ public class GenerateThumbnailJob extends ExecJob {
|
|||
appendJarFile(cpSeparator, buf, new File(servletContext.getRealPath("/WEB-INF/lib")), "WEB-INF" + File.separator + "lib"
|
||||
+ File.separator);
|
||||
// WEB-INF/env/thumbnail/lib
|
||||
appendJarFile(cpSeparator, buf, new File(servletContext.getRealPath("/WEB-INF/env/thumbnail/lib")), "WEB-INF" + File.separator
|
||||
+ "env" + File.separator + "thumbnail" + File.separator + "lib" + File.separator);
|
||||
appendJarFile(cpSeparator, buf, new File(servletContext.getRealPath("/WEB-INF/env/" + getExecuteType() + "/lib")), "WEB-INF"
|
||||
+ File.separator + "env" + File.separator + getExecuteType() + File.separator + "lib" + File.separator);
|
||||
final File targetLibDir = new File(targetDir, "fess" + File.separator + "WEB-INF" + File.separator + "lib");
|
||||
if (targetLibDir.isDirectory()) {
|
||||
appendJarFile(cpSeparator, buf, targetLibDir, targetLibDir.getAbsolutePath() + File.separator);
|
||||
|
@ -151,7 +150,7 @@ public class GenerateThumbnailJob extends ExecJob {
|
|||
final String systemLastaEnv = System.getProperty("lasta.env");
|
||||
if (StringUtil.isNotBlank(systemLastaEnv)) {
|
||||
if (systemLastaEnv.equals("web")) {
|
||||
cmdList.add("-Dlasta.env=thumbnail");
|
||||
cmdList.add("-Dlasta.env=" + getExecuteType());
|
||||
} else {
|
||||
cmdList.add("-Dlasta.env=" + systemLastaEnv);
|
||||
}
|
||||
|
@ -160,7 +159,7 @@ public class GenerateThumbnailJob extends ExecJob {
|
|||
}
|
||||
|
||||
addSystemProperty(cmdList, Constants.FESS_CONF_PATH, null, null);
|
||||
cmdList.add("-Dfess.thumbnail.process=true");
|
||||
cmdList.add("-Dfess." + getExecuteType() + ".process=true");
|
||||
if (logFilePath == null) {
|
||||
final String value = System.getProperty("fess.log.path");
|
||||
logFilePath = value != null ? value : new File(targetDir, "logs").getAbsolutePath();
|
||||
|
@ -168,7 +167,7 @@ public class GenerateThumbnailJob extends ExecJob {
|
|||
cmdList.add("-Dfess.log.path=" + logFilePath);
|
||||
addSystemProperty(cmdList, Constants.FESS_VAR_PATH, null, null);
|
||||
addSystemProperty(cmdList, Constants.FESS_THUMBNAIL_PATH, null, null);
|
||||
addSystemProperty(cmdList, "fess.log.name", "fess-thumbnail", "-thumbnail");
|
||||
addSystemProperty(cmdList, "fess.log.name", "fess-" + getExecuteType(), "-" + getExecuteType());
|
||||
if (logLevel != null) {
|
||||
cmdList.add("-Dfess.log.level=" + logLevel);
|
||||
}
|
||||
|
@ -186,8 +185,8 @@ public class GenerateThumbnailJob extends ExecJob {
|
|||
}
|
||||
}
|
||||
|
||||
if (StringUtil.isNotBlank(jvmOptions)) {
|
||||
split(jvmOptions, " ").of(stream -> stream.filter(StringUtil::isNotBlank).forEach(s -> cmdList.add(s)));
|
||||
if (!jvmOptions.isEmpty()) {
|
||||
jvmOptions.stream().filter(StringUtil::isNotBlank).forEach(cmdList::add);
|
||||
}
|
||||
|
||||
cmdList.add(ThumbnailGenerator.class.getCanonicalName());
|
||||
|
@ -203,7 +202,7 @@ public class GenerateThumbnailJob extends ExecJob {
|
|||
File propFile = null;
|
||||
try {
|
||||
cmdList.add("-p");
|
||||
propFile = File.createTempFile("thumbnail_", ".properties");
|
||||
propFile = File.createTempFile(getExecuteType() + "_", ".properties");
|
||||
cmdList.add(propFile.getAbsolutePath());
|
||||
try (FileOutputStream out = new FileOutputStream(propFile)) {
|
||||
final Properties prop = new Properties();
|
||||
|
@ -255,4 +254,9 @@ public class GenerateThumbnailJob extends ExecJob {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getExecuteType() {
|
||||
return "thumbnail";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
*/
|
||||
package org.codelibs.fess.job;
|
||||
|
||||
import static org.codelibs.core.stream.StreamUtil.split;
|
||||
import static org.codelibs.core.stream.StreamUtil.stream;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -100,7 +99,7 @@ public class SuggestJob extends ExecJob {
|
|||
buf.append(File.separator);
|
||||
buf.append("env");
|
||||
buf.append(File.separator);
|
||||
buf.append("suggest");
|
||||
buf.append(getExecuteType());
|
||||
buf.append(File.separator);
|
||||
buf.append("resources");
|
||||
buf.append(cpSeparator);
|
||||
|
@ -120,8 +119,8 @@ public class SuggestJob extends ExecJob {
|
|||
appendJarFile(cpSeparator, buf, new File(servletContext.getRealPath("/WEB-INF/lib")), "WEB-INF" + File.separator + "lib"
|
||||
+ File.separator);
|
||||
// WEB-INF/env/suggest/lib
|
||||
appendJarFile(cpSeparator, buf, new File(servletContext.getRealPath("/WEB-INF/env/suggest/lib")), "WEB-INF" + File.separator
|
||||
+ "env" + File.separator + "suggest" + File.separator + "lib" + File.separator);
|
||||
appendJarFile(cpSeparator, buf, new File(servletContext.getRealPath("/WEB-INF/env/" + getExecuteType() + "/lib")), "WEB-INF"
|
||||
+ File.separator + "env" + File.separator + getExecuteType() + File.separator + "lib" + File.separator);
|
||||
final File targetLibDir = new File(targetDir, "fess" + File.separator + "WEB-INF" + File.separator + "lib");
|
||||
if (targetLibDir.isDirectory()) {
|
||||
appendJarFile(cpSeparator, buf, targetLibDir, targetLibDir.getAbsolutePath() + File.separator);
|
||||
|
@ -138,7 +137,7 @@ public class SuggestJob extends ExecJob {
|
|||
final String systemLastaEnv = System.getProperty("lasta.env");
|
||||
if (StringUtil.isNotBlank(systemLastaEnv)) {
|
||||
if (systemLastaEnv.equals("web")) {
|
||||
cmdList.add("-Dlasta.env=suggest");
|
||||
cmdList.add("-Dlasta.env=" + getExecuteType());
|
||||
} else {
|
||||
cmdList.add("-Dlasta.env=" + systemLastaEnv);
|
||||
}
|
||||
|
@ -147,13 +146,13 @@ public class SuggestJob extends ExecJob {
|
|||
}
|
||||
|
||||
addSystemProperty(cmdList, Constants.FESS_CONF_PATH, null, null);
|
||||
cmdList.add("-Dfess.suggest.process=true");
|
||||
cmdList.add("-Dfess." + getExecuteType() + ".process=true");
|
||||
if (logFilePath == null) {
|
||||
final String value = System.getProperty("fess.log.path");
|
||||
logFilePath = value != null ? value : new File(targetDir, "logs").getAbsolutePath();
|
||||
}
|
||||
cmdList.add("-Dfess.log.path=" + logFilePath);
|
||||
addSystemProperty(cmdList, "fess.log.name", "fess-suggest", "-suggest");
|
||||
addSystemProperty(cmdList, "fess.log.name", "fess-" + getExecuteType(), "-" + getExecuteType());
|
||||
if (logLevel == null) {
|
||||
addSystemProperty(cmdList, "fess.log.level", null, null);
|
||||
} else {
|
||||
|
@ -173,8 +172,8 @@ public class SuggestJob extends ExecJob {
|
|||
}
|
||||
}
|
||||
|
||||
if (StringUtil.isNotBlank(jvmOptions)) {
|
||||
split(jvmOptions, " ").of(stream -> stream.filter(StringUtil::isNotBlank).forEach(s -> cmdList.add(s)));
|
||||
if (!jvmOptions.isEmpty()) {
|
||||
jvmOptions.stream().filter(StringUtil::isNotBlank).forEach(cmdList::add);
|
||||
}
|
||||
|
||||
cmdList.add(SuggestCreator.class.getCanonicalName());
|
||||
|
@ -185,7 +184,7 @@ public class SuggestJob extends ExecJob {
|
|||
File propFile = null;
|
||||
try {
|
||||
cmdList.add("-p");
|
||||
propFile = File.createTempFile("suggest_", ".properties");
|
||||
propFile = File.createTempFile(getExecuteType() + "_", ".properties");
|
||||
cmdList.add(propFile.getAbsolutePath());
|
||||
try (FileOutputStream out = new FileOutputStream(propFile)) {
|
||||
final Properties prop = new Properties();
|
||||
|
@ -238,4 +237,9 @@ public class SuggestJob extends ExecJob {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getExecuteType() {
|
||||
return "suggest";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{"index":{"_index":".fess_config.scheduled_job","_id":"default_crawler"}}
|
||||
{"name":"Default Crawler","target":"all","cronExpression":"0 0 * * *","scriptType":"groovy","scriptData":"return container.getComponent(\"crawlJob\").logLevel(\"info\").execute(executor);","jobLogging":true,"crawler":true,"available":true,"sortOrder":1,"createdBy":"system","createdTime":0,"updatedBy":"system","updatedTime":0}
|
||||
{"name":"Default Crawler","target":"all","cronExpression":"0 0 * * *","scriptType":"groovy","scriptData":"return container.getComponent(\"crawlJob\").logLevel(\"info\").gcLogging().execute(executor);","jobLogging":true,"crawler":true,"available":true,"sortOrder":1,"createdBy":"system","createdTime":0,"updatedBy":"system","updatedTime":0}
|
||||
{"index":{"_index":".fess_config.scheduled_job","_id":"suggest_indexer"}}
|
||||
{"name":"Suggest Indexer","target":"all","cronExpression":"0 12 * * *","scriptType":"groovy","scriptData":"return container.getComponent(\"suggestJob\").logLevel(\"info\").sessionId(\"SUGGEST\").execute(executor);","jobLogging":true,"crawler":false,"available":true,"sortOrder":2,"createdBy":"system","createdTime":0,"updatedBy":"system","updatedTime":0}
|
||||
{"index":{"_index":".fess_config.scheduled_job","_id":"log_aggregator"}}
|
||||
|
|
Loading…
Add table
Reference in a new issue