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?

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.

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.

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

Dennis
Dennis ·

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

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!"

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.

Samuel Loft
Samuel Loft ·

Constantly getting caught out with this myself.

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.

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.

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.

Dennis
Dennis · · Edited

Dennis
Dennis ·

@Ben would you be able to test?

Ben
Ben Item author ·

Hi Dennis, sorry for the late response! Yes, I'd be happy to test this. Is the feature live and available in production now? If so, where can I find the new options? Let me know how best to proceed! Cheers, Ben

Dennis
Dennis ·

Haha 1 year old already wow! Yes, if you have ZTD enabled you get the new deploy scripts feature like in my image above which you can test.

Philipp
Philipp ·

@Dennis Did this change/prototype ever go live? I'm still having issues with queue:restart in a ZDT environment.

Execute commands after zero downtime deployment

4 total votes
  • Dennis moved item to board Live

    1 year ago
  • Dennis moved item to board In progress

    1 year ago
  • Dennis moved item to board Planned

    1 year ago
  • Dennis moved item to board Under review

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

    4 years ago
  • Ben created the item

    4 years ago
Quick Actions
Activity
View recent activity and updates
Use arrow keys to navigate