File tree 1 file changed +20
-11
lines changed
src/main/java/io/opensergo
1 file changed +20
-11
lines changed Original file line number Diff line number Diff line change @@ -102,19 +102,28 @@ public void start() throws Exception {
102
102
}
103
103
104
104
private void keepAlive () {
105
- try {
106
- if (status != OpenSergoClientStatus .STARTING
107
- && status != OpenSergoClientStatus .STARTED
108
- && status != OpenSergoClientStatus .SHUTDOWN ) {
109
- OpenSergoLogger .info ("try to restart openSergoClient..." );
110
- this .start ();
105
+ // TODO change to event-based design, instead of for-loop.
106
+ for (;;) {
107
+ if (status == OpenSergoClientStatus .SHUTDOWN ) {
108
+ return ;
111
109
}
112
- Thread .sleep (TimeUnit .SECONDS .toMillis (10 ));
113
- if ( status != OpenSergoClientStatus .SHUTDOWN ) {
114
- keepAlive ();
110
+
111
+ try {
112
+ if (status == OpenSergoClientStatus .INTERRUPTED ) {
113
+ OpenSergoLogger .info ("try to restart openSergoClient..." );
114
+ this .start ();
115
+ }
116
+ Thread .sleep (TimeUnit .SECONDS .toMillis (10 ));
117
+ } catch (InterruptedException e ) {
118
+ OpenSergoLogger .error (e .toString (), e );
119
+ } catch (Exception e ) {
120
+ try {
121
+ this .close ();
122
+ } catch (Exception ex ) {
123
+ status = OpenSergoClientStatus .SHUTDOWN ;
124
+ }
125
+ OpenSergoLogger .error ("close OpenSergoClient because of " + e , e );
115
126
}
116
- } catch (Exception e ) {
117
- e .printStackTrace ();
118
127
}
119
128
}
120
129
You can’t perform that action at this time.
0 commit comments