Rancher 环境变量不支持中文的分析解决
1、查看 \build\c_files\config\init\config0.sh 文件
sed -i "s@PCS_API_CFG_CPU_PARAMS_XCONTENT@PCS_API_CFG_CPU_PARAMS_XCONTENT@g" /sobey/www/pcs-api/environments/dev/common/config/params-local.php; sed -i "s@PCS_API_CFG_CPU_PARAMS_XCONTENT@PCS_API_CFG_CPU_PARAMS_XCONTENT@g" /sobey/www/pcs-api/environments/prod/common/config/params-local.php; sed -i "s@PCS_API_CFG_CPU_PARAMS_PCS@PCS_API_CFG_CPU_PARAMS_PCS@g" /sobey/www/pcs-api/environments/dev/common/config/params-local.php; sed -i "s@PCS_API_CFG_CPU_PARAMS_PCS@PCS_API_CFG_CPU_PARAMS_PCS@g" /sobey/www/pcs-api/environments/prod/common/config/params-local.php; sed -i "s@PCS_API_CFG_CPU_PARAMS_SOURCE@$PCS_API_CFG_CPU_PARAMS_SOURCE@g" /sobey/www/pcs-api/environments/dev/common/config/params-local.php; sed -i "s@PCS_API_CFG_CPU_PARAMS_SOURCE@$PCS_API_CFG_CPU_PARAMS_SOURCE@g" /sobey/www/pcs-api/environments/prod/common/config/params-local.php;
2、在 Rancher 环境变量中,PCS_API_CFG_CPU_PARAMS_XCONTENT、PCS_API_CFG_CPU_PARAMS_PCS 的值为中文,如图1
3、升级完毕后,进入容器中查看,发现配置文件中的变量未被替换,如图2
4、编辑 \build\c_files\config\init\config0.sh 文件,将涉及到中文的变量部分中 @ 替换为 @$,之前缺少了$
sed -i "s@PCS_API_CFG_CPU_PARAMS_XCONTENT@$PCS_API_CFG_CPU_PARAMS_XCONTENT@g" /sobey/www/pcs-api/environments/dev/common/config/params-local.php; sed -i "s@PCS_API_CFG_CPU_PARAMS_XCONTENT@$PCS_API_CFG_CPU_PARAMS_XCONTENT@g" /sobey/www/pcs-api/environments/prod/common/config/params-local.php; sed -i "s@PCS_API_CFG_CPU_PARAMS_PCS@$PCS_API_CFG_CPU_PARAMS_PCS@g" /sobey/www/pcs-api/environments/dev/common/config/params-local.php; sed -i "s@PCS_API_CFG_CPU_PARAMS_PCS@$PCS_API_CFG_CPU_PARAMS_PCS@g" /sobey/www/pcs-api/environments/prod/common/config/params-local.php; sed -i "s@PCS_API_CFG_CPU_PARAMS_SOURCE@$PCS_API_CFG_CPU_PARAMS_SOURCE@g" /sobey/www/pcs-api/environments/dev/common/config/params-local.php; sed -i "s@PCS_API_CFG_CPU_PARAMS_SOURCE@$PCS_API_CFG_CPU_PARAMS_SOURCE@g" /sobey/www/pcs-api/environments/prod/common/config/params-local.php;
5、再次升级完毕后,进入容器中查看,发现配置文件中的变量已被替换,因此,变量未被替换的问题,本质上与中文无关,如图3
近期评论