Uninote
Uninote

pre环境发布

  • 更新脚本
#!/bin/bash
cd `dirname $0`
currentPath=`pwd`
cd /home/www/dajx-api
git fetch --all
git checkout sprint9
git pull
cd /home/www
git clone git@git.dajxyl.com:hcg/shop.git
chown -R www.www *
mysql -u root -proot <<ENDTAG
use dajx-api;
source /home/www/dajx-api/documents/hcg_update.sql;
create database shop;
use shop;
source /home/www/shop/ducument/迭代9sql初始化文件/shop.sql;
ENDTAG
mysql -uroot -proot -e 'use shop;INSERT INTO `admin` (`username`,`password`,`nickname`,`creator_id`,`status`,`role_id`) VALUES ("admin","$2y$10$IwxpRqDFc1ZCtAAznYXYx.raox/u/Km8h3jzLpUYEwjCRmfO.7hB2","超级管理员",0,1,0)'
mysql -uroot -proot -e 'grant all privileges on *.* to reader@"%";flush privileges;use biglove;update admin set password="203aeace9b9ed0b1a79ae1641d556b29" where id=1;'
echo -e '# create by hcg 2020-12-26 \n*/10 * * * * curl https://pre.api.dajxyl.com/shop-order/auto-cancel-order > /dev/null 2>&1 \n# create by lixun \n*/10 * * * * curl https://pre.s.dajxyl.com/promotion/setEnd >/dev/null 2>&1 \n*/10 * * * * curl https://pre.s.dajxyl.com/order/setConfirm >/dev/null 2>&1 ' >> /etc/crontab
service crond restart
cd $currentPath
tar xf letsencrypt.pre.tar.gz -C /etc/
dajx_api_host=pre.api.dajxyl.com
dajx_staff_api_host=pre.staffapi.dajxyl.com
dajx_cms_host=pre.admin.dajxyl.com
dajx_www_host=pre.www.dajxyl.com
front_host=$dajx_api_host
gt_api=dajx_api_pre_
gt_staffapi=dajx_staff_api_pre_
        sed -i "s#https://staffapi.dajxyl.com#https://$dajx_staff_api_host#" /home/www/additional_item/logviewer/logs.php
        sed -i "s#https://api.dajxyl.com#https://$dajx_api_host#" /home/www/additional_item/logviewer/logs.php
        sed -i "s#https://api.dajxyl.com#https://$dajx_api_host#g" /home/www/biglove-cms/cms/config/__params.php
        sed -i "s#https://staffapi.dajxyl.com#https://$dajx_staff_api_host#g" /home/www/biglove-cms/cms/config/__params.php
        sed -i "s#dajx_api_#$gt_api#g" /home/www/biglove-cms/cms/config/__params.php
        sed -i "s#dajx_staff_#$gt_staffapi#g" /home/www/biglove-cms/cms/config/__params.php
        sed -i "s#/live/admin.dajxyl.com#/live/$dajx_cms_host#" /home/www/biglove-workerman/Config/__config.php
        sed -i "s#dajx_staff_api_#$gt_staffapi#" /home/www/biglove-workerman/Config/__config.php
        sed -i "s#dajx_api_#$gt_api#" /home/www/biglove-workerman/Config/__config.php
        sed -i "s#staffapi.dajxyl.com#$dajx_staff_api_host#g" /home/www/dajx-staff-api/config/__params.php
        sed -i "s#dajx_staff_api_#$gt_staffapi#g" /home/www/dajx-staff-api/config/__params.php
        sed -i "s#dajx_api_#$gt_api#g" /home/www/dajx-staff-api/config/__params.php
        sed -i "s#https://www.dajxyl.com/#https://$dajx_www_host/#" /home/www/dajx-api/config/__params.php
        sed -i "s#dajx_staff_api_#$gt_staffapi#g" /home/www/dajx-api/config/__params.php
        sed -i "s#dajx_staff_#$gt_staffapi#g" /home/www/dajx-api/config/__params.php
        sed -i "s#https://api.dajxyl.com#https://$dajx_api_host#g" /home/www/dajx-api/config/__params.php
        sed -i "s#live/api.dajxyl.com#live/$dajx_api_host#g" /usr/local/nginx/conf/vhost/dajx_api_ssl.conf
        sed -i "s#server_name api.dajxyl.com#server_name $dajx_api_host#g" /usr/local/nginx/conf/vhost/dajx_api_ssl.conf
        sed -i "s#server_name admin.dajxyl.com#server_name $dajx_cms_host#g" /usr/local/nginx/conf/vhost/dajx_cms_ssl.conf
        sed -i "s#live/admin.dajxyl.com#live/$dajx_cms_host#g" /usr/local/nginx/conf/vhost/dajx_cms_ssl.conf
        sed -i "s#server_name staffapi.dajxyl.com#server_name $dajx_staff_api_host#g" /usr/local/nginx/conf/vhost/dajx_staff_api_ssl.conf
        sed -i "s#live/staffapi.dajxyl.com#live/$dajx_staff_api_host#g" /usr/local/nginx/conf/vhost/dajx_staff_api_ssl.conf
        sed -i "s#server_name www.dajxyl.com#server_name $dajx_www_host#g" /usr/local/nginx/conf/vhost/dajx_www_ssl.conf
        sed -i "s#live/www.dajxyl.com#live/$dajx_www_host#g" /usr/local/nginx/conf/vhost/dajx_www_ssl.conf
        sed -i "s#https://www.dajxyl.com#https://$dajx_www_host#g" /usr/local/nginx/conf/vhost/dajx_www_ssl.conf
        nginx -s reload
