📜 ⬆️ ⬇️

The structure of configs on the Alawar sites

Hello!
Alawar sites are sites for Russian , American , European and other markets, separate sites for mobile devices, affiliate program sites, etc. All of them are deployed on the same Yii instance, which we already wrote about on our blog .
Today I will tell you how we organized the storage, structure and management of configs of our sites, which at the same time received advantages. And also I will tell how the deployment of our project is carried out in various environments.



Configs

To customize the sites, we applied the following configs structure in Yii:
')
protected/config /console /config.php /import.php /cache.php /log.php … /mobile /config.php /import.php /cache.php /log.php … /sites /alawar.ru.php /iphone.alawar.ru.php /ipad.alawar.ru.php /site.php … /test /config.php /import.php … /web /config.php /import.php /log.php … /~server /amqp.php /crontab.txt /db.php /eauth.php /mongo.php /redis.php /smsgate.php /services.php /comment.php … 

All configuration files were divided into categories according to their purpose:

A specific feature of the configs structure is that the protected / ~ server contains “sero-dependent” parameters and settings that are stored in separate repositories for each server (~ server is just a symlink to check out one of the repositories). This structure allows you to easily, quickly and without crutches to deploy the project in a variety of environments.

Depla

At the moment, our project can be deployed on 3 servers:

Accordingly, each server has its own repository with configs:


When deploying a project (we do this with jenkins and phing ), we simply indicate which branch and which repository with configs to raise:
 #  task-xx  dev- phing -Dbranch=task-xx -Dconfig=dev-config deploy #     phing -Dbranch=prod -Dconfig=prod-config deploy 


This is what phing does with it:
 <!--     --> <target name="deploy" depends="-get-properties"> <!--   ,     --> <mkdir dir="${deploy.path}" /> <!--   ,          --> <mkdir dir="${deploy.path}/application" /> <!--   ,        --> <mkdir dir="${deploy.path}/config" /> <echo msg="checkout application and config..." /> <!--   --> <exec command="bzr co ${bzr.branch.path} ./" dir="${deploy.path}" checkreturn="FALSE" returnProperty="bzr.co.return" outputProperty="bzr.co.out" /> <if> <!--    ,  ,     --> <equals arg1="${bzr.co.return}" arg2="3" /> <then> <exec command="bzr co ${bzr.trunk.path} ./" dir="${deploy.path}/application" /> <exec command="bzr switch -b ${bzr.branch.path}" dir="${deploy.path}/application" /> </then> </if> <!--     --> <exec command="bzr co ${bzr.config.path} ./" dir="${deploy.path}/config" /> <!--      runtime --> <chmod file="${deploy.path}/application/protected/runtime" mode="0777" /> <!--     --> <exec command="ln -s ${deploy.path}/config/server server" dir="${deploy.path}/application/protected/config/" level="info"/> <!--    php error log --> <exec command="ln -s ${php.error.log.path} phplog" dir="${deploy.path}/application/protected/runtime/" level="info"/> <!--      css  js       protected/runtime/sites/{site.ru.php} --> <exec command="php ${deploy.path}/application/protected/yiic deploy data=css" /> <exec command="php ${deploy.path}/application/protected/yiic deploy data=js" /> <!--    redis  mysql --> <exec command="php ${deploy.path}/application/protected/yiic deploy data=shardmap" /> </target> 


Thus, after deployment, the structure of the entire project becomes the following:
 application/ #     protected/ … config/ … ~server/ #  config/server … … public/ … config/ #    … server/ … 

Total

The structure of configs used by us allowed:

However, of course, the approach with various repositories for configs has its drawbacks, the main one is the synchronization of changes. It is necessary to transfer the changes in one repository to all others, taking into account the settings of the environment.

Source: https://habr.com/ru/post/186458/


All Articles