force close if sock in use

This commit is contained in:
dj2ls 2022-02-19 21:30:52 +01:00
parent 34cf0a4b05
commit 6bc67362c1
4 changed files with 28 additions and 10 deletions

View file

@ -181,7 +181,22 @@ app.whenReady().then(() => {
console.log(file);
});
});
if(os.platform()=='darwin'){
daemonProcess = exec(path.join(__dirname) + '/tnc/daemon', [])
daemonProcess.on('error', (err) => {
console.log(err);
});
daemonProcess.on('message', (data) => {
console.log(data);
});
}
if(os.platform()=='linux'){
@ -221,7 +236,9 @@ app.whenReady().then(() => {
})
app.on('window-all-closed', () => {
// closing the tnc binary if not closed when closing application
// closing the tnc binary if not closed when closing application and also our daemon which has been started by the gui
daemonProcess.kill();
console.log("closing tnc...")
if(os.platform()=='win32' || os.platform()=='win64'){
@ -229,7 +246,9 @@ app.on('window-all-closed', () => {
}
if(os.platform()=='linux' || os.platform()=='darwin'){
console.log("kill process...")
exec('pkill', ['-9', 'tnc'])
}

View file

@ -38,7 +38,7 @@ sys.path.append(app_path)
structlog.get_logger("structlog").info("[C2 ] Searching for libcodec2...")
if sys.platform == 'linux':
files = glob.glob('**/*libcodec2*',recursive=True)
files.append('libcodec2.so')
elif sys.platform == 'darwin':
files = glob.glob('**/*libcodec2*.dylib',recursive=True)

View file

@ -61,10 +61,11 @@ class DAEMON():
while 1:
try:
if not static.TNCSTARTED:
static.AUDIO_INPUT_DEVICES, static.AUDIO_OUTPUT_DEVICES = audio.get_audio_devices()
except Exception as e:
print(e)
time.sleep(2)
time.sleep(1)
def update_serial_devices(self):
@ -280,15 +281,13 @@ class DAEMON():
if __name__ == '__main__':
# we need to run this on windows for multiprocessing support
multiprocessing.freeze_support()
# --------------------------------------------GET PARAMETER INPUTS
PARSER = argparse.ArgumentParser(description='Simons TEST TNC')
PARSER.add_argument('--port', dest="socket_port",default=3001, help="Socket port", type=int)
#PARSER.add_argument('--multiprocessing-fork', dest="multi_processing", help="test", type=str)
#PARSER.add_argument('pipe_handle', dest="pipe_handle_param", help="test", type=str)
PARSER = argparse.ArgumentParser(description='FreeDATA Daemon')
PARSER.add_argument('--port', dest="socket_port",default=3001, help="Socket port", type=int)
ARGS = PARSER.parse_args()
static.DAEMONPORT = ARGS.socket_port
@ -307,7 +306,7 @@ if __name__ == '__main__':
except Exception as e:
structlog.get_logger("structlog").error("[DMN] Starting TCP/IP socket failed", port=static.DAEMONPORT, e=e)
os._exit(1)
daemon = DAEMON()

View file

@ -113,6 +113,6 @@ if __name__ == '__main__':
except Exception as e:
structlog.get_logger("structlog").error("[TNC] Starting TCP/IP socket failed", port=static.PORT, e=e)
os._exit(1)
while 1:
time.sleep(1)