# test2 config dump to git
[ ! -d /server/scripts ] && mkdir -p /server/scripts
cd /server/scripts && rm -rf ./*
git clone git@git.dajxyl.com:dajx/prj-utils.git . && rm -rf .git
bash dumpconfig.sh pre root
  • 配置supervisor守护进程
#!/bin/bash
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos6_base.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.cloud.tencent.com/repo/epel-6.repo

yum -y install supervisord

cat > /etc/supervisord.conf <<EOF
[supervisord]
http_port=/var/tmp/supervisor.sock ; (default is to run a UNIX domain socket server)
;http_port=127.0.0.1:9001  ; (alternately, ip_address:port specifies AF_INET)
;sockchmod=0700              ; AF_UNIX socketmode (AF_INET ignore, default 0700)
;sockchown=nobody.nogroup     ; AF_UNIX socket uid.gid owner (AF_INET ignores)
;umask=022                   ; (process file creation umask;default 022)
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB       ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10          ; (num of main logfile rotation backups;default 10)
loglevel=info               ; (logging level;default info; others: debug,warn)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false              ; (start in foreground if true;default false)
minfds=1024                 ; (min. avail startup file descriptors;default 1024)
minprocs=200                ; (min. avail process descriptors;default 200)

;nocleanup=true              ; (don't clean up tempfiles at start;default false)
;http_username=user          ; (default is no username (open system))
;http_password=123           ; (default is no password (open system))
;childlogdir=/tmp            ; ('AUTO' child log dir, default $TEMP)
;user=chrism                 ; (default is current user, required if root)
;directory=/tmp              ; (default is not to cd during start)
;environment=KEY=value       ; (key value pairs to add to environment)

[supervisorctl]
serverurl=unix:///var/tmp/supervisor.sock ; use a unix:// URL  for a unix socket
;serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket
;username=chris              ; should be same as http_username if set
;password=123                ; should be same as http_password if set
;prompt=mysupervisor         ; cmd line prompt (default "supervisor")
[program:queue]
directory=/home/www/dajx-api
command=/usr/local/php/bin/php /home/www/dajx-api/yii queue/listen
;priority=999                ; the relative start priority (default 999)
autostart=true              ; start at supervisord start (default: true)
;autorestart=true            ; retstart at unexpected quit (default: true)
;startsecs=10                ; number of secs prog must stay running (def. 10)
;startretries=3              ; max # of serial start failures (default 3)
;exitcodes=0,2               ; 'expected' exit codes for process (default 0,2)
;stopsignal=QUIT             ; signal used to kill process (default TERM)
;stopwaitsecs=10             ; max num secs to wait before SIGKILL (default 10)
user=www                 ; setuid to this UNIX account to run the program
log_stdout=true             ; if true, log program stdout (default true)
log_stderr=true             ; if true, log program stderr (def false)
logfile=/home/wwwlogs/queue.log   ; child log path, use NONE for none; default AUTO
logfile_maxbytes=1MB        ; max # logfile bytes b4 rotation (default 50MB)
;logfile_backups=10          ; # of logfile backups (default 10)

[program:shopqueue]
user=www
directory=/home/www/shop
command=/usr/local/php/bin/php /home/www/shop/think queue:work --queue ShopQueue
autostart=true
autorestart=false
log_stdout=true             ; if true, log program stdout (default true)
log_stderr=true
stderr_logfile=/tmp/shop_queue_stderr.log
stdout_logfile=/tmp/shop_queue_stdout.log
EOF
chown www.www -R /var/log/supervisor
chown www.www -R /home/wwwlogs/
service superviord start

#nginx 配置shop和api
cat > /usr/local/nginx/conf/vhost/dajx_s_ssl.conf <<EOF
server {
    #listen 443 ssl;
    listen 80;
    #if ($scheme = http){
    #    return 301 https://$host$request_uri;
    #}
    server_name pre.s.dajxyl.com;
    #ssl_trusted_certificate     /etc/letsencrypt/live/s.dajxyl.com/fullchain.pem;
    #ssl_certificate             /etc/letsencrypt/live/s.dajxyl.com/fullchain.pem;
    #ssl_certificate_key         /etc/letsencrypt/live/s.dajxyl.com/privkey.pem;
    #ssl_session_timeout 5m;
    #ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
    #ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    #ssl_prefer_server_ciphers on;

    #ssl_stapling on;
    #ssl_stapling_verify on;

    #resolver 8.8.8.8 8.8.4.4 valid=600s;
    #resolver_timeout 6s;

    access_log  /home/wwwlogs/dajx_s_access.log main;
    error_log   /home/wwwlogs/dajx_s_error.log;
    set         $root   /home/www/shop/public;
    # 商城后台前端页面路径
    set         $rootweb /home/www/shop-web;
    location /shop-web {
        alias $rootweb;
        index index.html index.htm;
    }
    location / {
        root    $root;
        index   index.html index.php;
        if ( !-e $request_filename) {
            rewrite ^(.*)$ /index.php/$1 last;
            break;
        }
    }
    location ~ .+\.php($|/) {
        fastcgi_pass    127.0.0.1:9000;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_param   PATH_INFO          $fastcgi_path_info;
        fastcgi_param   PATH_TRANSLATED    $document_root$fastcgi_path_info;
        fastcgi_param   SCRIPT_FILENAME    $root$fastcgi_script_name;
        include         fastcgi_params;
    }
}
EOF

onlie 更新

#!/bin/bash
cd `dirname $0`
currentPath=`pwd`
cd /home/www/dajx-api
git fetch --all
git checkout sprint9
git pull
cd /home/www
git clone git@git.dajxyl.com:hcg/shop.git
chown -R www.www *
mysql -u root -proot <<ENDTAG
use dajx-api;
source /home/www/dajx-api/documents/hcg_update.sql;
create database shop;
use shop;
source /home/www/shop/ducument/迭代9sql初始化文件/shop.sql;
ENDTAG
mysql -uroot -proot -e 'use shop;INSERT INTO `admin` (`username`,`password`,`nickname`,`creator_id`,`status`,`role_id`) VALUES ("admin","$2y$10$IwxpRqDFc1ZCtAAznYXYx.raox/u/Km8h3jzLpUYEwjCRmfO.7hB2","超级管理员",0,1,0)'
echo -e '# create by hcg 2020-12-26 \n*/10 * * * * root curl  https://api.dajxyl.com/shop-order/auto-cancel-order > /dev/null 2>&1 \n# create by lixun \n*/10 * * * * root curl  https://s.dajxyl.com/promotion/setEnd >/dev/null 2>&1 \n*/10 * * * * root curl  https://s.dajxyl.com/order/setConfirm >/dev/null 2>&1 ' >> /etc/crontab
service crond restart
# test2 config dump to git
[ ! -d /server/scripts ] && mkdir -p /server/scripts
cd /server/scripts && rm -rf ./*
git clone git@git.dajxyl.com:dajx/prj-utils.git . && rm -rf .git
bash dumpconfig.sh online root
  • 配置supervisor守护进程
#!/bin/bash
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos6_base.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.cloud.tencent.com/repo/epel-6.repo

yum -y install supervisord

cat > /etc/supervisord.conf <<EOF
[supervisord]
http_port=/var/tmp/supervisor.sock ; (default is to run a UNIX domain socket server)
;http_port=127.0.0.1:9001  ; (alternately, ip_address:port specifies AF_INET)
;sockchmod=0700              ; AF_UNIX socketmode (AF_INET ignore, default 0700)
;sockchown=nobody.nogroup     ; AF_UNIX socket uid.gid owner (AF_INET ignores)
;umask=022                   ; (process file creation umask;default 022)
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB       ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10          ; (num of main logfile rotation backups;default 10)
loglevel=info               ; (logging level;default info; others: debug,warn)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false              ; (start in foreground if true;default false)
minfds=1024                 ; (min. avail startup file descriptors;default 1024)
minprocs=200                ; (min. avail process descriptors;default 200)

;nocleanup=true              ; (don't clean up tempfiles at start;default false)
;http_username=user          ; (default is no username (open system))
;http_password=123           ; (default is no password (open system))
;childlogdir=/tmp            ; ('AUTO' child log dir, default $TEMP)
;user=chrism                 ; (default is current user, required if root)
;directory=/tmp              ; (default is not to cd during start)
;environment=KEY=value       ; (key value pairs to add to environment)

[supervisorctl]
serverurl=unix:///var/tmp/supervisor.sock ; use a unix:// URL  for a unix socket
;serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket
;username=chris              ; should be same as http_username if set
;password=123                ; should be same as http_password if set
;prompt=mysupervisor         ; cmd line prompt (default "supervisor")
[program:queue]
directory=/home/www/dajx-api
command=/usr/local/php/bin/php /home/www/dajx-api/yii queue/listen
;priority=999                ; the relative start priority (default 999)
autostart=true              ; start at supervisord start (default: true)
;autorestart=true            ; retstart at unexpected quit (default: true)
;startsecs=10                ; number of secs prog must stay running (def. 10)
;startretries=3              ; max # of serial start failures (default 3)
;exitcodes=0,2               ; 'expected' exit codes for process (default 0,2)
;stopsignal=QUIT             ; signal used to kill process (default TERM)
;stopwaitsecs=10             ; max num secs to wait before SIGKILL (default 10)
user=www                 ; setuid to this UNIX account to run the program
log_stdout=true             ; if true, log program stdout (default true)
log_stderr=true             ; if true, log program stderr (def false)
stderr_logfile=/home/wwwlogs/queue_stderr.log
stdout_logfile=/home/wwwlogs/queue_stdout.log
logfile_maxbytes=1MB        ; max # logfile bytes b4 rotation (default 50MB)
;logfile_backups=10          ; # of logfile backups (default 10)

[program:shopqueue]
user=www
directory=/home/www/shop
command=/usr/local/php/bin/php /home/www/shop/think queue:listen --queue ShopQueue
autostart=true
autorestart=false
log_stdout=true             ; if true, log program stdout (default true)
log_stderr=true
stderr_logfile=/home/wwwlogs/shop_queue_stderr.log
stdout_logfile=/home/wwwlogs/shop_queue_stdout.log
EOF
chown www.www -R /var/log/supervisor
chown www.www -R /home/wwwlogs/
service superviord start

#nginx 配置shop和api
cat > /usr/local/nginx/conf/vhost/dajx_s_ssl.conf <<EOF
server {
    #listen 443 ssl;
    listen 80;
    #if ($scheme = http){
    #    return 301 https://$host$request_uri;
    #}
    server_name s.dajxyl.com;
    #ssl_trusted_certificate     /etc/letsencrypt/live/s.dajxyl.com/fullchain.pem;
    #ssl_certificate             /etc/letsencrypt/live/s.dajxyl.com/fullchain.pem;
    #ssl_certificate_key         /etc/letsencrypt/live/s.dajxyl.com/privkey.pem;
    #ssl_session_timeout 5m;
    #ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
    #ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    #ssl_prefer_server_ciphers on;

    #ssl_stapling on;
    #ssl_stapling_verify on;

    #resolver 8.8.8.8 8.8.4.4 valid=600s;
    #resolver_timeout 6s;

    access_log  /home/wwwlogs/dajx_s_access.log main;
    error_log   /home/wwwlogs/dajx_s_error.log;
    set         $root   /home/www/shop/public;
    # 商城后台前端页面路径
    set         $rootweb /home/www/shop-web;
    location /shop-web {
        alias $rootweb;
        index index.html index.htm;
    }
    location / {
        root    $root;
        index   index.html index.php;
        if ( !-e $request_filename) {
            rewrite ^(.*)$ /index.php/$1 last;
            break;
        }
    }
    location ~ .+\.php($|/) {
        fastcgi_pass    127.0.0.1:9000;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_param   PATH_INFO          $fastcgi_path_info;
        fastcgi_param   PATH_TRANSLATED    $document_root$fastcgi_path_info;
        fastcgi_param   SCRIPT_FILENAME    $root$fastcgi_script_name;
        include         fastcgi_params;
    }
}
EOF

迭代8发布报告

点赞(0) 阅读(1) 举报
目录
标题