diff --git a/README.md b/README.md
index 198a6e369..694ccc6c2 100755
--- a/README.md
+++ b/README.md
@@ -3,7 +3,6 @@
[![](https://circleci.com/gh/ossrs/srs/tree/develop.svg?style=svg&circle-token=1ef1d5b5b0cde6c8c282ed856a18199f9e8f85a9)](https://circleci.com/gh/ossrs/srs/tree/develop)
[![](https://codecov.io/gh/ossrs/srs/branch/develop/graph/badge.svg)](https://codecov.io/gh/ossrs/srs/branch/develop)
[![](https://cloud.githubusercontent.com/assets/2777660/22814959/c51cbe72-ef92-11e6-81cc-32b657b285d5.png)](https://github.com/ossrs/srs/wiki/v1_CN_Contact#wechat)
-[
](https://github.com/ossrs/srs/wiki/v1_EN_Contact#skype-or-gitter)
SRS/3.0,[OuXuli][release3],是一个简单的流媒体直播集群,简单的快乐。
SRS is a simple live streaming cluster, a simple joy.
@@ -154,6 +153,10 @@ Please select according to languages:
### V3 changes
+* v3.0, 2019-10-06, Support log rotate by init.d command. 3.0.60
+* v3.0, 2019-10-06, We prefer ipv4, only use ipv6 if ipv4 is disabled. 3.0.59
+* v3.0, 2019-10-05, Support systemctl service for CentOS7. 3.0.58
+* v3.0, 2019-10-04, Disable SO_REUSEPORT if not supported. 3.0.57
* v3.0, 2019-10-04, [3.0 alpha0(3.0.56)][r3.0a0] released. 107946 lines.
* v3.0, 2019-10-04, Support go-oryx rtmplb with [proxy protocol](https://github.com/ossrs/go-oryx/wiki/RtmpProxy). 3.0.56
* v3.0, 2019-10-03, Fix [#775][bug #775], Support SO_REUSEPORT to improve edge performance. 3.0.54
diff --git a/trunk/conf/go-oryx-edge.conf b/trunk/conf/go-oryx-edge.conf
new file mode 100644
index 000000000..8b07031e0
--- /dev/null
+++ b/trunk/conf/go-oryx-edge.conf
@@ -0,0 +1,15 @@
+# the config for srs origin-edge cluster
+# @see https://github.com/ossrs/srs/wiki/v1_CN_Edge
+# @see full.conf for detail config.
+
+listen 19351;
+max_connections 1000;
+pid objs/edge1.pid;
+daemon off;
+srs_log_tank console;
+vhost __defaultVhost__ {
+ cluster {
+ mode remote;
+ origin 127.0.0.1:19350;
+ }
+}
diff --git a/trunk/conf/go-oryx-edge2.conf b/trunk/conf/go-oryx-edge2.conf
new file mode 100644
index 000000000..74ea54f01
--- /dev/null
+++ b/trunk/conf/go-oryx-edge2.conf
@@ -0,0 +1,15 @@
+# the config for srs origin-edge cluster
+# @see https://github.com/ossrs/srs/wiki/v1_CN_Edge
+# @see full.conf for detail config.
+
+listen 19352;
+max_connections 1000;
+pid objs/edge2.pid;
+daemon off;
+srs_log_tank console;
+vhost __defaultVhost__ {
+ cluster {
+ mode remote;
+ origin 127.0.0.1:19350;
+ }
+}
diff --git a/trunk/configure b/trunk/configure
index 301b997f5..e4f75de9b 100755
--- a/trunk/configure
+++ b/trunk/configure
@@ -484,22 +484,30 @@ install:
@mkdir -p \$(__REAL_INSTALL)
@echo "Now make the http root dir"
@mkdir -p \$(__REAL_INSTALL)/objs/nginx/html
- @cp research/api-server/static-dir/crossdomain.xml \$(__REAL_INSTALL)/objs/nginx/html
+ @cp -f research/api-server/static-dir/crossdomain.xml \$(__REAL_INSTALL)/objs/nginx/html
@echo "Now copy binary files"
@mkdir -p \$(__REAL_INSTALL)/objs
- @cp objs/srs \$(__REAL_INSTALL)/objs
+ @cp -f objs/srs \$(__REAL_INSTALL)/objs
@echo "Now copy srs conf files"
@mkdir -p \$(__REAL_INSTALL)/conf
- @cp conf/*.conf \$(__REAL_INSTALL)/conf
+ @cp -f conf/*.conf \$(__REAL_INSTALL)/conf
@echo "Now copy init.d script files"
@mkdir -p \$(__REAL_INSTALL)/etc/init.d
- @cp etc/init.d/srs \$(__REAL_INSTALL)/etc/init.d
+ @cp -f etc/init.d/srs \$(__REAL_INSTALL)/etc/init.d
@sed -i "s|^ROOT=.*|ROOT=\"\$(SRS_PREFIX)\"|g" \$(__REAL_INSTALL)/etc/init.d/srs
+ @echo "Now copy systemctl service files"
+ @mkdir -p \$(__REAL_INSTALL)/usr/lib/systemd/system
+ @cp -f usr/lib/systemd/system/srs.service \$(__REAL_INSTALL)/usr/lib/systemd/system/srs.service
@echo ""
- @echo "SRS is installed, to link and start srs:"
- @echo " sudo ln -sf \$(SRS_PREFIX)/etc/init.d/srs /etc/init.d/srs"
+ @echo "The api installed, to link and start srs, please"
+ @echo "For CentOS6:"
+ @echo " sudo ln -sf \$(SRS_PREFIX)/etc/init.d/srs /etc/init.d/srs &&"
@echo " /etc/init.d/srs start"
- @echo "@see: https://github.com/ossrs/srs/wiki/v1_CN_LinuxService"
+ @echo "For CentOS7:"
+ @echo " sudo ln -sf \$(SRS_PREFIX)/etc/init.d/srs /etc/init.d/srs &&"
+ @echo " sudo cp -f \$(SRS_PREFIX)/usr/lib/systemd/system/srs.service /usr/lib/systemd/system/srs.service && sudo systemctl daemon-reload && sudo systemctl enable srs &&"
+ @echo " sudo systemctl start srs"
+ @echo "@see: https://github.com/ossrs/srs/wiki/v3_CN_LinuxService"
END
fi
diff --git a/trunk/etc/init.d/srs b/trunk/etc/init.d/srs
index 2c0e92e71..7e749044d 100755
--- a/trunk/etc/init.d/srs
+++ b/trunk/etc/init.d/srs
@@ -166,6 +166,18 @@ reload() {
return 0
}
+logrotate() {
+ # not start, exit
+ load_process_info
+ if [[ 0 -ne $? ]]; then failed_msg "SRS not start."; return 0; fi
+
+ ok_msg "Reopen log file of SRS(pid ${srs_pid})..."
+ kill -s SIGUSR1 ${srs_pid}
+
+ ok_msg "Log rotated"
+ return 0
+}
+
menu() {
case "$1" in
start)
@@ -184,8 +196,13 @@ menu() {
reload)
reload
;;
+ rotate)
+ logrotate
+ ;;
*)
- echo "Usage: $0 {start|stop|status|restart|reload}"
+ echo "Usage: $0 {start|stop|status|restart|reload|rotate}"
+ echo " reload Apply log file by not restarting SRS"
+ echo " rotate For log rotate, to send SIGUSR1 to SRS to reopen the log file."
return 1
;;
esac
diff --git a/trunk/scripts/install.sh b/trunk/scripts/install.sh
index faa35bffc..3a1c6292a 100755
--- a/trunk/scripts/install.sh
+++ b/trunk/scripts/install.sh
@@ -69,6 +69,7 @@ ok_msg "copy core components"
mkdir -p $install_root
cp -r $work_dir/${INSTALL}/conf $install_root &&
cp -r $work_dir/${INSTALL}/etc $install_root &&
+ cp -r $work_dir/${INSTALL}/usr $install_root &&
cp -r $work_dir/${INSTALL}/objs $install_root
) >>$log 2>&1
ret=$?; if [[ 0 -ne ${ret} ]]; then failed_msg "copy core components failed"; exit $ret; fi
@@ -83,6 +84,17 @@ ok_msg "install init.d scripts"
ret=$?; if [[ 0 -ne ${ret} ]]; then failed_msg "install init.d scripts failed"; exit $ret; fi
ok_msg "install init.d scripts success"
+# For systemctl
+if [[ -d /usr/lib/systemd/system ]]; then
+ ok_msg "install srs.service for systemctl"
+ (
+ cp -f $install_root/usr/lib/systemd/system/srs.service /usr/lib/systemd/system/srs.service &&
+ systemctl daemon-reload
+ ) >>$log 2>&1
+ ret=$?; if [[ 0 -ne ${ret} ]]; then failed_msg "install srs.service for systemctl failed"; exit $ret; fi
+ ok_msg "install srs.service for systemctl success"
+fi
+
# install system service
lsb_release --id|grep "CentOS" >/dev/null 2>&1; os_id_centos=$?
lsb_release --id|grep "Ubuntu" >/dev/null 2>&1; os_id_ubuntu=$?
@@ -90,7 +102,11 @@ lsb_release --id|grep "Debian" >/dev/null 2>&1; os_id_debian=$?
lsb_release --id|grep "Raspbian" >/dev/null 2>&1; os_id_rasabian=$?
if [[ 0 -eq $os_id_centos ]]; then
ok_msg "install system service for CentOS"
- /sbin/chkconfig --add srs && /sbin/chkconfig srs on
+ if [[ -d /usr/lib/systemd/system ]]; then
+ systemctl enable srs
+ else
+ /sbin/chkconfig --add srs && /sbin/chkconfig srs on
+ fi
ret=$?; if [[ 0 -ne ${ret} ]]; then failed_msg "install system service failed"; exit $ret; fi
ok_msg "install system service success"
elif [[ 0 -eq $os_id_ubuntu ]]; then
@@ -113,9 +129,11 @@ else
fi
echo ""
-echo "see: https://github.com/ossrs/srs/wiki/v1_CN_LinuxService"
-echo "install success, you can:"
+echo "see: https://github.com/ossrs/srs/wiki/v3_CN_LinuxService"
+echo "install success, you can start SRS on CentOS6:"
echo -e "${GREEN} sudo /etc/init.d/srs start${BLACK}"
+echo "or CentOS7:"
+echo -e "${GREEN} sudo systemctl start srs${BLACK}"
echo "srs root is ${INSTALL}"
exit 0
diff --git a/trunk/scripts/package.sh b/trunk/scripts/package.sh
index c72624fb1..6629bbf6e 100755
--- a/trunk/scripts/package.sh
+++ b/trunk/scripts/package.sh
@@ -87,7 +87,9 @@ ret=$?; if [[ $ret -ne 0 ]]; then
failed_msg "lsb_release not found. "
failed_msg "to install on centos/debian(ubuntu/respberry-pi):";
failed_msg " sudo yum install -y lsb-release";
- failed_msg " sudo aptitude install -y lsb-release";
+ failed_msg " sudo aptitude install -y lsb-release";
+ failed_msg "or centos7:"
+ failed_msg " sudo yum install -y redhat-lsb"
exit $ret;
fi
diff --git a/trunk/scripts/unstall.sh b/trunk/scripts/unstall.sh
new file mode 100755
index 000000000..d65809bb7
--- /dev/null
+++ b/trunk/scripts/unstall.sh
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+if [[ -d /usr/lib/systemd/system ]]; then
+ systemctl disable srs
+ systemctl stop srs
+ rm -f /usr/lib/systemd/system/srs.service
+ rm -f /etc/init.d/srs
+else
+ /sbin/chkconfig srs off
+ /sbin/chkconfig --del srs
+ /etc/init.d/srs stop
+ rm -f /etc/init.d/srs
+fi
+rm -rf /usr/local/srs
+echo "SRS uninstalled"
diff --git a/trunk/src/app/srs_app_rtsp.cpp b/trunk/src/app/srs_app_rtsp.cpp
index 35fffa620..b96b2190e 100644
--- a/trunk/src/app/srs_app_rtsp.cpp
+++ b/trunk/src/app/srs_app_rtsp.cpp
@@ -52,7 +52,7 @@ SrsRtpConn::SrsRtpConn(SrsRtspConn* r, int p, int sid)
_port = p;
stream_id = sid;
// TODO: support listen at <[ip:]port>
- listener = new SrsUdpListener(this, srs_any_address4listener(), p);
+ listener = new SrsUdpListener(this, srs_any_address_for_listener(), p);
cache = new SrsRtpPacket();
pprint = SrsPithyPrint::create_caster();
}
diff --git a/trunk/src/app/srs_app_server.cpp b/trunk/src/app/srs_app_server.cpp
index 1901da4db..33f571d32 100644
--- a/trunk/src/app/srs_app_server.cpp
+++ b/trunk/src/app/srs_app_server.cpp
@@ -1017,9 +1017,8 @@ srs_error_t SrsServer::listen_rtmp()
for (int i = 0; i < (int)ip_ports.size(); i++) {
SrsListener* listener = new SrsBufferListener(this, SrsListenerRtmpStream);
listeners.push_back(listener);
-
- std::string ip;
- int port;
+
+ int port; string ip;
srs_parse_endpoint(ip_ports[i], ip, port);
if ((err = listener->listen(ip, port)) != srs_success) {
@@ -1113,7 +1112,7 @@ srs_error_t SrsServer::listen_stream_caster()
}
// TODO: support listen at <[ip:]port>
- if ((err = listener->listen(srs_any_address4listener(), port)) != srs_success) {
+ if ((err = listener->listen(srs_any_address_for_listener(), port)) != srs_success) {
return srs_error_wrap(err, "listen at %d", port);
}
}
diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp
index 5f020c54b..3dd549262 100644
--- a/trunk/src/core/srs_core.hpp
+++ b/trunk/src/core/srs_core.hpp
@@ -27,7 +27,7 @@
// The version config.
#define VERSION_MAJOR 3
#define VERSION_MINOR 0
-#define VERSION_REVISION 56
+#define VERSION_REVISION 60
// The macros generated by configure script.
#include
diff --git a/trunk/src/kernel/srs_kernel_utility.cpp b/trunk/src/kernel/srs_kernel_utility.cpp
index d0f19d86c..93ea6a895 100644
--- a/trunk/src/kernel/srs_kernel_utility.cpp
+++ b/trunk/src/kernel/srs_kernel_utility.cpp
@@ -210,18 +210,29 @@ void srs_parse_hostport(const string& hostport, string& host, int& port)
}
}
-string srs_any_address4listener()
+string srs_any_address_for_listener()
{
- int fd = socket(AF_INET6, SOCK_DGRAM, 0);
-
- // socket()
- // A -1 is returned if an error occurs, otherwise the return value is a
- // descriptor referencing the socket.
- if(fd != -1) {
- close(fd);
+ bool ipv4_active = false;
+ bool ipv6_active = false;
+
+ if (true) {
+ int fd = socket(AF_INET, SOCK_DGRAM, 0);
+ if(fd != -1) {
+ ipv4_active = true;
+ close(fd);
+ }
+ }
+ if (true) {
+ int fd = socket(AF_INET6, SOCK_DGRAM, 0);
+ if(fd != -1) {
+ ipv6_active = true;
+ close(fd);
+ }
+ }
+
+ if (ipv6_active && !ipv4_active) {
return "::";
}
-
return "0.0.0.0";
}
@@ -240,7 +251,7 @@ void srs_parse_endpoint(string hostport, string& ip, int& port)
const string sport = hostport.substr(pos + 1);
port = ::atoi(sport.c_str());
} else {
- ip = srs_any_address4listener();
+ ip = srs_any_address_for_listener();
port = ::atoi(hostport.c_str());
}
}
diff --git a/trunk/src/kernel/srs_kernel_utility.hpp b/trunk/src/kernel/srs_kernel_utility.hpp
index 99a3fdc6a..3b55a520f 100644
--- a/trunk/src/kernel/srs_kernel_utility.hpp
+++ b/trunk/src/kernel/srs_kernel_utility.hpp
@@ -48,7 +48,8 @@ extern srs_utime_t srs_get_system_startup_time();
extern srs_utime_t srs_update_system_time();
// The "ANY" address to listen, it's "0.0.0.0" for ipv4, and "::" for ipv6.
-extern std::string srs_any_address4listener();
+// @remark We prefer ipv4, only use ipv6 if ipv4 is disabled.
+extern std::string srs_any_address_for_listener();
// The dns resolve utility, return the resolved ip address.
extern std::string srs_dns_resolve(std::string host, int& family);
diff --git a/trunk/src/service/srs_service_st.cpp b/trunk/src/service/srs_service_st.cpp
index e4ffe2669..1f6d2266c 100644
--- a/trunk/src/service/srs_service_st.cpp
+++ b/trunk/src/service/srs_service_st.cpp
@@ -112,10 +112,15 @@ srs_error_t srs_fd_reuseaddr(int fd)
srs_error_t srs_fd_reuseport(int fd)
{
+#if defined(SO_REUSEPORT)
int v = 1;
if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &v, sizeof(int)) == -1) {
return srs_error_new(ERROR_SOCKET_SETREUSEADDR, "SO_REUSEPORT fd=%v", fd);
}
+#else
+ #warning "SO_REUSEPORT is not supported by your OS"
+ srs_warn("SO_REUSEPORT is not supported util Linux kernel 3.9");
+#endif
return srs_success;
}
diff --git a/trunk/src/utest/srs_utest_kernel.cpp b/trunk/src/utest/srs_utest_kernel.cpp
index 2e4e0960c..7f0479ddb 100644
--- a/trunk/src/utest/srs_utest_kernel.cpp
+++ b/trunk/src/utest/srs_utest_kernel.cpp
@@ -4086,7 +4086,7 @@ VOID TEST(KernelUtilityTest, CoverTimeUtilityAll)
}
if (true) {
- string ep = srs_any_address4listener();
+ string ep = srs_any_address_for_listener();
EXPECT_TRUE(ep == "0.0.0.0" || ep == "::");
}
diff --git a/trunk/usr/lib/systemd/system/srs.service b/trunk/usr/lib/systemd/system/srs.service
new file mode 100644
index 000000000..b76bc930a
--- /dev/null
+++ b/trunk/usr/lib/systemd/system/srs.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=The SRS Media Stream Cluster
+After=network.target
+
+[Service]
+Type=forking
+ExecStart=/etc/init.d/srs start
+ExecReload=/etc/init.d/srs reload
+ExecStop=/etc/init.d/srs stop
+
+[Install]
+WantedBy=multi-user.target