SoapyIllusion's avatar

Docker Container - Laravel Scheduler Best Practice

Hello All,

Currently setting up a Laravel API app that uses Commands to pull data from an external API every hour in the background. That API data gets stored to a database. This app runs within a docker container that itself will live on VM.

I am currently achieving this by setting up a scheduler that auto-restarts and runs the command php artisan schedule:run

Ultimately I am just running three different commands over the span of a few hours every day. Is this considered good practice for a an app that will have a very very small user base?

I know the other option is to utilize supervisor and CRON but I feel for that amount of tasks and the scope of the project I feel its overkill.

1 like
4 replies
vincent15000's avatar

Not sure to understand what you need ... if you have to restart some commands that could stop anyway, in production you have to use a supervisor like this one for example.

https://supervisord.org/

The supervisor ensures that each command that should run permanently is reexecuted if it stops.

I have done this last year for an application created inside a docker container.

martinbean's avatar

@soapyillusion I don’t really understand why you’re containerising an app to then put in a VM. Like, you do one or the other.

There’s also no point containerising and putting your app in a virtual machine if you then can’t run something as simple as a cron job.

1 like
SoapyIllusion's avatar

Unfortunately there are political constraints preventing me from running this as I would ultimately like. So I am trying to make the best solutions with the given constraints.

1 like
SoapyIllusion's avatar
SoapyIllusion
OP
Best Answer
Level 3

I was able to get some higher ups to relent on a policy. I am now allowed to run the CRON on the host. Running every minute php artisan schedule:run will be sufficient.

2 likes

Please or to participate in this conversation.