diff --git a/src/main/html/webapp/components/admin/settings/server/server.stache b/src/main/html/webapp/components/admin/settings/server/server.stache
index f681fe16..437f685d 100644
--- a/src/main/html/webapp/components/admin/settings/server/server.stache
+++ b/src/main/html/webapp/components/admin/settings/server/server.stache
@@ -95,7 +95,9 @@
{{else}}
{{name}}
- {{{error}}}
+
{{/enabled}}
diff --git a/src/main/java/cloudgene/mapred/plugins/docker/DockerBinary.java b/src/main/java/cloudgene/mapred/plugins/docker/DockerBinary.java
index 4f0f469f..04101742 100644
--- a/src/main/java/cloudgene/mapred/plugins/docker/DockerBinary.java
+++ b/src/main/java/cloudgene/mapred/plugins/docker/DockerBinary.java
@@ -38,12 +38,11 @@ public String getVersion() {
if (isInstalled()) {
String binary = getBinary();
Command command = new Command(binary, "version");
- command.saveStdOut(FileUtil.path("docker-version.txt"));
+ StringBuffer stdout = new StringBuffer();
+ command.writeStdout(stdout);
command.setSilent(true);
command.execute();
- String version = FileUtil.readFileAsString("docker-version.txt");
- FileUtil.deleteFile("docker-version.txt");
- return version;
+ return stdout.toString();
} else {
return "Docker not installed.";
}
diff --git a/src/main/java/cloudgene/mapred/plugins/nextflow/NextflowBinary.java b/src/main/java/cloudgene/mapred/plugins/nextflow/NextflowBinary.java
index 85347d26..b32aca2e 100644
--- a/src/main/java/cloudgene/mapred/plugins/nextflow/NextflowBinary.java
+++ b/src/main/java/cloudgene/mapred/plugins/nextflow/NextflowBinary.java
@@ -63,12 +63,11 @@ public boolean isInstalled() {
public String getVersion() {
if (isInstalled()) {
Command command = new Command(binary, "info");
- command.saveStdOut(FileUtil.path("info-version.txt"));
+ StringBuffer stdout = new StringBuffer();
+ command.writeStdout(stdout);
command.setSilent(true);
command.execute();
- String version = FileUtil.readFileAsString("info-version.txt");
- FileUtil.deleteFile("info-version.txt");
- return version;
+ return stdout.toString();
} else {
return "Nextflow not installed.";
}
diff --git a/src/main/java/cloudgene/mapred/server/controller/ServerAdminController.java b/src/main/java/cloudgene/mapred/server/controller/ServerAdminController.java
index 005bebb8..1490ff63 100644
--- a/src/main/java/cloudgene/mapred/server/controller/ServerAdminController.java
+++ b/src/main/java/cloudgene/mapred/server/controller/ServerAdminController.java
@@ -14,6 +14,7 @@
import cloudgene.mapred.server.responses.ServerResponse;
import cloudgene.mapred.server.responses.StatisticsResponse;
import cloudgene.mapred.server.services.ServerService;
+import cloudgene.mapred.util.TextUtil;
import genepi.io.FileUtil;
import io.micronaut.core.annotation.Nullable;
import io.micronaut.http.MediaType;
@@ -88,8 +89,7 @@ public String getDetails() {
public String getLogs() {
File file = new File(LOG_FILENAME);
if (file.exists()) {
- String content = serverService.tail(file, 1000);
- return content;
+ return TextUtil.tail(file, 1000);
} else {
return "No log file available.";
}
diff --git a/src/main/java/cloudgene/mapred/server/services/ServerService.java b/src/main/java/cloudgene/mapred/server/services/ServerService.java
index 000dd2b4..f2f1af57 100644
--- a/src/main/java/cloudgene/mapred/server/services/ServerService.java
+++ b/src/main/java/cloudgene/mapred/server/services/ServerService.java
@@ -3,15 +3,12 @@
import java.io.File;
import java.io.IOException;
import java.net.URL;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
+import java.util.*;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
import cloudgene.mapred.plugins.nextflow.NextflowPlugin;
+import cloudgene.mapred.util.command.Command;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
@@ -211,6 +208,34 @@ public String getClusterDetails() {
plugins.add(pluginObject);
}
+ //check user defined resources
+ for (Map resource: application.getSettings().getResources()){
+ String name = resource.get("name");
+ ObjectNode pluginObject = mapper.createObjectNode();
+ pluginObject.put("name", name);
+ if (!resource.containsKey("command")) {
+ pluginObject.put("error", "Command defined in resource '" + name + "'");
+ }
+ String cmd = resource.get("command");
+ String[] tiles = cmd.split(" ");
+ String[] params = Arrays.copyOfRange(tiles, 1, tiles.length);
+ Command command = new Command(tiles[0], params);
+ command.setSilent(true);
+ StringBuffer output = new StringBuffer();
+ StringBuffer error = new StringBuffer();
+ command.writeStdout(output);
+ command.writeStderr(error);
+ int exitCode = command.execute();
+ if (exitCode == 0) {
+ pluginObject.put("enabled", true);
+ pluginObject.put("details", output.toString());
+ }else {
+ pluginObject.put("enabled", false);
+ pluginObject.put("error", output.toString()+ "\n" + error.toString());
+ }
+ plugins.add(pluginObject);
+ }
+
// database
object.put("db_max_active", application.getDatabase().getDataSource().getMaxActive());
object.put("db_active", application.getDatabase().getDataSource().getNumActive());
@@ -222,53 +247,6 @@ public String getClusterDetails() {
return object.toString();
}
- public String tail(File file, int lines) {
- java.io.RandomAccessFile fileHandler = null;
- try {
- fileHandler = new java.io.RandomAccessFile(file, "r");
- long fileLength = fileHandler.length() - 1;
- StringBuilder sb = new StringBuilder();
- int line = 0;
-
- for (long filePointer = fileLength; filePointer != -1; filePointer--) {
- fileHandler.seek(filePointer);
- int readByte = fileHandler.readByte();
-
- if (readByte == 0xA) {
- line = line + 1;
- if (line == lines) {
- if (filePointer == fileLength) {
- continue;
- }
- break;
- }
- } else if (readByte == 0xD) {
- line = line + 1;
- if (line == lines) {
- if (filePointer == fileLength - 1) {
- continue;
- }
- break;
- }
- }
- sb.append((char) readByte);
- }
-
- String lastLine = sb.reverse().toString();
- return lastLine;
- } catch (java.io.IOException e) {
- log.error("Parsing log file failed.", e);
- return null;
- } finally {
- if (fileHandler != null)
- try {
- fileHandler.close();
- } catch (IOException e) {
- log.error("Parsing log file failed.", e);
- }
- }
- }
-
public void updateNextflowConfig(String content) {
NextflowPlugin plugin = (NextflowPlugin) PluginManager.getInstance().getPlugin(NextflowPlugin.ID);
String filename = plugin.getNextflowConfig();
diff --git a/src/main/java/cloudgene/mapred/util/Settings.java b/src/main/java/cloudgene/mapred/util/Settings.java
index d2520b6a..32da184e 100644
--- a/src/main/java/cloudgene/mapred/util/Settings.java
+++ b/src/main/java/cloudgene/mapred/util/Settings.java
@@ -48,6 +48,8 @@ public class Settings {
private List