sfu creation added
This commit is contained in:
@@ -2,6 +2,7 @@ const {spawn, fork} = require('node:child_process')
|
||||
const is_running = require('is-running')
|
||||
const config = require('../../config')
|
||||
const webrtc_server_path = config.webrtc_server_path
|
||||
const sfu_server_path = config.sfu_server_path
|
||||
const app_args_static = config.app_args.static
|
||||
const app_port_arg = config.app_args.runtime.port
|
||||
const fs = require('fs')
|
||||
@@ -76,6 +77,28 @@ const run_app = async (app_path, app_port) => {
|
||||
|
||||
}
|
||||
|
||||
const run_sfu = async (sfu_port) => {
|
||||
if (!fs.existsSync(sfu_server_path)) {
|
||||
return null
|
||||
}
|
||||
|
||||
let sfu_proc
|
||||
try {
|
||||
let sfu_proc_arg = JSON.stringify({sfu_port:sfu_port})
|
||||
sfu_proc = fork(sfu_server_path, [sfu_proc_arg], {
|
||||
detached: true
|
||||
})
|
||||
//await tcp_port_used.waitUntilUsed(webrtc_port, webrtc_retry_time, webrtc_timeout)
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
return null
|
||||
}
|
||||
|
||||
//let proc_status = await is_proc_running_async(webrtc_proc.pid, 500)
|
||||
|
||||
return (sfu_proc) ? sfu_proc.pid : null
|
||||
}
|
||||
|
||||
const kill_proc = (pid) => {
|
||||
if (!is_proc_running(pid)) {
|
||||
return
|
||||
@@ -96,6 +119,7 @@ const kill_proc = (pid) => {
|
||||
module.exports = {
|
||||
run_webrtc,
|
||||
run_app,
|
||||
run_sfu,
|
||||
is_proc_running,
|
||||
is_proc_running_async,
|
||||
kill_proc
|
||||
|
||||
Reference in New Issue
Block a user