Commit d50d378c authored by Dave Syer's avatar Dave Syer

Prevent more than one app at a time from running

parent 0bca416d
...@@ -53,7 +53,7 @@ public class RunCommand extends OptionParsingCommand { ...@@ -53,7 +53,7 @@ public class RunCommand extends OptionParsingCommand {
public void stop() { public void stop() {
if (this.getHandler() != null) { if (this.getHandler() != null) {
((RunOptionHandler) this.getHandler()).runner.stop(); ((RunOptionHandler) this.getHandler()).stop();
} }
} }
...@@ -78,8 +78,21 @@ public class RunCommand extends OptionParsingCommand { ...@@ -78,8 +78,21 @@ public class RunCommand extends OptionParsingCommand {
this.quietOption = option(asList("quiet", "q"), "Quiet logging"); this.quietOption = option(asList("quiet", "q"), "Quiet logging");
} }
public synchronized void stop() {
if (this.runner != null) {
this.runner.stop();
}
this.runner = null;
}
@Override @Override
protected void run(OptionSet options) throws Exception { protected synchronized void run(OptionSet options) throws Exception {
if (this.runner != null) {
throw new RuntimeException(
"Already running. Please stop the current application before running another.");
}
FileOptions fileOptions = new FileOptions(options); FileOptions fileOptions = new FileOptions(options);
if (options.has(this.editOption)) { if (options.has(this.editOption)) {
......
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