Schedule:run from a Scheduled Function instead of a cron?
In my two weeks of struggling to deploy on Digital Ocean Apps I never managed to get the cron to work. So an interesting idea popped into my head:
Digital Ocean has "Functions" you can automatically execute every minute, much like a cron. So what if instead of running a cron, I create such a function.
The function would make a curl request to the API, which in turn would execute "schedule:run". This would happen every minute.
Do crons do anything magic other than calling the function every minute? Wouldn't the result be the same?
@vincent15000 Yes I realise that. My question is if in situations where a cron is not viable, of triggering schedule:run every minute in other ways (such as "Scheduled Functions" in Digital Ocean) is a good alternative.
@KrisTP I don't know Digital Ocean, but what you say seems to be a cron task on Digital Ocean. Furthermore the Laravel documentation says that the cron configuration will execute schedule:run every minute, so it's exactly the same as what would be done with a crontab configuration.
So sure what you want to do seems to be a good alternative.
Otherwise have you seen this documentation about Digital Ocean ?
@vincent15000 yes, I've seen that page. Unfortunately I did not get Docker to successfully deploy after many days of trying, so I had to come up with an alternative solution.
If my idea is valid and I'm not making a big mistake by doing it this way, I can be up and running really fast and leave the Docker mess behind me.
@KrisTP I don't know Docker and I really don't understand why Docker could be useful in this case.
According to me, there is no mistake by running schedule:run every minute via a Digital Ocean configuration given that via a crontab configuration the schedule:run command is executed every minute too.
So, when using Laravel's scheduler, we only need to add a single cron configuration entry to our server that runs the schedule:run command every minute.
Your function will run for at least 100ms (according to the docs) and might actually run for the entire duration of the schedule command so probably best to queue any work triggered by the schedule.
@Snapey cost is a consideration. I just did some calculations and I think I'll stay within the free tier. The scheduled tasks aren't that complex. There are some e-mails being sent, but those are queued.