webrtc server creation waiting added, webrtc and app order changed, titles.json removed

This commit is contained in:
C
2023-02-06 16:40:10 +05:00
parent 8c5b0dc1f0
commit 9f7070ed26
5 changed files with 125 additions and 18 deletions
+6 -6
View File
@@ -24,18 +24,18 @@ const run_session = async (req, res, next) => {
return
}
var webrtc_pid = await run_webrtc(webrtc_port, app_port)
if (!webrtc_pid) {
next(new server_error('can not run webrtc'))
return
}
var app_pid = await run_app(app_path, app_port)
if (!app_pid) {
next(new server_error('can not run app'))
return
}
var webrtc_pid = await run_webrtc(webrtc_port, app_port)
if (!webrtc_pid) {
next(new server_error('can not run webrtc'))
return
}
var add_runnning_session_result = await database.add_running_session(session_id, app_pid, webrtc_pid)
if(!add_runnning_session_result) {
+5
View File
@@ -5,6 +5,10 @@ const webrtc_server_path = config.webrtc_server_path
const app_args_static = config.app_args.static
const app_port_arg = config.app_args.runtime.port
const fs = require('fs')
const tcp_port_used = require('tcp-port-used')
const webrtc_timeout = 5000
const webrtc_retry_time = 100
const is_proc_running = (pid) => {
return is_running(pid)
@@ -37,6 +41,7 @@ const run_webrtc = async (webrtc_port, app_port) => {
webrtc_proc = fork(webrtc_server_path, [webrtc_proc_arg], {
detached: true
})
await tcp_port_used.waitUntilUsed(webrtc_port, webrtc_retry_time, webrtc_timeout)
} catch (err) {
return null
}