Best practice to get progress for long-running processes with machines?

I see two ways of solving this:

  1. Sending a request to a webhook
  2. Save progress in an ENV variable and poll the machine via the machine API

I would like to avoid relying on webhooks for now. What would be the best way to update ENV variables so that they’re also reflected through the machine API? Do we have to send an update call to the fly API or is there another way?

May I suggest you use metadata?

Updating envs could trigger machine restart but metadata can be dynamically set from within (machines already can do that, auth is already set) and from outside the machine and you can retrieve those as easily as well.

If I may also offer a more near-real-time solution we ship logs via NATS. That means if your machine can write logs such as Task 123 Progress: 10% or even raw json like {"type": "task_progress", ...} and you listen to logs from another machine or even an outside from fly server you can get ordered message updates.

1 Like

An example of code that processes logs that works with Node (or Bun or …) can be found at:

1 Like

My audio encoding machines just write the FFMPEG progress to a DB.

1 Like

Thanks for all the replies and the resources! Will dive right in :pray:

From How To to Questions / Help

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.