owt-server 服务开机自启
owt-server
服务需要进入镜像内部,执行startowt.sh
脚本进行启动。但如果服务器断电重启了,服务在业主地方。业主又是内网环境,启动服务就会很复杂。 这个时候 owt-server
开机自启就很重要了,官网并没有开机自启的方式。研究了一下可以实现,需要改一下 docker
启动方式。
目前只用到4.3 和 5.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.toml
和agent.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
, 换别的好像会有问题