@@ -134,6 +134,41 @@ def TerminateProc(proc: subprocess.Popen) -> None:
134
134
pass
135
135
136
136
137
+ def StartExecClt () -> subprocess .Popen :
138
+ execCltSelect = os .getenv ('ETH_EXEC_CLT' , None )
139
+ if execCltSelect == 'geth' :
140
+ execCltProc = RunExecCltGeth ()
141
+ else :
142
+ raise RuntimeError (
143
+ 'Unknown execution client selection: {}' .format (execCltSelect )
144
+ )
145
+ return execCltProc
146
+
147
+ def StartConsClt () -> subprocess .Popen :
148
+ consCltSelect = os .getenv ('ETH_CONS_CLT' , None )
149
+ if consCltSelect == 'prysm' :
150
+ consCltProc = RunConsCltPrysm ()
151
+ elif consCltSelect == 'lighthouse' :
152
+ consCltProc = RunConsCltLighthouse ()
153
+ else :
154
+ raise RuntimeError (
155
+ 'Unknown consensus client selection: {}' .format (consCltSelect )
156
+ )
157
+ return consCltProc
158
+
159
+ def StartValiClt () -> subprocess .Popen :
160
+ valiCltProc = None
161
+ valiCltSelect = os .getenv ('ETH_VALI_CLT' , None )
162
+ if valiCltSelect == 'lighthouse' :
163
+ valiCltProc = RunValiCltLighthouse ()
164
+ elif valiCltSelect is not None :
165
+ raise RuntimeError (
166
+ 'Unknown validator client selection: {}' .format (valiCltSelect )
167
+ )
168
+ else :
169
+ print ('Validator client disabled.' )
170
+ return valiCltProc
171
+
137
172
def main ():
138
173
if not os .path .isfile (JWT_PATH ):
139
174
with open (JWT_PATH , 'w' ) as f :
@@ -144,33 +179,11 @@ def main():
144
179
valiCltProc = None
145
180
146
181
try :
147
- execCltSelect = os .getenv ('ETH_EXEC_CLT' , None )
148
- if execCltSelect == 'geth' :
149
- execCltProc = RunExecCltGeth ()
150
- else :
151
- raise RuntimeError (
152
- 'Unknown execution client selection: {}' .format (execCltSelect )
153
- )
154
-
155
- consCltSelect = os .getenv ('ETH_CONS_CLT' , None )
156
- if consCltSelect == 'prysm' :
157
- consCltProc = RunConsCltPrysm ()
158
- elif consCltSelect == 'lighthouse' :
159
- consCltProc = RunConsCltLighthouse ()
160
- else :
161
- raise RuntimeError (
162
- 'Unknown consensus client selection: {}' .format (consCltSelect )
163
- )
164
-
165
- valiCltSelect = os .getenv ('ETH_VALI_CLT' , None )
166
- if valiCltSelect == 'lighthouse' :
167
- valiCltProc = RunValiCltLighthouse ()
168
- elif valiCltSelect is not None :
169
- raise RuntimeError (
170
- 'Unknown validator client selection: {}' .format (valiCltSelect )
171
- )
172
- else :
173
- print ('Validator client disabled.' )
182
+ execCltProc = StartExecClt ()
183
+
184
+ consCltProc = StartConsClt ()
185
+
186
+ valiCltProc = StartValiClt ()
174
187
175
188
# register signal handler
176
189
signal .signal (signal .SIGTERM , OnTerminate )
@@ -179,20 +192,26 @@ def main():
179
192
# wait for termination
180
193
while not TERMINATE_EVENT .is_set ():
181
194
if execCltProc is not None and execCltProc .poll () is not None :
182
- raise RuntimeError (
183
- f'Execution client process terminated with code '
195
+ print (
196
+ f'ERROR: Execution client process terminated with code '
184
197
f'{ execCltProc .returncode } '
185
198
)
199
+ # reboot execution client
200
+ execCltProc = StartExecClt ()
186
201
if consCltProc is not None and consCltProc .poll () is not None :
187
- raise RuntimeError (
188
- f'Consensus client process terminated with code '
202
+ print (
203
+ f'ERROR: Consensus client process terminated with code '
189
204
f'{ consCltProc .returncode } '
190
205
)
206
+ # reboot consensus client
207
+ consCltProc = StartConsClt ()
191
208
if valiCltProc is not None and valiCltProc .poll () is not None :
192
- raise RuntimeError (
193
- f'Validator client process terminated with code '
209
+ print (
210
+ f'ERROR: Validator client process terminated with code '
194
211
f'{ valiCltProc .returncode } '
195
212
)
213
+ # reboot validator client
214
+ valiCltProc = StartValiClt ()
196
215
TERMINATE_EVENT .wait (1.0 )
197
216
finally :
198
217
# terminate processes
0 commit comments