Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

fkwok's avatar
Level 2

Envoyer didn't really restart forge managed queue workers

Hi,

While I am using Envoyer for my project deployment and have Forge to management my servers e.g. creating new workers for the queues.

Before I move to Envoyer I have tried the Forge deployment feature and it work fine with adding php artisan queue:restart in the deployment script.

However when I move to Envoyer I added the deployment webhooks after "Activate New Release" to restart the queue as below, so I can load the new code to the workers.

cd {{release}}
php artisan queue:restart

Deployment went well, but when I run the jobs I can see the old codes are still being executed in the workers (Through log files). It will only refresh the new version of codes when I login to Forge and manually restart the workers one by one from the server application.

Is there anything I did wrong that the worker in Forge doesn't restart properly?

Regards,

Fei

0 likes
15 replies
francoboy7's avatar

I use the same command and feel like i'm having the same issue as you

fkwok's avatar
Level 2

Yeh, I am not 100% sure the cd {{release}} work as I expected... I feel like the directly might not be the right one when we deploy it.... So I think I will try to use cd /home/forge/default/current instead (just to be sure) and put this deployment webhook at the very last thing to do in the deployment process.

If this still not working .... I will just update the forge deployment script to do nothing but just restarting the queue in the "current" folder.... down side is, it is manual ...

fkwok's avatar
Level 2

alright, I have tried the following method and still not working:

  1. put the php artisan queue:restart at the end of the deployment process in Envoyer (like last time to do of the process)
  2. put the php artisan queue:restart in Forge site "deployment script" after cd /home/forge/default/current folder and click deploy button manually.

Both methods doesn't work ... the workers still execute the out of date source code.

Only when I got into each website in Forge and restart the "workers" one by one ... then them finally reload the latest source code and running the job correct.

Anyone has a better solution for this? because if we can't automate the worker restart then it won't have much benefit working with Envoyer .... even it is great for multiple servers deployments....

trevorg's avatar

I know when the artisan queue:restart command is issued, what it does is set a value in the cache which the queue workers check every time they run. What cache store are you using?

fideloper's avatar

Just as a sanity check - Are your app files actually in the default directory?

fkwok's avatar
Level 2

I am using Redis Cache. Not sure is that related ... but isn't the php artisan queue:restart should take care of it already?

My feeling is because the worker I created and managed were on the "Forge" - application and the deployment webhooks which trigger the queue:restart was from "Envoyer" application.

Since they are from different application so the "Envoyer" deployment webhooks doesn't affect the "Forge" workers...

fkwok's avatar
Level 2

@fideloper I am using "Envoyer" do the deployment so the app is in :

forget/default/current folder - envoyer default setting

BGWeb's avatar

@fkwok Did you get this resolved? I use cd {{ release }} to move to the release directory and build my assets; have not had an issue with this. However, I now need to restart my queue workers after deploying and want to make sure I have the right build hook setup. I put the following as my last hook, after the old release is purged:

cd {{ release }}

php artisan queue:restart

When I deploy later today I will let you know how it goes.

1 like
fkwok's avatar
Level 2

Hi @bgweb @polarcubs ,

I have started to use horizon instead of Forge originated workers.

I couldn't seems to get the Forge's workers refresh correctly while using the Envoyer. I guess I just have to accept it that both applications are not compatible while cross managing the workers.

If you want to use Envoyer as the deployment tool, it will be easier to just use horizon on your application to management the worker. So you don't need to create the worker in the Forge etc.

With this you can put the "restart" script in the Envoyer deployment webhooks and use Forge's Daemon tools ensure the horizon (and it's workers) to restart every time we deploy.

This is the only way I can think of to make sure worker always run on the latest version. I got these information from the Medium post below.

https://medium.com/@driesvints/laravel-horizon-with-forge-and-envoyer-82a7e819d69f

Hope this help. Open for any other suggestion.

Cheers,

Fei

StepToMe's avatar

I as well just experienced the problem mentioned here initially.

I have this as a deployment hook in the after Activate New Release:

cd {{ release }}

php artisan queue:restart

But the job still ran with an old release.

I restarted the queue manually in Forge and I think that fixed it, but not sure how to do it automatically...And I don't really have time to set up horizon right now.

auflyer2's avatar

Having the same issue on Forge directly.

php artisan queue:restart

...has no effect on the currently running queue workers.

I can manually restart the queues using the refresh icon on forge, or manually SSH'ing into the server but that doesn't help with auto-deploy.

Anyone else run across this?

auflyer2's avatar

Follow up...

I have no idea why or if this is what fixed it, but changing the cache driver to redis (queues are running on redis as well) and manually restarting the queues seemed to fix it.

Just leaving this here in case it helps someone else down the line.

1 like
alfrednutile's avatar

Tried the above and still not luck. @fkwok it is not about different managed services, Envoyer runs the commands on your server. Tried the Redis cache thing too no luck. I might try the horizon option but it is a lot of work to do something so simple.

alfrednutile's avatar

I went nuclear on the hook :)

cd {{ release }}

sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl restart all
php artisan queue:restart

I could limit the "all" but just wanted to prove it works

3 likes

Please or to participate in this conversation.