Run the PHP command-line script based on Supervisord, which can be controlled based on the Rancher environment variable to support the implementation of the PHP command-line script only runs in the stand-alone when deploying a cluster
1. will /build/c_files/etc/supervisord.d/yii-cmc-console-user-sync.ini, /build/c_files/etc/supervisord.d/yii-config-column-user-sync.ini Shear to /build/c_files/tmp/yii-cmc-console-user-sync.ini, /b uild/c_files/tmp/yii-config-column-user-sync.ini, as shown in Figure 1
2. Edit \build\c_files\config\init\console_init.sh, the code is as follows, as shown in Figure 2
env | grep PCS_API_CFG_CONSOLE || export PCS_API_CFG_CONSOLE="false"
if [[ $PCS_API_CFG_CONSOLE == "true" ]]
then
\cp /tmp/yii-cmc-console-user-sync.ini /etc/supervisord.d/
echo "复制 yii-cmc-console-user-sync.ini 至 /etc/supervisord.d/"
\cp /tmp/yii-config-column-user-sync.ini /etc/supervisord.d/
echo "复制 yii-config-column-user-sync.ini 至 /etc/supervisord.d/"
elif [[ $PCS_API_CFG_CONSOLE == "false" ]]
then
echo "copy without console"
else
echo "please set environment variable PCS_API_CFG_CONSOLE true or false"
fi
3. Edit \build\readme.md, whether the console command is executed (when a single-machine deployment, it needs to be set to true; when deploying a cluster, only one machine needs to be set to true, and other machines are set to false), true: yes; false: no, default: false
Rancher 环境变量(已设置默认值,可无需设置)
PCS_API_CFG_CONSOLE=false # 控制台命令是否执行(单机部署时,需设置为 true;集群部署时,仅需一台机器设置为 true,其他机器皆设置为 false),true:是;false:否,默认:false
4. When the container is upgraded, set the environment variable pcs_api_cfg_console=true1 to view the upgrade log
2019/9/29 下午2:51:31PCS_API_CFG_CONSOLE=true1
2019/9/29 下午2:51:31please set environment variable PCS_API_CFG_CONSOLE true or false
5. After the container is upgraded, set the environment variable pcs_api_cfg_console=true1 to check the running status of supervisord, php command line script CMC-console-user/sync, config-column-user/sync are not running, in line with expectations
[root@ccb936b43173 /]# ps aux|grep superviosrd
root 533 0.0 0.0 10696 992 pts/2 S+ 14:50 0:00 grep --color=auto superviosrd
[root@3bcad2636ae5 /]# supervisorctl status
cronolog RUNNING pid 436, uptime 0:01:47
nginx RUNNING pid 433, uptime 0:01:47
php-fpm RUNNING pid 434, uptime 0:01:47
report_client RUNNING pid 435, uptime 0:01:47
6. When the container is upgraded, the environment variable PCS_API_CFG_CONSOLE is not set, or the environment variable PCS_API_CFG_CONSOLE=FALSE is set, as shown in Figure 3
2019/9/29 下午2:49:26copy without console
7. After the container is upgraded, the environment variable PCS_API_CFG_CONSOLE is not set, or the environment variable PCS_API_CFG_CONSOLE=FALSE is checked, check the running status of supervisord, php command line script CMC-console-user/sync, config-column-user/sync are not running, in line with expectations
[root@ccb936b43173 /]# ps aux|grep superviosrd
root 533 0.0 0.0 10696 992 pts/2 S+ 14:50 0:00 grep --color=auto superviosrd
[root@ccb936b43173 /]# supervisorctl status
cronolog RUNNING pid 436, uptime 0:01:02
nginx RUNNING pid 433, uptime 0:01:02
php-fpm RUNNING pid 434, uptime 0:01:02
report_client RUNNING pid 435, uptime 0:01:02
8. When the container is upgraded, set the environment variable pcs_api_cfg_console=true, as shown in Figure 4
2019/9/29 下午2:54:53PCS_API_CFG_CONSOLE=true
2019/9/29 下午2:54:53复制 yii-cmc-console-user-sync.ini 至 /etc/supervisord.d/
2019/9/29 下午2:54:53复制 yii-config-column-user-sync.ini 至 /etc/supervisord.d/
9. After the container is upgraded, set the environment variable pcs_api_cfg_console=true to check the running status of supervisord, php command line script CMC-console-user/sync, config-column-user/sync are all running, in line with expectations, as shown in Figure 5
[root@9fdfba4524e6 /]# ps aux|grep superviosrd
root 550 0.0 0.0 10696 992 pts/2 R+ 14:46 0:00 grep --color=auto superviosrd
[root@9fdfba4524e6 /]# supervisorctl status
cronolog RUNNING pid 441, uptime 0:02:01
nginx RUNNING pid 436, uptime 0:02:01
php-fpm RUNNING pid 435, uptime 0:02:01
report_client RUNNING pid 438, uptime 0:02:01
yii-cmc-console-user-sync RUNNING pid 515, uptime 0:00:57
yii-config-column-user-sync RUNNING pid 514, uptime 0:00:58
10. It is recommended to view the URL:https://www.shuijingwanwq.com/2019/09/29/3525/, replace the /tmp to /mcloud, fix the bug :




