Skip to content
This repository was archived by the owner on May 27, 2022. It is now read-only.

Commit e82a29d

Browse files
authored
Merge pull request #11 from jpmorganchase/clean_shutdown
Wait for solc quit to complete before returning (fixes #5)
2 parents 257d132 + f1c3fa4 commit e82a29d

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

cakeshop-api/src/main/java/com/jpmorgan/cakeshop/db/BlockScanner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public void init() {
8181
}
8282

8383
public void shutdown() {
84-
LOG.debug("shutdown " + getId());
84+
LOG.info("Stopping BlockScanner (thread id=" + getId() + ")");
8585
this.stopped = true;
8686
synchronized(wakeup) {
8787
this.wakeup.notify();

cakeshop-api/src/main/java/com/jpmorgan/cakeshop/db/MetricsBlockListener.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,14 @@ private void startThread() {
100100
@PreDestroy
101101
@Override
102102
public void shutdown() {
103+
LOG.info("Stopping MetricsBlockListener (thread id=" + metricCollector.getId() + ")");
103104
LOG.debug("shutdown" + metricCollector.getId());
104105
if (this.metricCollector != null && this.metricCollector.isAlive()) {
105106
this.metricCollector.running = false;
106-
this.metricCollector.interrupt();
107+
try {
108+
this.metricCollector.join();
109+
} catch (InterruptedException e) {
110+
}
107111
}
108112
}
109113

cakeshop-api/src/main/java/com/jpmorgan/cakeshop/db/SavingBlockListener.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,8 @@ protected void init() {
9595
@PreDestroy
9696
@Override
9797
public void shutdown() {
98-
LOG.debug("shutdown " + blockSaver.getId());
98+
LOG.info("Stopping SavingBlockListener (thread id=" + blockSaver.getId() + ")");
9999
blockSaver.running = false;
100-
blockSaver.interrupt();
101100
}
102101

103102
protected void saveBlock(Block block) {

cakeshop-api/src/main/java/com/jpmorgan/cakeshop/service/impl/GethHttpServiceImpl.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,15 +284,17 @@ protected void autoStop() {
284284
deletePid();
285285

286286
// stop solc server
287+
LOG.info("Stopping solc daemon");
287288
List<String> args = Lists.newArrayList(
288289
gethConfig.getNodePath(),
289290
gethConfig.getSolcPath(),
290291
"--stop-ipc");
291292

292293
ProcessBuilder builder = ProcessUtils.createProcessBuilder(gethConfig, args);
293294
try {
294-
builder.start();
295-
} catch (IOException e) {
295+
Process proc = builder.start();
296+
proc.waitFor();
297+
} catch (IOException | InterruptedException e) {
296298
}
297299
}
298300

0 commit comments

Comments
 (0)