Report this

What is the reason for this report?

What code needed for App Platform "Worker"

Posted on May 12, 2022

I’m trying to make code that will run one method in my App Platform Django project every 15 minutes. According to the D.O. docs a Worker resource can do this.

However, after scouring the internet for hours I can’t find any documentation about how this code is run, if it needs to be it’s own python process, how the worker is configured or any other basic information on how these are supposed to work.

Ideally I can just say “run this method” on my existing App Platform app and be done with it. If needed I’m fine with sending a network request to start the method (without a response according to the Worker documentation).

I just need somewhere to start. I have no idea how to code something the worker can even use.



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!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there,

Background workers can consist of any application code you like. As far as App Platform is concerned, they are the same as services, except they are not “routable,” i.e. they are not accessible via an external URL.

It sounds like for your use case, it might be better to use a serverless function and schedule it so it runs on specific times:

https://docs.digitalocean.com/products/functions/how-to/schedule-functions/

Best,

Bobby

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.