owt-server 服务开机自启

owt-server 服务开机自启

owt-server 服务需要进入镜像内部,执行startowt.sh 脚本进行启动。但如果服务器断电重启了,服务在业主地方。业主又是内网环境,启动服务就会很复杂。 这个时候 owt-server 开机自启就很重要了,官网并没有开机自启的方式。研究了一下可以实现,需要改一下 docker启动方式。

目前只用到4.35.1.0 这两个版本的。

owt-server 4.3 开机自启方式

4.3 版本没有提供 startowt.sh 脚本,需要自己添加启动方式的 shell 脚本

bash 复制代码
docker run -it  --restart=always   -d  --name owt-server -p 3004:3004 -p 3300:3300 -p 8092:8092 -p 60000-60050:60000-60050/udp \
    -v /home/zbh/owt-server/portal/portal.toml:/home/owt/portal/portal.toml \
    -v /home/zbh/owt-server/webrtc_agent/agent.toml:/home/owt/webrtc_agent/agent.toml \
    -v /home/zbh/owt-server/logs:/home/owt/logs \
    -v /home/zbh/owt-server/startowt.sh:/home/startowt.sh \
    yuhanghate/owt-server:4.3.1 /bin/bash /home/start.sh

这里的start.sh 脚本是我自己做镜像时挂上去的。如果需要改动也可以映射出来改。

  • start.sh脚本内容:

    bash 复制代码
    #!/usr/bin/env bash
    /home/owt/bin/init-all.sh && /home/owt/bin/start-all.sh
    sleep infinity

这里主要是加了 sleep infinity 命令。可以让主机重启以后,运行的docker 镜像重启服务器以后。可以一直不结束,如果不加这个命令。会导致docker镜像重启了,里面的服务没有重启。3004或者3300对应端口的网站没有启动

owt-server 5.1.0 开机自启方式

bash 复制代码
    docker run -it  --restart=always  --user root  -d  --name owt-server -p 3004:3004 -p 3300:3300 -p 8092:8092 -p 60000-60050:60000-60050/udp \
    -v /home/zbh/owt-server/portal/portal.toml:/home/owt/portal/portal.toml \
    -v /home/zbh/owt-server/webrtc_agent/agent.toml:/home/owt/webrtc_agent/agent.toml \
    -v /home/zbh/owt-server/logs:/home/owt/logs \
    -v /home/zbh/owt-server/startowt.sh:/home/startowt.sh \
    yuhanghate/owt-server:5.1.0 /bin/bash /home/startowt.sh

/home/zbh/owt-server 路径换成实体机上的路径名称。启动的话,需要配置portal.tomlagent.toml两个文件。
镜像是owt 用户,需要加 --user root 把当前镜像升级到root权限。不然执行 startowt.sh脚本的时候,会失败。

  • portal.toml 文件配置

    ini 复制代码
    [portal]
    keystorePath = "./cert/certificate.pfx"
    hostname = "" #default: ""
    ip_address = "192.168.100.210" #default: ""
    # Port that the socket.io server listens at.
    port = 8092 #default: 8080
    ssl = true #default: true
    force_tls_v12 = false #default: false, tls1 and tls1.1 will not be allowed if set to true
    #The network inferface the socket.io will be bound to in case portal.ip_address (the 'ip_address' item above) is not specified or equal to "".
    # networkInterface = "eth1"
    # How many seconds before Socket.IO client sending a new ping packet. This value might be overwrote by client side.
    # ping_interval = 25 #default: undefined
    # How many seconds without a pong packet to consider the Socket.IO connection closed. This value might be overwrote by client side.
    # ping_timeout = 60 #default: undefined
    # Life time for reconnection ticket. Unit: second.
    reconnection_ticket_lifetime = 600 #default: 600
    # Client will leave conference if it cannot reconnect to Socket.IO server after |reconnection_timeout| seconds.
    reconnection_timeout = 5 #default: 60
    #default: *, allow cross origin request share list. Add http(s)://web-app-server-ip-or-hostname:port to cors list in product deployment, example: ["http://web-app-server-ip-or-hostname:3001", "https://web-app-server-ip-or-hostname:3004"].
    cors = ["*"]
    ​
    ​
    [cluster]
    name = "owt-cluster"
    ​
    #The number of times to retry joining if the first try fails.
    join_retry = 60 #default: 60
    ​
    #The interval of reporting the work load
    report_load_interval = 1000 #default: 1000, unit: millisecond
    ​
    #The max CPU load under which this worker can taks new tasks.
    max_load = 0.85 #default: 0.85
    ​
    ​
    [capacity]
    #The ISP list this portal is able to handle
    #If the ISP list is set to be non-empty, only the creating token requests with preference.ips being matched with one element of this list will be scheduled to this portal.
    isps = [] #default: [], which means all ISPs.
    #The region list this portal prefers to handle
    #If the region list is set to be non-empty, the creating token requests with preference.region being matched with one element of this list will be priorly scheduled to this portal.
    regions = [] #default: [], which means all regions.
    ​
    ​
    [rabbit]
    host = "localhost" #default: "localhost"
    port = 5672 #default: 5672
    ​
    [mongo]
    dataBaseURL = "localhost/owtdb" #default: "localhost/owtdb"

