Heim > Backend-Entwicklung > PHP-Tutorial > php代码上线,实现版本切换

php代码上线,实现版本切换

WBOY
Freigeben: 2016-06-23 13:27:21
Original
1222 Leute haben es durchsucht

以下为现有php业务,代码上线方式。实现:4套环境版本切换。

[root@hz-web-01 htdocs]# cat release.sh#!/usr/bin/env bash work_dir=/mnt/var/www/htdocsrelease_dir=/var/www/htdocs # app environmentapp_env=$1# build release file pathbuild_file_path=$2 help() {   echo   echo usage: ${0##*/} [app_env] [build_file_path]   echo example: ${0##*/} int lvanclub_int_build_20150731_170557.tar.gz   echo   exit 0} # check the app_env variable valuecase ${app_env} in   dev)       echo "ECHO: don't support dev environment present"       help       exit 1       ;;   int)       user=apache       group=apache       ;;   sandbox)       user=apache       group=apache       ;;   live)       user=php-fpm       group=php-fpm       ;;   *)       echo "ERROR: invalid app_env value, should be dev, int, sandbox orlive!"       help       exit 1       ;;esac # check the build_file_path variable valueif [ -z ${build_file_path} ]then   echo "ERROR: please specify the build file path"   help   exit 1elif [ ! -f ${build_file_path} ]then   echo "ERROR: specified build file '${build_file_path}' is notfound"   help   exit 1fi # reference: linux shell 字符串操作(长度,查找,替换)详解 - http://www.cnblogs.com/chengmo/archive/2010/10/02/1841355.html# only keep the build folder namebuild_file_name=${build_file_path##*/}build_name=${build_file_name%.tar.gz}# if current build folder exists, justremove itrm ${work_dir}/${build_name} -rvftar xzvf ${build_file_path}--directory=${work_dir}/ # make soft link for cpserver projectcd ${work_dir}/${build_name}/sdkserver/webln -s ../../cpserver cpserver # copy log filescd ${work_dir}# appstorecp${release_dir}/${app_env}/appstore/apps/api/var/logs ${work_dir}/${build_name}/appstore/apps/api/var/-rvf# appstore dashboardcp${release_dir}/${app_env}/appstore/apps/dashboard/var/logs${work_dir}/${build_name}/appstore/apps/dashboard/var/ -rvf# sdkservercp${release_dir}/${app_env}/sdkserver/protected/logs${work_dir}/${build_name}/sdkserver/protected/ -rvfcp${release_dir}/${app_env}/sdkserver/protected/runtime${work_dir}/${build_name}/sdkserver/protected/ -rvf# cpservercp ${release_dir}/${app_env}/cpserver/logs${work_dir}/${build_name}/cpserver/ -rvf # change file owners and permissionschown ${user}:${group}${work_dir}/${build_name} -Rchmod 775 ${work_dir}/${build_name} -R # make build as current releaserm ${release_dir}/${app_env} -vfln -s ${work_dir}/${build_name}${release_dir}/${app_env} # restart php-fpm serviceservice php-fpm restart
Nach dem Login kopieren


以上脚本内容较少,没有注释。下面进行解读   

采用这种方式的原因:阿里云平台,挂载磁盘被分配在/mnt目录下


实际目录:/mnt/var/www/htdocs

软连接目录:/var/www/htdocs

正如help所说  dev 环境   int环境   sandbox环境  live环境   四套环境的版本切换。live环境为线上正式环境。


我已将思路共享,希望大家能给出改良方案!


#2015-08-26      以下为每次代码上线的实施文档

#此文档为暂时文档,后期部署jenkins 更换

#1 检查tar.gz文件里面一级菜单内容

#2 回滚操作:

# 根据第三步,选择近期升级版本。


第一步:

把要升级的软件包,传送至服务器:hz-bf-01

代码存放位置:/mnt/word

第二布:

分发软件包到相应的服务器

sh /mnt/shell/fenfa.sh /mnt/word/lvanclub_live_build_20150826_111450.tar.gz /mnt/var/www/htdocs

第三步:

执行ansiable:

ansible -i ./hosts  web -m command -a "sh /mnt/var/www/htdocs/release.sh live /mnt/var/www/htdocs/lvanclub_live_build_20150827_153156.tar.gz"



Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage