Skip to content

Commit 8428480

Browse files
Merge pull request tronprotocol#6095 from halibobo1205/477/backup_thead_pool_close_opt
feat(backup): make nodes with backup shutdown gracefully by kill -15
2 parents 160a440 + 2333531 commit 8428480

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

framework/src/main/java/org/tron/common/backup/socket/BackupServer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ public void initChannel(NioDatagramChannel ch)
9595
public void close() {
9696
logger.info("Closing backup server...");
9797
shutdown = true;
98-
ExecutorServiceManager.shutdownAndAwaitTermination(executor, name);
9998
backupManager.stop();
10099
if (channel != null) {
101100
try {
@@ -104,6 +103,7 @@ public void close() {
104103
logger.warn("Closing backup server failed.", e);
105104
}
106105
}
106+
ExecutorServiceManager.shutdownAndAwaitTermination(executor, name);
107107
logger.info("Backup server closed.");
108108
}
109109
}

framework/src/test/java/org/tron/common/backup/BackupServerTest.java

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.junit.Rule;
88
import org.junit.Test;
99
import org.junit.rules.TemporaryFolder;
10+
import org.junit.rules.Timeout;
1011
import org.tron.common.backup.socket.BackupServer;
1112
import org.tron.common.parameter.CommonParameter;
1213
import org.tron.core.Constant;
@@ -17,6 +18,9 @@ public class BackupServerTest {
1718

1819
@Rule
1920
public TemporaryFolder temporaryFolder = new TemporaryFolder();
21+
22+
@Rule
23+
public Timeout globalTimeout = Timeout.seconds(60);
2024
private BackupServer backupServer;
2125

2226
@Before
@@ -40,5 +44,7 @@ public void tearDown() {
4044
@Test
4145
public void test() throws InterruptedException {
4246
backupServer.initServer();
47+
// wait for the server to start
48+
Thread.sleep(1000);
4349
}
4450
}

0 commit comments

Comments
 (0)