Read backup output async

This commit is contained in:
snowleo 2014-01-25 15:33:33 +01:00
parent 32b118d3c0
commit 52c3169a3c

View file

@ -91,8 +91,7 @@ public class Backup implements Runnable
server.dispatchCommand(cs, "save-all"); server.dispatchCommand(cs, "save-all");
server.dispatchCommand(cs, "save-off"); server.dispatchCommand(cs, "save-off");
ess.runTaskAsynchronously( ess.runTaskAsynchronously(new Runnable()
new Runnable()
{ {
@Override @Override
public void run() public void run()
@ -103,10 +102,16 @@ public class Backup implements Runnable
childBuilder.redirectErrorStream(true); childBuilder.redirectErrorStream(true);
childBuilder.directory(ess.getDataFolder().getParentFile().getParentFile()); childBuilder.directory(ess.getDataFolder().getParentFile().getParentFile());
final Process child = childBuilder.start(); final Process child = childBuilder.start();
ess.runTaskAsynchronously(new Runnable()
{
@Override
public void run()
{
try
{
final BufferedReader reader = new BufferedReader(new InputStreamReader(child.getInputStream())); final BufferedReader reader = new BufferedReader(new InputStreamReader(child.getInputStream()));
try try
{ {
child.waitFor();
String line; String line;
do do
{ {
@ -123,6 +128,14 @@ public class Backup implements Runnable
reader.close(); reader.close();
} }
} }
catch (IOException ex)
{
LOGGER.log(Level.SEVERE, null, ex);
}
}
});
child.waitFor();
}
catch (InterruptedException ex) catch (InterruptedException ex)
{ {
LOGGER.log(Level.SEVERE, null, ex); LOGGER.log(Level.SEVERE, null, ex);
@ -133,8 +146,7 @@ public class Backup implements Runnable
} }
finally finally
{ {
ess.scheduleSyncDelayedTask( ess.scheduleSyncDelayedTask(new Runnable()
new Runnable()
{ {
@Override @Override
public void run() public void run()