GraphQL API config services json

Hey again, I’m trying to convert this fly.toml config to use with the graphql API:

kill_signal = "SIGINT"
kill_timeout = 5

[[services]]
  internal_port = 80
  protocol = "tcp"

  [services.concurrency]
    hard_limit = 500
    soft_limit = 400

  [[services.ports]]
    port = "80"

[[services]]
  internal_port = 443
  protocol = "tcp"

  [services.concurrency]
    hard_limit = 500
    soft_limit = 400

  [[services.ports]]
    port = "443"

[[services.script_checks]]
  command       = "/usr/bin/pullscript.sh"
  grace_period  = "30s"
  interval      = "60s"
  restart_limit = 1
  timeout       = "15s"

but I’m not sure how to format the services correctly in the config services section (see below):

mutation launchApp {
            launchApp(input: {
            organizationId: "myorgid",
            name: "#{fly_app.name}",
            config: {
              services: [
                {
                  internal_port: 443,
                  protocol: "tcp"
                  ports: [{
                    port: 443,
                  }],
                  concurrency: [{
                    hard_limit: #{fly_app.hard_limit},
                    soft_limit: #{fly_app.soft_limit} 
                  }],
                },
                {
                  internal_port: 80,
                  protocol: "tcp"
                  ports: [{
                    port: 80,
                  }]
                }
              ],
              env: {
                FOO: "bar"
              }
            },
            image: "registry/image",
            vmSize: DEDICATED_CPU_1X,
            regions: [EWR, YYZ],
            secrets: [
              {
                key: "foo",
                value: "bar",
              },
              {
                key: "hello",
                value: "world",
              },
            ],
          }) {
              app { id, name }
              release { id, version, inProgress }
            }
          }

Mainly the script check service. Any help is much appreciated!

services.script_checks are per-service. You’ll probably need 1 per service here.

Essentially, you want to do:

// ...
services: [
  // ...
  script_checks: [
    {
        command: "/usr/bin/pullscript.sh",
        grace_period: "30s",
        interval: "60s",
        restart_limit: 1,
        timeout: "15s"
    }
  ]
// ...
}

TOML is a bit tricky when it comes to arrays vs maps.

services.concurrency is a map, not an array. Easy way to think about it [[ ]] means it’s an array and [ ] means it’s a map.

1 Like

You can see the json config of an existing app with flyctl config display for reference.

1 Like