|
@@ -262,9 +262,44 @@ async def golang_process_check():
|
|
|
print('Wait golang...')
|
|
print('Wait golang...')
|
|
|
time.sleep(1)
|
|
time.sleep(1)
|
|
|
|
|
|
|
|
|
|
+def kill_port(port, timeout = 1.5, force = True):
|
|
|
|
|
+ pids = {
|
|
|
|
|
+ c.pid for c in psutil.net_connections(kind = "inet")
|
|
|
|
|
+ if c.pid and c.laddr and c.laddr.port == port and c.status == psutil.CONN_LISTEN
|
|
|
|
|
+ }
|
|
|
|
|
+ procs = []
|
|
|
|
|
+ for pid in pids:
|
|
|
|
|
+ try:
|
|
|
|
|
+ p = psutil.Process(pid)
|
|
|
|
|
+ p.terminate()
|
|
|
|
|
+ procs.append(p)
|
|
|
|
|
+ except psutil.NoSuchProcess:
|
|
|
|
|
+ pass
|
|
|
|
|
+ except psutil.AccessDenied:
|
|
|
|
|
+ print("Golang PID is not dying, please shut down manually by sudo.")
|
|
|
|
|
+ raise
|
|
|
|
|
+
|
|
|
|
|
+ _, alive = psutil.wait_procs(procs, timeout = timeout)
|
|
|
|
|
+ if force:
|
|
|
|
|
+ for p in alive:
|
|
|
|
|
+ try:
|
|
|
|
|
+ p.kill()
|
|
|
|
|
+ except psutil.NoSuchProcess:
|
|
|
|
|
+ pass
|
|
|
|
|
+ except psutil.AccessDenied:
|
|
|
|
|
+ print("Golang PID is not dying, please shut down manually by sudo.")
|
|
|
|
|
+ raise
|
|
|
|
|
+
|
|
|
|
|
+ psutil.wait_procs(alive, timeout = timeout)
|
|
|
|
|
+
|
|
|
|
|
+ return sorted(pids)
|
|
|
|
|
+
|
|
|
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
|
BIN_DIR = os.path.join(BASE_DIR, "bin")
|
|
BIN_DIR = os.path.join(BASE_DIR, "bin")
|
|
|
|
|
|
|
|
|
|
+port_kill = kill_port(server_set["golang_port"])
|
|
|
|
|
+print("Golang port killed : " + str(port_kill))
|
|
|
|
|
+
|
|
|
exe_name = linux_exe_chmod()
|
|
exe_name = linux_exe_chmod()
|
|
|
exe_path = os.path.join(BIN_DIR, exe_name)
|
|
exe_path = os.path.join(BIN_DIR, exe_name)
|
|
|
|
|
|