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