fix bugs
This commit is contained in:
parent
d28e178ecc
commit
4019060e68
@ -1,6 +1,5 @@
|
|||||||
proxy:
|
proxy:{% for idx in running_idx %}
|
||||||
{% for idx in running_idx %}
|
- url: "socks5://192.168.122.128:108{{idx}}"
|
||||||
- url: "socks5://192.168.122.128:108{{idx}}}"
|
|
||||||
weight: 5
|
weight: 5
|
||||||
{% end %}
|
{% end %}
|
||||||
sticky: false
|
sticky: false
|
||||||
|
|||||||
16
o_manager.py
16
o_manager.py
@ -13,6 +13,7 @@ class OManager:
|
|||||||
self.idx = 0
|
self.idx = 0
|
||||||
self.running_idx = []
|
self.running_idx = []
|
||||||
self.run_task = []
|
self.run_task = []
|
||||||
|
self.PID = None
|
||||||
if loop:
|
if loop:
|
||||||
self.loop = loop
|
self.loop = loop
|
||||||
else:
|
else:
|
||||||
@ -68,6 +69,7 @@ class OManager:
|
|||||||
idx = op.idx
|
idx = op.idx
|
||||||
if idx not in self.running_idx:
|
if idx not in self.running_idx:
|
||||||
self.running_idx.append(idx)
|
self.running_idx.append(idx)
|
||||||
|
self.reset_lb()
|
||||||
|
|
||||||
def stop_all(self):
|
def stop_all(self):
|
||||||
loop = self.loop
|
loop = self.loop
|
||||||
@ -78,26 +80,28 @@ class OManager:
|
|||||||
|
|
||||||
def reset_lb(self):
|
def reset_lb(self):
|
||||||
try:
|
try:
|
||||||
os.kill(self.PID, signal.SIGINT)
|
if self.PID:
|
||||||
|
os.kill(self.PID, signal.SIGINT)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
print("kill failed:", err)
|
print("kill failed:", err)
|
||||||
for task in self.run_task:
|
for task in self.run_task:
|
||||||
task.cancel()
|
task.cancel()
|
||||||
self.run_task = []
|
self.run_task = []
|
||||||
lb_cfg_fp = self.generate_lb_cfg()
|
lb_cfg_fp = self.generate_lb_cfg()
|
||||||
# TODO: remove --mute-replay-warnings
|
lb_cmd = ["go-socks-lb/go-socks-lb", "-config",
|
||||||
lb_cmd = " ".join(["go-socks-lb/go-socks-lb", "-config",
|
lb_cfg_fp, "-bind", "0.0.0.0:7000"]
|
||||||
lb_cfg_fp, "-bind", "0.0.0.0:7000"])
|
print("lb_cmd", lb_cmd)
|
||||||
self.run_task.append(self.loop.create_task(
|
self.run_task.append(self.loop.create_task(
|
||||||
self.run_cmd(lb_cmd)))
|
self.run_cmd(lb_cmd)))
|
||||||
|
|
||||||
async def run_cmd(self, cmd):
|
async def run_cmd(self, cmd):
|
||||||
while True:
|
while True:
|
||||||
|
print("Manager trying to start go")
|
||||||
proc = await asyncio.create_subprocess_exec(
|
proc = await asyncio.create_subprocess_exec(
|
||||||
cmd,
|
cmd[0], *cmd[1:],
|
||||||
stdout=asyncio.subprocess.PIPE,
|
stdout=asyncio.subprocess.PIPE,
|
||||||
stderr=asyncio.subprocess.PIPE)
|
stderr=asyncio.subprocess.PIPE)
|
||||||
print("started")
|
print("Manager started", cmd)
|
||||||
self.proc = proc
|
self.proc = proc
|
||||||
self.PID = proc.pid
|
self.PID = proc.pid
|
||||||
print(f"pid: {self.PID}")
|
print(f"pid: {self.PID}")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user