If you want to see how things added up - run through commits from the first one.
This is especially important for DB migrations part, as same file was changed several times.
cd deployer
curl -LO https://deployer.org/deployer.phar
cd app
composer install
cd ../../env
./run.sh
To look inside php-fpm:
ssh root@localhost -p 2222
Open tester/index.html
for testing.
cd deployer
php deployer.phar deploy -vvv nginx
Not using restart: redeploy - main script is old, included one - new.
Using restart: release is changed, but errors on deployment
cd deployer
php deployer.phar deploy -vvv apache
Inconsistencies when deploying for small amount of time.
cd deployer
php deployer.phar deploy -vvv nginx
No symlinks anywhere - whee!
Problems with OpCache:
http://localhost:8081/opcache.php
Use cachetool to reset OpCache: http://gordalina.github.io/cachetool/
http://localhost:8081/cache.php
Cache needs to be cleared manually if not restarting php-fpm.
Either way, simple restart on running system is not enough.
Cache keys must include current release / version number.
Let's take a case: we have table where one column represents money in
this format: ### ABC
, where ###
is amount and ABC
is currency.
We'll try to change this structure into two columns: ###
and ABC
.
Migrations are run on deployment, before changing to the new code.
Let's run Load tester on DB. Then:
php deployer.phar deploy -vvv nginx
# errors should be visible
php deployer.phar rollback -vvv nginx
# ouch!
# to reset test, from env/:
./reset-db.sh
First deployment:
- Add new columns, do not remove old ones.
- Always insert both old and new values. This handles previous release and possible rollback.
- Support both new and old columns - this will be needed later.
Second deployment:
- Make old column nullable.
- Migrate data from old to new columns.
- Only use new columns in code - both for inserting and returning. As we've got step No. 3 covered in previous deployment, it's OK to rollback at this state.
Third deployment:
- Remove old column.
- Make new columns non nullable (could be in previous step).