By kenshin9
I’m looking to use App Platform for hosting some custom code. This is meant to be a scheduled type of task, so from what I understand, I’d want to set up a Worker component to run in the background. I have seen the docs and repo about the cron using Docker, over in the DigitalOcean-AppPlatform-Cron repo.
But I couldn’t find clarification on details regarding this Worker component. Is it a long running resource? I seem to be getting mixed answers as I search the internet, so I just wanted to be sure. I was thinking that if it was, then I could use something like node-cron within a script, and then have the Worker instance execute this script so that I can run some cron jobs. But I’d love to hear if this wouldn’t work.
Thanks in advance.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Accepted Answer
Hi there,
Indeed, the Worker components are long running components. The main difference between a Worker component and a Web service component is that the Worker components are not exposed to the internet via HTTP.
The cronjob repo example that you are referring to here:
https://github.com/DO-Solutions/DigitalOcean-AppPlatform-Cron
This is going to be useful if you want to setup an HTTP endpoint that you can hit with that service on a specific schedule. However if you are looking to setup a CLI command instead, you would need to modify that example repo so that you actually deploy your code as well rather than just the cron
and curl
commands.
What you could do indeed is just fork that repository and extend it so that you could also include your app in there and use the cron
service as well.
Let me know if this helps!
- Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.