Our client was happy with the deployment, but they were not happy that the website was down for a while, during the deployment. And that makes sense! We have our script set up to take our application down:
cd /home/forge/v2.linksletter.comif [ -f artisan ]; then $FORGE_PHP artisan downfi git pull origin $FORGE_SITE_BRANCH$FORGE_COMPOSER install --no-dev --no-interaction --prefer-dist --optimize-autoloader npm installnpm run build rm -rf /node_modules if [ -f artisan ]; then $FORGE_PHP artisan cache:clear $FORGE_PHP artisan view:clear $FORGE_PHP artisan route:cache $FORGE_PHP artisan config:cache $FORGE_PHP artisan view:cachefi ( flock -w 10 9 || exit 1 echo 'Restarting FPM...'; sudo -S service $FORGE_PHP_FPM reload ) 9>/tmp/fpmlock if [ -f artisan ]; then $FORGE_PHP artisan migrate --force $FORGE_PHP artisan upfi
Specifically, the artisan down
and artisan up
commands. They take our application into maintenance
mode for a few minutes. Let's look at Forge's deployment history:
It takes 10-20 seconds; imagine if our application grew in complexity and size. This can grow exponentially!
So, what are our solutions? We can use a zero-downtime deployment tool like official Laravel Envoyer.
There are also other alternatives:
But for this tutorial, we chose Envoyer because it's a first-party tool from Laravel team.
Let's set it up!
Configuring Envoyer
To set up Envoyer, we must go to the Envoyer website and sign up for an account. Once we have an account, we can start the...