Creating Machine through API, Auto start and Auto Stop doesn't get set!

Hey Its my first time using fly.io , Its been a great experience so far but I have hit a major roadblock.

I am creating apps using api and I set the auto stop and auto start in there. But when I create through the api autostart and auto stop doesn’t work. If I create through fly.toml and cli then auto start and stop works

Code which makes the api call

const machineConfig = {
                config: {
                    image: 'test/expo-fast:latest',
                    services: [
                        {
                            protocol: 'tcp',
                            internal_port: 8000,
                            auto_stop_machines: "stop",
                            auto_start_machines: true,
                            min_machines_running: 0,
                            ports: [
                                { port: 80, handlers: ['http'] },
                                { port: 443, handlers: ['tls', 'http'] }
                            ]
                        },
                        {
                            protocol: 'tcp',
                            internal_port: 8001,
                            auto_stop_machines: "stop",
                            auto_start_machines: true,
                            min_machines_running: 0,
                            ports: [
                                { port: 8001, handlers: ['tls', 'http'] }
                            ]
                        }
                    ],
                    env: {
                        PORT: '8000',
                    },
                    guest: {
                        cpu_kind: 'shared',
                        cpus: 2,
                        memory_mb: 2048
                    }
                },
            };

What did I do to debug ?

I ran this cli command to get the config of the machine created by the api

flyctl config save -a container-1744165961751-0

Its missing the auto start and auto stop

[[services]]
  protocol = 'tcp'
  internal_port = 8000
  min_machines_running = 0

  [[services.ports]]
    port = 80
    handlers = ['http']

  [[services.ports]]
    port = 443
    handlers = ['tls', 'http']

[[services]]
  protocol = 'tcp'
  internal_port = 8001
  min_machines_running = 0

  [[services.ports]]
    port = 8001
    handlers = ['tls', 'http']

[[metrics]]

Either this is a major bug no one has gone through before or I am doing something majorly wrong

Hey @tanmaykejriwal28

The fields are called auto_start_machines and auto_stop_machines in fly.toml, but the API expects autostart and autostop: Fly Machines API

1 Like

Thanks this really helped

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