I'm looking for a way to gracefully exit from a long running python script which I launch from my Laravel app.
My actual process to do so is:
- From Laravel set a 'script_state' to 1 in a MySql table database
- Launch the python script via
shell_exec
- The python scripts periodically check the 'script_state' by a MySql query. If it is changed to 0 (intentionally from my Laravel app) then it gracefully exit the script
Retrieving the pid
from the shell_exec
and then kill could have been an option but I actually wan't the script to stop and exit gracefully.
My actual config works but I'm looking for a better approach.