earmsby's avatar

Deployment script/restarting Queue

I have a bunch of different sites deployed on Forge. In one or two, I'm using Filament importing and exporting and thus I have a Queue Worker process running.

I noticed a difference between the deployment scripts for more recently created sites and older sites. One thing is that on the newer sites, there is this in the deployment script:

$RESTART_QUEUES()

On an older site where I'd also like to restart the queue when I deploy changes, I don't have that. I tried adding this line to the deployment script but it caused the deployment to fail. I'm guessing that's because the whole deployment process is different between the two sites.

Could I just copy the whole script (editing as needed to pertain to the site) from the newer site to the older one or are other steps needed to accomplish this? Alternatively, is there a difference command to use that would restart the queue and also work in the older style deployment script?

For reference, here is the entire script for the older site:

cd /home/forge/my-site.on-forge.com

git pull origin $FORGE_SITE_BRANCH
$FORGE_COMPOSER install --no-dev --no-interaction --prefer-dist --optimize-autoloader

# Prevent concurrent php-fpm reloads...
touch /tmp/fpmlock 2>/dev/null || true
( flock -w 10 9 || exit 1
    echo 'Reloading PHP FPM...'; sudo -S service $FORGE_PHP_FPM reload ) 9</tmp/fpmlock

npm ci && npm run build

And here's the whole script for the newer site:

$CREATE_RELEASE()

cd $FORGE_RELEASE_DIRECTORY

$FORGE_COMPOSER install --no-dev --no-interaction --prefer-dist --optimize-autoloader
$FORGE_PHP artisan optimize
$FORGE_PHP artisan storage:link
$FORGE_PHP artisan migrate --force

npm ci || npm install && npm run build

$ACTIVATE_RELEASE()

$RESTART_QUEUES()
0 likes
1 reply
LaryAI's avatar
Level 58

You’re correct that $RESTART_QUEUES() is a Forge deployment hook only available when you’re using the newer zero-downtime style scripts ($CREATE_RELEASE/$ACTIVATE_RELEASE). That function doesn’t exist in your older, "single dir" style script—so it errors out.

To restart your queue worker in the older deployment script, you should use the Artisan command directly, like so:

$FORGE_PHP artisan queue:restart

Just add that as the last step in your script, after code is updated and dependencies are installed. No need to copy the entire new script style unless you want to migrate to zero-downtime deployments. This single line should handle queue restarting for you!

Please or to participate in this conversation.