Ben

Ben

Live

Hi,

with enabled zero downtime deployment, the current deploy script will run before the actual going live because the symlinks are automatically changed after running. With e.g. Statamic, there is a command to preheat the cache by crawling the current live site, which is still the old one at the time of deployment. If you do not have enabled zero downtime deployment, you do not have that issue because the site is technically changed within the control of the deployment script. So it would be really cool if there is an additional deploy script variable to execute the symlink change and post-deploy stuff of zero downtime in the script, so that we can do something after that like preheat the cache.

Dennis

Dennis

·
·

Are you using {RELEASE} by any chance to run your commands in?

no votes yet
Ben

Ben

Item author
·
·

Yes, I do, but that's just giving the new release folder. Problem is that the preheat logic crawls the currently live site and that is still the "old" one at the time of executing the deployment script. So the preheated HTML files will be put into the currently live folder. If we could have the folders switched with a new custom variable, we could be sure to execute the preheating after symlinking to the new folder.

no votes yet
Ben

Ben

Item author
· · Edited
·

That would also give more flexibility to the zero downtime deployment script since this could be easily done with normal deployments because we control the actual "going live" ourselves on them via git pull, refresh caches etc. This "functionality" is missing on zero downtime deployments.

no votes yet
Ben

Ben

Item author
·
·

btw this does also apply to the queue restart problem. When you restart your queue during zero downtime deployment, it will not pick up the latest changes

no votes yet
Dennis

Dennis

·
·

Could you post your deploy script? (Exclude any sensitive data)

no votes yet
Ben

Ben

Item author
·
·

if [[ {COMMIT_MESSAGE} =~ "[BOT]" ]]; then echo "AUTO-COMMITTED ON PRODUCTION. NOTHING TO DEPLOY." {DO_NOT_NOTIFY} exit 0 fi

cd {RELEASE} git reset --hard git pull composer install --no-dev --no-interaction --prefer-dist --optimize-autoloader {RELOAD_PHP_FPM}

rm -rf public/static/ php8.1 artisan cache:clear

php8.1 artisan config:cache php8.1 artisan route:cache php8.1 artisan view:cache php8.1 artisan event:cache

php8.1 artisan migrate --force

{RESTART_DAEMON ###}

php8.1 artisan statamic:stache:warm # Warm the Statamic stache. php8.1 artisan statamic:search:update --all # Update the search index. php8.1 artisan statamic:assets:generate-presets # Generate all asset presets.

yarn yarn production

echo "🚀 Application deployed!"

no votes yet
Ben

Ben

Item author
· · Edited
·

Anything that's relaying on currently live data (queues use currently active live directory, warm static caches with live URL) will not work with zero downtime deployment.

1 total vote
Samuel Loft
Samuel Loft

Samuel Loft

·
·

Constantly getting caught out with this myself.

no votes yet
Jürgen

Jürgen

·
·

I'm having issues with restarting queues / horizon when using zero downtime deploys. Would be nice to have a more like Envoyer approach where you're able to add a script that runs after symlinking the new folder.

no votes yet
Thomas van der Westen

Thomas van der Westen

·
·

Yeah, I'm having the same problem. The queue is still using the previously deployed code. Also, php artisan queue:restart does not results in a hard restart.

no votes yet
Dennis

Dennis

·
·

I will be working on a POC tonight which allows you to run commands after the symlink. This should solve a lot I supose.

no votes yet
Dennis

Dennis

· · Edited
·

2 total votes
Daniel Sturm Thomas van der Westen
Dennis

Dennis

·
·

@Ben would you be able to test?

no votes yet

Execute commands after zero downtime deployment

3 total votes
Samuel Loft Daniel Sturm Ben
  • Dennis moved item to board Live

    1 month ago
  • Dennis moved item to board In progress

    1 month ago
  • Dennis moved item to board Planned

    1 month ago
  • Dennis moved item to board Under review

    2 years ago
  • Ben moved item to project Site Level Requests

    2 years ago
  • Ben created the item

    2 years ago