@@ -58,46 +58,43 @@ public StartBootstrap(RskContext ctx) {
58
58
public static void main (String [] args ) {
59
59
setUpThread (Thread .currentThread ());
60
60
61
- try (RskContext ctx = new BootstrapRskContext (args )) {
62
- int result = new CommandLine (new StartBootstrap (ctx )).setUnmatchedArgumentsAllowed (true ).execute (args );
61
+ RskContext ctx = null ;
62
+ try {
63
+ ctx = new BootstrapRskContext (args );
64
+
65
+ new CommandLine (new StartBootstrap (ctx )).setUnmatchedArgumentsAllowed (true ).execute (args );
66
+ } catch (Exception e ) {
67
+ logger .error ("Main thread of RSK bootstrap node crashed" , e );
63
68
64
- if (result != 0 ) {
65
- throw new PicocliBadResultException ( result );
69
+ if (ctx != null ) {
70
+ ctx . close ( );
66
71
}
72
+
73
+ System .exit (1 );
67
74
}
68
75
}
69
76
70
77
@ Override
71
- public Integer call () throws IOException {
78
+ public Integer call () throws Exception {
72
79
PreflightChecksUtils preflightChecks = new PreflightChecksUtils (ctx );
73
80
Runtime runtime = Runtime .getRuntime ();
74
- NodeStopper nodeStopper = System ::exit ;
75
81
76
- runBootstrapNode (ctx , preflightChecks , runtime , nodeStopper );
82
+ runBootstrapNode (ctx , preflightChecks , runtime );
77
83
return 0 ;
78
84
}
79
85
80
86
static void runBootstrapNode (@ Nonnull RskContext ctx ,
81
87
@ Nonnull PreflightChecksUtils preflightChecks ,
82
- @ Nonnull Runtime runtime ,
83
- @ Nonnull NodeStopper nodeStopper ) {
84
- try {
85
- // make preflight checks
86
- preflightChecks .runChecks ();
88
+ @ Nonnull Runtime runtime ) throws Exception {
89
+ // make preflight checks
90
+ preflightChecks .runChecks ();
87
91
88
- // subscribe to shutdown hook
89
- runtime .addShutdownHook (new Thread (ctx ::close , "stopper" ));
92
+ // subscribe to shutdown hook
93
+ runtime .addShutdownHook (new Thread (ctx ::close , "stopper" ));
90
94
91
- // start node runner
92
- NodeRunner runner = ctx .getNodeRunner ();
93
- runner .run ();
94
- } catch (Exception e ) {
95
- logger .error ("Main thread of RSK bootstrap node crashed" , e );
96
-
97
- ctx .close ();
98
-
99
- nodeStopper .stop (1 );
100
- }
95
+ // start node runner
96
+ NodeRunner runner = ctx .getNodeRunner ();
97
+ runner .run ();
101
98
}
102
99
103
100
static void setUpThread (@ Nonnull Thread thread ) {
0 commit comments