|
11 | 11 | from mypyconsole.mypyconsole import MyPyConsole |
12 | 12 |
|
13 | 13 | from mytoninstaller.config import GetLiteServerConfig, get_ls_proxy_config |
14 | | -from mytoninstaller.node_args import get_node_args |
| 14 | +from mytoninstaller.node_args import get_node_args, set_node_arg |
15 | 15 | from mytoninstaller.utils import GetInitBlock |
16 | 16 | from mytoncore.utils import dict2b64, str2bool, b642dict |
17 | 17 |
|
@@ -63,6 +63,7 @@ def inject_globals(func): |
63 | 63 | console.name = "MyTonInstaller" |
64 | 64 | console.color = console.RED |
65 | 65 | console.AddItem("status", inject_globals(Status), "Print TON component status") |
| 66 | + console.AddItem("set_node_argument", inject_globals(set_node_argument), "Set node argument") |
66 | 67 | console.AddItem("enable", inject_globals(Enable), "Enable some function") |
67 | 68 | console.AddItem("update", inject_globals(Enable), "Update some function: 'JR' - jsonrpc. Example: 'update JR'") |
68 | 69 | console.AddItem("plsc", inject_globals(PrintLiteServerConfig), "Print lite-server config") |
@@ -131,6 +132,34 @@ def Status(local, args): |
131 | 132 | #end define |
132 | 133 |
|
133 | 134 |
|
| 135 | +def restart_node(): |
| 136 | + exit_code = run_as_root(["systemctl", "daemon-reload"]) |
| 137 | + if not exit_code: |
| 138 | + raise Exception(f"`systemctl daemon-reload` failed with exit code {exit_code}") |
| 139 | + exit_code = run_as_root(["systemctl", "restart", "validator"]) |
| 140 | + if not exit_code: |
| 141 | + raise Exception(f"`systemctl restart validator` failed with exit code {exit_code}") |
| 142 | +#end define |
| 143 | + |
| 144 | + |
| 145 | +def set_node_argument(local, args): |
| 146 | + if len(args) < 1: |
| 147 | + color_print("{red}Bad args. Usage:{endc} set_node_argument <arg-name> [arg-value] [-d (to delete)]") |
| 148 | + return |
| 149 | + arg_name = args[0] |
| 150 | + if len(args) == 1: |
| 151 | + set_node_arg(arg_name) |
| 152 | + else: |
| 153 | + arg_value = args[1] |
| 154 | + if arg_value == "-d": |
| 155 | + set_node_arg(arg_name, None) |
| 156 | + else: |
| 157 | + set_node_arg(arg_name, arg_value) |
| 158 | + restart_node() |
| 159 | + color_print("set_node_argument - {green}OK{endc}") |
| 160 | +#end define |
| 161 | + |
| 162 | + |
134 | 163 | def Enable(local, args): |
135 | 164 | try: |
136 | 165 | name = args[0] |
|
0 commit comments