Commit 11cb69cf authored by Yann Mombrun's avatar Yann Mombrun
Browse files

OPENAXES-173 - Fix the path to the file to check existence in isEnabled...

OPENAXES-173 - Fix the path to the file to check existence in isEnabled method. Test if enabled inside start and stop methods.
parent fcbfd3f1
......@@ -45,7 +45,7 @@ public class Imsearch extends WebLabServer {
private static final String PID_FILE = "imsearch.pid";
private String imsearchDirectory, imsearchScript;
private String imsearchDirectory;
/**
......@@ -122,6 +122,11 @@ public class Imsearch extends WebLabServer {
@Override
public Process start() {
if (!this.isEnabled()) {
this.logger.info("Imsearch should not be started, it is disabled.");
return ProcessUtils.dummyProccess();
}
if (this.status() != State.STOPPED) {
this.logger.severe(this.getName() + " is not stopped! Aborting start...");
return null;
......@@ -134,7 +139,7 @@ public class Imsearch extends WebLabServer {
this.logger.info(this.getName() + " is starting...");
final Process p = ProcessUtils.runProcess(this.logger, this.getBinDirectory(), this.getEnv(), this.getScript(), "start", this.imsearchDirectory, this.imsearchScript);
final Process p = ProcessUtils.runProcess(this.logger, this.getBinDirectory(), this.getEnv(), this.getScript(), "start", this.imsearchDirectory, String.valueOf(this.getPort()));
final int exitCode;
try {
exitCode = p.waitFor();
......@@ -154,6 +159,11 @@ public class Imsearch extends WebLabServer {
@Override
public void stop() {
if (!this.isEnabled()) {
this.logger.info("Imsearch should not be stopped, it is disabled.");
return;
}
this.logger.info(this.getName() + " is stopping...");
ProcessUtils.runProcess(this.logger, this.getBinDirectory(), this.getEnv(), this.getScript(), "stop");
this.logger.info(this.getName() + " is stopped.");
......@@ -215,7 +225,7 @@ public class Imsearch extends WebLabServer {
@Override
public boolean isEnabled() {
final File binDir = new File(this.imsearchDirectory);
final File binDir = new File(this.getBinDirectory(), this.imsearchDirectory);
return super.isEnabled() && binDir.exists() && binDir.isDirectory() && binDir.listFiles().length > 0;
}
......@@ -237,21 +247,4 @@ public class Imsearch extends WebLabServer {
}
/**
* @return the imsearchScript
*/
public String getImsearchScript() {
return this.imsearchScript;
}
/**
* @param imsearchScript
* the imsearchScript to set
*/
public void setImsearchcript(String imsearchScript) {
this.imsearchScript = imsearchScript;
}
}
......@@ -122,6 +122,11 @@ public class Visor extends WebLabServer {
@Override
public Process start() {
if (!this.isEnabled()) {
this.logger.info("Visor should not be started, it is disabled.");
return ProcessUtils.dummyProccess();
}
if (this.status() != State.STOPPED) {
this.logger.severe(this.getName() + " is not stopped! Aborting start...");
return null;
......@@ -154,6 +159,10 @@ public class Visor extends WebLabServer {
@Override
public void stop() {
if (!this.isEnabled()) {
this.logger.info("Visor should not be stopped, it is disabled.");
return;
}
this.logger.info(this.getName() + " is stopping...");
ProcessUtils.runProcess(this.logger, this.getBinDirectory(), this.getEnv(), this.getScript(), "stop");
this.logger.info(this.getName() + " is stopped.");
......@@ -221,7 +230,7 @@ public class Visor extends WebLabServer {
@Override
public boolean isEnabled() {
final File binDir = new File(this.cpuvisorDirectory);
final File binDir = new File(this.getBinDirectory(), this.cpuvisorDirectory);
return super.isEnabled() && binDir.exists() && binDir.isDirectory() && binDir.listFiles().length > 0;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment