Is there any way to read fresh config values in queue:work
When I run a job that uses a config(env) variable's value, when I change that value in .env, to have fresh values in my job, I have to restart the queue:work, is there any other way that I don't need to check that I've changed .env or not, to restart queue(on deploy)?
The queue worker initiated using php artisan queue:work is a long-running process so it needs to be restarted whenever there is a change to your code/environment. This is the most efficient way to run queues on your production environment.
However, if you use the queue listener, initiated by php artisan queue:listen instead, it will not require restarting after changes in your code/application state.
I would wonder why your environment variables are needing to be changed at all? What is the underlying issue here
@tykus e.g, adding a new job that requires a .env variable to a deployed application, or modifying wrong(or updated) .env values(external url addresses), and etc.
Adding a new Job class will also require deployment; restarting PHP-FPM as well as the queue worker.
modifying wrong .env value
Surely this is not a regular problem?
Why is restarting the queue worker during these maintenance activities difficult?
Last thing... typically .env variables are cached into your config, and once config is cached, the .env file is not read. In fact, it is recommended not to use the env() helper outside of your config files; how are you handling this aspect of changing env variables?