ip_address 属性改成自己主机的ip地址

reconnection_timeout :可以修改owt服务的websocket超时时间。防止杀进程等操作时2个画面时间过长

  • agent.toml 配置文件

    ini 复制代码
    [agent]
    #Max processes that agent can run
    maxProcesses = 13 #default: 13
    ​
    #Number of precesses that agent runs when it starts. 1 <= prerunProcesses <= maxProcesses.
    prerunProcesses = 2 #default: 2
    ​
    ​
    [cluster]
    name = "owt-cluster"
    ​
    #The number of times to retry joining if the first try fails.
    join_retry = 60 #default: 60
    ​
    #The interval of reporting the work load
    report_load_interval = 1000 #default: 1000, unit: millisecond
    ​
    #The max network load under which this worker can take new tasks.
    max_load = 0.85 #default: 0.85
    ​
    #The name of network-interface for reporting load.
    network_name = "lo"
    ​
    #The bandwidth of network-interface used for WebRTC peerconnections. 
    network_max_scale = 1000 #unit: Mbps
    ​
    ​
    [capacity]
    #The ISP list this agent is able to handle.
    #If the ISP list is set to be non-empty, only the creating token requests with preference.ips being matched with one element of this list will be scheduled to this agent.
    isps = [] #default: [], which means all ISPs.
    #The region list this agent prefers to handle
    #If the region list is set to be non-empty, the creating token requests with preference.region being matched with one element of this list will be priorly scheduled to this agent.
    regions = [] #default: [], which means all regions.
    ​
    ​
    [rabbit]
    host = "localhost" #default: "localhost"
    port = 5672 #default: 5672
    ​
    [internal]
    #The IP address used for internal-cluster media spreading. Will use the IP got from the 'network_interface' item if 'ip_address' is not specified or equal to "".
    ip_address = "" #default: ""
    ​
    #The network interface used for internal-cluster media spreading. The first enumerated network interface in the system will be adopted if this item is not specified.
    # network_interface = "eth0" # default: undefined
    ​
    # The internal listening port range, only works for TCP now
    maxport = 0 #default: 0
    minport = 0 #default: 0
    ​
    #########################################################################################
    [webrtc]
    #The network inferface all peer-connections will be established through. All network interfaces in the system will be adopted if this item is not specified or specified with an empty array.
    ##Valid value is an array of objects that has two properties: name and replaced_ip_address. name is the name of network interface that will be used, replaced_ip_address is the IP address used for replacing the internal IP address in locally generated SDP's and ICE candidates during establishing the peer-connection(useful when behind NATs). replaced_ip_address is optional, if it is not specified, IP address from corresponding network interface will not be replaced.
    #Example of valid value: [{name = "eth1"}, {name = "eth2", replaced_ip_address = "192.0.2.2"}].
    network_interfaces = [{name="eth0",replaced_ip_address="192.168.100.210"}]  # default: []
    ​
    keystorePath = "./cert/certificate.pfx"
    #note, this won't work with all versions of libnice. With 0 all the available ports are used
    ​
    # The webrtc port range
    maxport = 0 #default: 0
    minport = 0 #default: 0
    ​
    #STUN server IP address and port to be used by the server.
    #if "" is used, the address is discovered locally
    stunport = 0 #default: 0
    stunserver = "" #default: ""
    ​
    #ThreadPool worker numbers for peer connection
    num_workers = 24 #default: 24

network_interfaces = [{name="eth0",replaced_ip_address="192.168.100.210"}]把里面的 replaced_ip_address 换成本机的ip地址或者公网ip地址。

name : 就用默认的 eth0 , 换别的好像会有问题

相关推荐
齐 飞11 分钟前
MongoDB笔记01-概念与安装
前端·数据库·笔记·后端·mongodb
LunarCod27 分钟前
WorkFlow源码剖析——Communicator之TCPServer(中)
后端·workflow·c/c++·网络框架·源码剖析·高性能高并发
码农派大星。1 小时前
Spring Boot 配置文件
java·spring boot·后端
杜杜的man2 小时前
【go从零单排】go中的结构体struct和method
开发语言·后端·golang
幼儿园老大*2 小时前
走进 Go 语言基础语法
开发语言·后端·学习·golang·go
llllinuuu2 小时前
Go语言结构体、方法与接口
开发语言·后端·golang
cookies_s_s2 小时前
Golang--协程和管道
开发语言·后端·golang
为什么这亚子2 小时前
九、Go语言快速入门之map
运维·开发语言·后端·算法·云原生·golang·云计算
想进大厂的小王2 小时前
项目架构介绍以及Spring cloud、redis、mq 等组件的基本认识
redis·分布式·后端·spring cloud·微服务·架构
customer082 小时前
【开源免费】基于SpringBoot+Vue.JS医院管理系统(JAVA毕业设计)
java·vue.js·spring boot·后端·spring cloud·开源·intellij-idea