@@ -11,20 +11,35 @@ def set_node_arg(arg_name: str, arg_value: str = ''):
1111 """
1212 assert arg_name .startswith ('-' ), 'arg_name must start with "-" or "--"'
1313 service = get_validator_service ()
14- command = get_node_start_command ()
15- if command .split (' ' )[0 ] != '/usr/bin/ton/validator-engine/validator-engine' :
16- raise Exception ('Invalid node start command in service file' )
17- if command is None :
14+ start_command = get_node_start_command ()
15+ if start_command is None :
1816 raise Exception ('Cannot find node start command in service file' )
19- args = get_node_args (command )
17+ first_arg = start_command .split (' ' )[0 ]
18+ if first_arg != '/usr/bin/ton/validator-engine/validator-engine' :
19+ raise Exception ('Invalid node start command in service file' )
20+ #end if
21+
22+ node_args = get_node_args (start_command )
2023 if arg_value == '-d' :
21- args .pop (arg_name , None )
24+ node_args .pop (arg_name , None )
2225 else :
23- args [arg_name ] = arg_value
24- new_command = command .split (' ' )[0 ] + ' ' + ' ' .join ([f'{ k } { v } ' for k , v in args .items ()])
25- new_service = service .replace (command , new_command )
26- with open ('/etc/systemd/system/validator.service' , 'w' ) as f :
27- f .write (new_service )
26+ if ' ' in arg_value :
27+ node_args [arg_name ] = arg_value .split ()
28+ else :
29+ node_args [arg_name ] = [arg_value ]
30+ #end if
31+
32+ buffer = list ()
33+ buffer .append (first_arg )
34+ for key , value_list in node_args .items ():
35+ if len (value_list ) == 0 :
36+ buffer .append (f"{ key } " )
37+ for value in value_list :
38+ buffer .append (f"{ key } { value } " )
39+ new_start_command = ' ' .join (buffer )
40+ new_service = service .replace (start_command , new_start_command )
41+ with open ('/etc/systemd/system/validator.service' , 'w' ) as file :
42+ file .write (new_service )
2843 restart_node ()
2944#end define
3045
0 commit comments