Skip to content

Commit 90752fc

Browse files
committed
GethNode:restart individual clt instead of all
1 parent 6585785 commit 90752fc

File tree

1 file changed

+52
-33
lines changed

1 file changed

+52
-33
lines changed

GethNode/init-geth

+52-33
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,41 @@ def TerminateProc(proc: subprocess.Popen) -> None:
134134
pass
135135

136136

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+
137172
def main():
138173
if not os.path.isfile(JWT_PATH):
139174
with open(JWT_PATH, 'w') as f:
@@ -144,33 +179,11 @@ def main():
144179
valiCltProc = None
145180

146181
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()
174187

175188
# register signal handler
176189
signal.signal(signal.SIGTERM, OnTerminate)
@@ -179,20 +192,26 @@ def main():
179192
# wait for termination
180193
while not TERMINATE_EVENT.is_set():
181194
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 '
184197
f'{execCltProc.returncode}'
185198
)
199+
# reboot execution client
200+
execCltProc = StartExecClt()
186201
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 '
189204
f'{consCltProc.returncode}'
190205
)
206+
# reboot consensus client
207+
consCltProc = StartConsClt()
191208
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 '
194211
f'{valiCltProc.returncode}'
195212
)
213+
# reboot validator client
214+
valiCltProc = StartValiClt()
196215
TERMINATE_EVENT.wait(1.0)
197216
finally:
198217
# terminate processes

0 commit comments

Comments
 (0)