From a8b53c24b1cc9e1bc8657ff1d6d15729e5cf76a5 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Fri, 5 Nov 2021 10:31:27 +0800 Subject: [PATCH] [TD-10863]: blm3 service on centos7 (#8565) --- packaging/check_package.sh | 3 ++- packaging/deb/DEBIAN/preinst | 4 ++++ packaging/deb/makedeb.sh | 3 +++ packaging/rpm/tdengine.spec | 12 ++++++++++-- packaging/tools/install.sh | 11 +++++++++-- packaging/tools/make_install.sh | 11 +++++++++-- packaging/tools/post.sh | 10 ++++++++-- packaging/tools/preun.sh | 9 +++++++++ packaging/tools/remove.sh | 2 ++ packaging/tools/startPre.sh | 1 - src/plugins/CMakeLists.txt | 1 + 11 files changed, 57 insertions(+), 10 deletions(-) diff --git a/packaging/check_package.sh b/packaging/check_package.sh index 5904aeb6f1..9728f9b964 100755 --- a/packaging/check_package.sh +++ b/packaging/check_package.sh @@ -179,7 +179,8 @@ function check_header_path() { function check_blm3_config_dir() { # check all config - check_file ${cfg_install_dir} blm3.toml + check_file ${cfg_install_dir} blm.toml + check_file ${cfg_install_dir} blm3.service check_file ${install_main_dir}/cfg blm.toml.org echo -e "Check conf path:\033[32mOK\033[0m!" } diff --git a/packaging/deb/DEBIAN/preinst b/packaging/deb/DEBIAN/preinst index 55218b4716..aaa052639b 100644 --- a/packaging/deb/DEBIAN/preinst +++ b/packaging/deb/DEBIAN/preinst @@ -32,5 +32,9 @@ if [ -f "${install_main_dir}/blm.toml" ]; then ${csudo} rm -f ${install_main_dir}/cfg/blm.toml || : fi +if [ -f "${install_main_dir}/blm3.service" ]; then + ${csudo} rm -f ${install_main_dir}/cfg/blm3.service || : +fi + # there can not libtaos.so*, otherwise ln -s error ${csudo} rm -f ${install_main_dir}/driver/libtaos* || : diff --git a/packaging/deb/makedeb.sh b/packaging/deb/makedeb.sh index 6e9cb00f65..cefdcdb1f1 100755 --- a/packaging/deb/makedeb.sh +++ b/packaging/deb/makedeb.sh @@ -47,6 +47,9 @@ cp ${compile_dir}/../packaging/cfg/taos.cfg ${pkg_dir}${install_home_pat if [ -f "${compile_dir}/test/cfg/blm.toml" ]; then cp ${compile_dir}/test/cfg/blm.toml ${pkg_dir}${install_home_path}/cfg fi +if [ -f "${compile_dir}/test/cfg/blm3.service" ]; then + cp ${compile_dir}/test/cfg/blm3.service ${pkg_dir}${install_home_path}/cfg ||: +fi cp ${compile_dir}/../packaging/deb/taosd ${pkg_dir}${install_home_path}/init.d cp ${compile_dir}/../packaging/tools/post.sh ${pkg_dir}${install_home_path}/script diff --git a/packaging/rpm/tdengine.spec b/packaging/rpm/tdengine.spec index d69eece30b..85aa7e0724 100644 --- a/packaging/rpm/tdengine.spec +++ b/packaging/rpm/tdengine.spec @@ -57,6 +57,9 @@ cp %{_compiledir}/../packaging/cfg/taos.cfg %{buildroot}%{homepath}/cfg if [ -f %{_compiledir}/test/cfg/blm.toml ]; then cp %{_compiledir}/test/cfg/blm.toml %{buildroot}%{homepath}/cfg fi +if [ -f %{_compiledir}/test/cfg/blm3.service ]; then + cp %{_compiledir}/test/cfg/blm3.service %{buildroot}%{homepath}/cfg +fi cp %{_compiledir}/../packaging/rpm/taosd %{buildroot}%{homepath}/init.d cp %{_compiledir}/../packaging/tools/post.sh %{buildroot}%{homepath}/script cp %{_compiledir}/../packaging/tools/preun.sh %{buildroot}%{homepath}/script @@ -153,16 +156,21 @@ if pidof taosd &> /dev/null; then echo "Stop taosd service success!" sleep 1 fi -# if taos.cfg already softlink, remove it +# if taos.cfg already exist, remove it if [ -f %{cfg_install_dir}/taos.cfg ]; then ${csudo} rm -f %{homepath}/cfg/taos.cfg || : fi -# if blm.toml already softlink, remove it +# if blm.toml already exist, remove it if [ -f %{cfg_install_dir}/blm.toml ]; then ${csudo} rm -f %{homepath}/cfg/blm.toml || : fi +# if blm3.service already softlink, remove it +if [ -f %{cfg_install_dir}/blm3.service ]; then + ${csudo} rm -f %{homepath}/cfg/blm3.service || : +fi + # there can not libtaos.so*, otherwise ln -s error ${csudo} rm -f %{homepath}/driver/libtaos* || : diff --git a/packaging/tools/install.sh b/packaging/tools/install.sh index 80bbad4bd9..33097bd541 100755 --- a/packaging/tools/install.sh +++ b/packaging/tools/install.sh @@ -679,8 +679,8 @@ function install_service_on_systemd() { taosd_service_config="${service_config_dir}/taosd.service" ${csudo} bash -c "echo '[Unit]' >> ${taosd_service_config}" ${csudo} bash -c "echo 'Description=TDengine server service' >> ${taosd_service_config}" - ${csudo} bash -c "echo 'After=network-online.target' >> ${taosd_service_config}" - ${csudo} bash -c "echo 'Wants=network-online.target' >> ${taosd_service_config}" + ${csudo} bash -c "echo 'After=network-online.target blm3.service' >> ${taosd_service_config}" + ${csudo} bash -c "echo 'Wants=network-online.target blm3.service' >> ${taosd_service_config}" ${csudo} bash -c "echo >> ${taosd_service_config}" ${csudo} bash -c "echo '[Service]' >> ${taosd_service_config}" ${csudo} bash -c "echo 'Type=simple' >> ${taosd_service_config}" @@ -756,6 +756,11 @@ function install_service_on_systemd() { fi } +function install_blm3_service() { + [ -f ${script_dir}/cfg/blm3.service ] &&\ + ${csudo} cp ${script_dir}/cfg/blm3.service ${service_config_dir}/ +} + function install_service() { if ((${service_mod}==0)); then install_service_on_systemd @@ -878,6 +883,7 @@ function update_TDengine() { if [ -z $1 ]; then install_bin install_service + install_blm3_service install_config install_blm3_config @@ -959,6 +965,7 @@ function install_TDengine() { # For installing new install_bin install_service + install_blm3_service openresty_work=false if [ "$verMode" == "cluster" ]; then diff --git a/packaging/tools/make_install.sh b/packaging/tools/make_install.sh index 96ba703cb3..c29c1cd665 100755 --- a/packaging/tools/make_install.sh +++ b/packaging/tools/make_install.sh @@ -503,8 +503,8 @@ function install_service_on_systemd() { ${csudo} bash -c "echo '[Unit]' >> ${taosd_service_config}" ${csudo} bash -c "echo 'Description=TDengine server service' >> ${taosd_service_config}" - ${csudo} bash -c "echo 'After=network-online.target' >> ${taosd_service_config}" - ${csudo} bash -c "echo 'Wants=network-online.target' >> ${taosd_service_config}" + ${csudo} bash -c "echo 'After=network-online.target blm3.service' >> ${taosd_service_config}" + ${csudo} bash -c "echo 'Wants=network-online.target blm3.service' >> ${taosd_service_config}" ${csudo} bash -c "echo >> ${taosd_service_config}" ${csudo} bash -c "echo '[Service]' >> ${taosd_service_config}" ${csudo} bash -c "echo 'Type=simple' >> ${taosd_service_config}" @@ -525,6 +525,11 @@ function install_service_on_systemd() { ${csudo} systemctl enable taosd } +function install_blm3_service() { + [ -f ${script_dir}/cfg/blm3.service ] &&\ + ${csudo} cp ${script_dir}/cfg/blm3.service ${service_config_dir}/ +} + function install_service() { if ((${service_mod}==0)); then install_service_on_systemd @@ -566,6 +571,7 @@ function update_TDengine() { if [ "$osType" != "Darwin" ]; then install_service + install_blm3_service fi install_config @@ -620,6 +626,7 @@ function install_TDengine() { if [ "$osType" != "Darwin" ]; then install_service + install_blm3_service fi install_config diff --git a/packaging/tools/post.sh b/packaging/tools/post.sh index 09d8559d34..418b9bd0f9 100755 --- a/packaging/tools/post.sh +++ b/packaging/tools/post.sh @@ -444,8 +444,8 @@ function install_service_on_systemd() { ${csudo} bash -c "echo '[Unit]' >> ${taosd_service_config}" ${csudo} bash -c "echo 'Description=TDengine server service' >> ${taosd_service_config}" - ${csudo} bash -c "echo 'After=network-online.target' >> ${taosd_service_config}" - ${csudo} bash -c "echo 'Wants=network-online.target' >> ${taosd_service_config}" + ${csudo} bash -c "echo 'After=network-online.target blm3.service' >> ${taosd_service_config}" + ${csudo} bash -c "echo 'Wants=network-online.target blm3.service' >> ${taosd_service_config}" ${csudo} bash -c "echo >> ${taosd_service_config}" ${csudo} bash -c "echo '[Service]' >> ${taosd_service_config}" ${csudo} bash -c "echo 'Type=simple' >> ${taosd_service_config}" @@ -466,6 +466,11 @@ function install_service_on_systemd() { ${csudo} systemctl enable taosd } +function install_blm3_service() { + [ -f ${script_dir}/cfg/blm3.service ] &&\ + ${csudo} cp ${script_dir}/cfg/blm3.service ${service_config_dir}/ +} + function install_service() { if ((${service_mod}==0)); then install_service_on_systemd @@ -497,6 +502,7 @@ function install_TDengine() { install_avro_lib install_bin install_service + install_blm3_service install_config install_blm3_config diff --git a/packaging/tools/preun.sh b/packaging/tools/preun.sh index 16a892d26c..7f6ef5c27d 100755 --- a/packaging/tools/preun.sh +++ b/packaging/tools/preun.sh @@ -58,6 +58,12 @@ function kill_taosd() { } function clean_service_on_systemd() { + blm3_service_config="${service_config_dir}/blm3.service" + if systemctl is-active --quiet blm3; then + echo "blm3 is running, stopping it..." + ${csudo} systemctl stop blm3 &> /dev/null || echo &> /dev/null + fi + taosd_service_config="${service_config_dir}/${taos_service_name}.service" if systemctl is-active --quiet ${taos_service_name}; then @@ -67,6 +73,9 @@ function clean_service_on_systemd() { ${csudo} systemctl disable ${taos_service_name} &> /dev/null || echo &> /dev/null ${csudo} rm -f ${taosd_service_config} + + [ -f ${blm3_service_config} ] && ${csudo} rm -f ${blm3_service_config} + } function clean_service_on_sysvinit() { diff --git a/packaging/tools/remove.sh b/packaging/tools/remove.sh index f4c3350b78..be5163c454 100755 --- a/packaging/tools/remove.sh +++ b/packaging/tools/remove.sh @@ -111,12 +111,14 @@ function clean_log() { function clean_service_on_systemd() { taosd_service_config="${service_config_dir}/${taos_service_name}.service" + blm3_service_config="${service_config_dir}/blm3.service" if systemctl is-active --quiet ${taos_service_name}; then echo "TDengine taosd is running, stopping it..." ${csudo} systemctl stop ${taos_service_name} &> /dev/null || echo &> /dev/null fi ${csudo} systemctl disable ${taos_service_name} &> /dev/null || echo &> /dev/null ${csudo} rm -f ${taosd_service_config} + [ -f ${blm3_service_config} ] && ${sudo} rm -f ${blm3_service_config} tarbitratord_service_config="${service_config_dir}/${tarbitrator_service_name}.service" if systemctl is-active --quiet ${tarbitrator_service_name}; then diff --git a/packaging/tools/startPre.sh b/packaging/tools/startPre.sh index 2f466f94f0..731f5b396f 100755 --- a/packaging/tools/startPre.sh +++ b/packaging/tools/startPre.sh @@ -48,4 +48,3 @@ if [ ${coreFlag} = "unlimited" ];then fi fi -/usr/bin/blm3 & diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index ec3863b815..66d15e48ed 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -45,6 +45,7 @@ ELSE () COMMAND cmake -E copy blm3 ${CMAKE_BINARY_DIR}/build/bin COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/test/cfg/ COMMAND cmake -E copy ./example/config/blm.toml ${CMAKE_BINARY_DIR}/test/cfg/ + COMMAND cmake -E copy ./blm3.service ${CMAKE_BINARY_DIR}/test/cfg/ ) ENDIF () -- GitLab