How to use `skip_launch` with the machines API?

I have noticed the awesome option to skip_launch in the machines API but unfortunately, I have no clue how to use it. The docs only say that I can “set” it, but do not mention where it belongs.

Can you please provide an example?

Also, the docs say that you can set it “if the Machine isn’t running, and you don’t want it to start up”. How is skip_launch handled if the machine is running and I still provide that option? Does it prevent immediate reboot?

I believe that to use skip_launch, you must include it in the body of the request when creating a machine. Here is an example in cURL to illustrate how to do it:

curl -i -X POST \
  -H "Authorization: Bearer ${FLY_API_TOKEN}" -H "Content-Type: application/json" \
  "${FLY_API_HOSTNAME}/v1/apps/my-app-name/machines" \
  -d '{
    "config": {
      "image": "registry-1.docker.io/library/ubuntu:latest",
      "skip_launch": true
    }
  }'

In this example, skip_launch: true is specified inside the config object, which ensures that the machine is not started immediately after being created. This is especially useful for cases where you need to have machines ready but not active, optimizing the use of resources and costs.

Let me know how it goes,
Sergio Turpín

1 Like

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