From 36d463f2f8aa71c5f182dd8ee3cc477251dbc594 Mon Sep 17 00:00:00 2001 From: huangtuq Date: Fri, 9 Dec 2022 19:32:16 +0800 Subject: [PATCH] redis rely on the deployment environment so we need compile the redis on the deployment environment Revert "compile redis 5.0.14 in package.sh" This reverts commit 77e154c5342dfab2b622640a01fb68686b8fef9f. --- package.sh | 78 ++++++------------- script/server/0_local_services/init.sh | 50 ++++++------ .../server/0_local_services/sysom-redis.ini | 8 -- tools/deploy/deploy.sh | 6 +- 4 files changed, 54 insertions(+), 88 deletions(-) delete mode 100644 script/server/0_local_services/sysom-redis.ini diff --git a/package.sh b/package.sh index eef7bfb9..2849d1d6 100644 --- a/package.sh +++ b/package.sh @@ -1,15 +1,4 @@ #!/bin/bash -OSS_URL=https://sysom.oss-cn-beijing.aliyuncs.com/redis -REDIS_DL_URL=https://download.redis.io/releases -RELEASE=sysomRelease-$(date +"%Y%m%d%H%M%S") -RELEASE_TARGET=${RELEASE}/server/target -RELEASE_REDIS=${RELEASE}/server/redis -SERVERDIR=sysom_server -WEBDIR=sysom_web -SCRIPTDIR=script -TOOLSDIR=tools -REDIS_DIR=redis-5.0.14 -REDIS_PKG=redis-5.0.14.tar.gz check_cmd() { local cmd="$1" @@ -23,48 +12,27 @@ green() { printf '\33[1;32m%b\n\33[0m' "$1" } -###you can ignore the action if the version of redis >= 5.0.0 in the deployment environment### -compile_redis() { - wget ${OSS_URL}/${REDIS_PKG} || wget ${REDIS_DL_URL}/${REDIS_PKG} - if [ ! -e ${REDIS_PKG} ] - then - echo "download ${REDIS_PKG} fail" - exit 1 - fi - tar -zxvf ${REDIS_PKG} - pushd ${REDIS_DIR} - make || exit 1 - popd - mkdir -p ${RELEASE_REDIS} - cp ${REDIS_DIR}/redis.conf ${RELEASE_REDIS}/ - cp ${REDIS_DIR}/src/redis-server ${RELEASE_REDIS}/ - rm -rf ${REDIS_DIR} ${REDIS_PKG} -} - -compile_sysom() { +check_cmd yarn +check_cmd tar - check_cmd yarn - check_cmd tar - - # build web - pushd sysom_web || exit - yarn - yarn build - popd || exit - - ###you can ignore the action if the version of redis >= 5.0.0 in the deployment environment### - compile_redis - - mkdir -p ${RELEASE_TARGET} - cp -r ${SERVERDIR}/ "${RELEASE_TARGET}"/ - cp -r ${TOOLSDIR}/ "${RELEASE}"/ - cp -r ${WEBDIR}/dist/ "${RELEASE_TARGET}"/${WEBDIR}/ - mkdir -p "${RELEASE_TARGET}"/${WEBDIR}/download/ - cp ${TOOLSDIR}/deploy/deploy.sh "${RELEASE}"/ - cp ${TOOLSDIR}/deploy/clear.sh "${RELEASE}"/ - cp -r ${SCRIPTDIR} "${RELEASE}"/ - tar czf "${RELEASE}".tar.gz "${RELEASE}"/ - rm -rf "${RELEASE}" - green "The release pacakge is ${RELEASE}.tar.gz" -} -compile_sysom +RELEASE=sysomRelease-$(date +"%Y%m%d%H%M%S") +SERVERDIR=sysom_server +WEBDIR=sysom_web +SCRIPTDIR=script +TOOLSDIR=tools +# build web +pushd sysom_web || exit +yarn +yarn build +popd || exit + +mkdir -p "${RELEASE}" +cp -r ${SERVERDIR}/ ${TOOLSDIR}/ "${RELEASE}"/ +cp -r ${WEBDIR}/dist/ "${RELEASE}"/${WEBDIR}/ +mkdir -p "${RELEASE}"/${WEBDIR}/download/ +cp ${TOOLSDIR}/deploy/deploy.sh "${RELEASE}"/ +cp ${TOOLSDIR}/deploy/clear.sh "${RELEASE}"/ +cp -r ${SCRIPTDIR} "${RELEASE}"/ +tar czf "${RELEASE}".tar.gz "${RELEASE}"/ +rm -rf "${RELEASE}" +green "The release pacakge is ${RELEASE}.tar.gz" diff --git a/script/server/0_local_services/init.sh b/script/server/0_local_services/init.sh index 6fd63695..62a1f97e 100755 --- a/script/server/0_local_services/init.sh +++ b/script/server/0_local_services/init.sh @@ -3,7 +3,11 @@ # ScriptName: start local service # Author: huangtuquan #***************************************************************# -SERVICE_NAME=sysom-redis +OSS_URL=https://sysom.oss-cn-beijing.aliyuncs.com/redis +REDIS_DL_URL=https://download.redis.io/releases +REDIS_DIR=redis-5.0.14 +REDIS_PKG=redis-5.0.14.tar.gz + usr_local_redis=0 setup_database() { @@ -28,37 +32,37 @@ setup_nginx() { sed -i "s;SERVER_PORT;${SERVER_PORT};g" /etc/nginx/conf.d/sysom.conf sed -i "s;/usr/local/sysom;${APP_HOME};g" /etc/nginx/conf.d/sysom.conf } - -init_conf() { - cp ${SERVICE_NAME}.ini /etc/supervisord.d/ - ###change the install dir base on param $1### - sed -i "s;/usr/local/sysom;${APP_HOME};g" /etc/supervisord.d/${SERVICE_NAME}.ini -} - setup_redis() { ###we need redis version >= 5.0.0, check redis version### redis_version=`yum list all | grep "^redis.x86_64" | awk '{print $2}' | awk -F"." '{print $1}'` echo ${redis_version} if [ $redis_version -lt 5 ] then - init_conf + echo "redis version in yum repo is less than 5.0.0, we will compile redis(5.0.14) and install it." + if [ ! -e ${REDIS_PKG} ] + then + wget ${OSS_URL}/${REDIS_PKG} || wget ${REDIS_DL_URL}/${REDIS_PKG} + if [ ! -e ${REDIS_PKG} ] + then + echo "download ${REDIS_PKG} fail" + exit 1 + fi + fi + echo "now uncompress ${REDIS_PKG}, then compile and install it." + tar -zxvf ${REDIS_PKG} + pushd ${REDIS_DIR} + make && make install + cp redis.conf /usr/local/bin/ + if [ $? -ne 0 ] + then + echo "redis compile or install error, exit 1" + exit 1 + fi usr_local_redis=1 + popd fi } -start_local_redis() { - ###if supervisor service started, we need use "supervisorctl update" to start new conf#### - supervisorctl update - supervisorctl status ${SERVICE_NAME} - if [ $? -eq 0 ] - then - echo "supervisorctl start ${SERVICE_NAME} success..." - return 0 - fi - echo "${SERVICE_NAME} service start fail, please check log" - exit 1 -} - start_app() { systemctl enable nginx.service systemctl restart nginx.service @@ -70,7 +74,7 @@ start_app() { then systemctl stop redis fi - start_local_redis + /usr/local/bin/redis-server /usr/local/bin/redis.conf & else systemctl enable redis.service systemctl restart redis.service diff --git a/script/server/0_local_services/sysom-redis.ini b/script/server/0_local_services/sysom-redis.ini deleted file mode 100644 index dcc775ee..00000000 --- a/script/server/0_local_services/sysom-redis.ini +++ /dev/null @@ -1,8 +0,0 @@ -[program:sysom-redis] -directory = /usr/local/sysom/server/redis -command=/usr/local/sysom/server/redis/redis-server /usr/local/sysom/server/redis/redis.conf -startsecs=3 -autostart=true -autorestart=true -stderr_logfile=/usr/local/sysom/server/logs/sysom-redis-error.log -stdout_logfile=/usr/local/sysom/server/logs/sysom-redis.log diff --git a/tools/deploy/deploy.sh b/tools/deploy/deploy.sh index 70829740..027b9a6e 100755 --- a/tools/deploy/deploy.sh +++ b/tools/deploy/deploy.sh @@ -7,7 +7,7 @@ # Function: deploy sysom #***************************************************************# APP_NAME="sysom" -SERVER_DIR="server" +SERVER_DIR="sysom_server" WEB_DIR="sysom_web" SCRIPT_DIR="script" APP_HOME=/usr/local/sysom @@ -55,9 +55,11 @@ update_target() { if [ -d "${TARGET_PATH}" ]; then rm -rf ${TARGET_PATH} fi + mkdir -p ${TARGET_PATH} echo "INFO: copy project file..." - cp -r ${SERVER_DIR}/* ${SERVER_HOME}/ + cp -r ${SERVER_DIR} ${WEB_DIR} ${TARGET_PATH} cp -r ${SCRIPT_DIR} ${APP_HOME}/init_scripts + cp tools/deploy/sysom-server.service /usr/lib/systemd/system/ } start_script_server() { -- Gitee