diff --git a/README.md b/README.md
index 5c1f2534e..118e17db0 100755
--- a/README.md
+++ b/README.md
@@ -151,6 +151,7 @@ Please select according to languages:
### V3 changes
+* 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
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/scripts/install.sh b/trunk/scripts/install.sh
index faa35bffc..2d725d8a5 100755
--- a/trunk/scripts/install.sh
+++ b/trunk/scripts/install.sh
@@ -83,6 +83,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 +101,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 +128,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/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp
index fd2797f01..8ae0953a5 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 57
+#define VERSION_REVISION 58
// The macros generated by configure script.
#include
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