How to schedule upscaling and downscaling of Fly.io machines using fly.toml configuration?

I’m having difficulty using fly.io! I need to schedule an upscaling and downscaling for one of my machines and I haven’t been successful. My fly.toml config file looks like this:

# fly.toml app configuration file generated for comuh on 2024-08-24T14:40:15-03:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = 'comuh'
primary_region = 'gru'
console_command = '/rails/bin/rails console'

[build]
  dockerfile = "Dockerfile.production"

[http_service]
  internal_port = 3000
  force_https = true
  auto_stop_machines = 'off'
  auto_start_machines = true
  min_machines_running = 0
  processes = ['app']

[checks]
  [checks.status]
    port = 3000
    type = 'http'
    interval = '20s'
    timeout = '5s'
    grace_period = '10s'
    method = 'GET'
    path = '/up'
    protocol = 'http'
    tls_skip_verify = false
    [checks.status.headers]
      X-Forwarded-Proto = 'https'

[[vm]]
  memory = '512mb'
  cpu_kind = 'shared'
  cpus = 1
  processes = ['app']

[[vm]]
  memory = '512mb'
  cpu_kind = 'shared'
  cpus = 1
  processes = ['worker']

[[schedule]]
  schedule = "0 13 * * *"
  memory = '2048mb'
  cpu_kind = 'shared'
  cpus = 4
  processes = ['worker']

[[schedule]]
  schedule = "0 12 * * *"
  memory = '512mb'
  cpu_kind = 'shared'
  cpus = 1
  processes = ['worker']

[processes]
  app = "bundle exec rails server"
  worker = "bundle exec sidekiq -C config/sidekiq.yml"

[deploy]
  release_command = "bash -c 'bundle install && bundle exec rails db:migrate'"

[mounts]
  source = 'browser_data'
  destination = '/app/storage/browser_sessions'
  processes = ['worker']

I’m having difficulty using fly.io! I need to schedule an upscaling and downscaling for one of my machines and I haven’t been successful. My fly.toml config file looks like this:

# fly.toml app configuration file generated for comuh on 2024-08-24T14:40:15-03:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = 'comuh'
primary_region = 'gru'
console_command = '/rails/bin/rails console'

[build]
  dockerfile = "Dockerfile.production"

[http_service]
  internal_port = 3000
  force_https = true
  auto_stop_machines = 'off'
  auto_start_machines = true
  min_machines_running = 0
  processes = ['app']

[checks]
  [checks.status]
    port = 3000
    type = 'http'
    interval = '20s'
    timeout = '5s'
    grace_period = '10s'
    method = 'GET'
    path = '/up'
    protocol = 'http'
    tls_skip_verify = false
    [checks.status.headers]
      X-Forwarded-Proto = 'https'

[[vm]]
  memory = '512mb'
  cpu_kind = 'shared'
  cpus = 1
  processes = ['app']

[[vm]]
  memory = '512mb'
  cpu_kind = 'shared'
  cpus = 1
  processes = ['worker']

[[schedule]]
  schedule = "0 13 * * *"
  memory = '2048mb'
  cpu_kind = 'shared'
  cpus = 4
  processes = ['worker']

[[schedule]]
  schedule = "0 12 * * *"
  memory = '512mb'
  cpu_kind = 'shared'
  cpus = 1
  processes = ['worker']

[processes]
  app = "bundle exec rails server"
  worker = "bundle exec sidekiq -C config/sidekiq.yml"

[deploy]
  release_command = "bash -c 'bundle install && bundle exec rails db:migrate'"

[mounts]
  source = 'browser_data'
  destination = '/app/storage/browser_sessions'
  processes = ['worker']

I also tried without success to use the command: fly machine update <machine_id> --app <company_name> --schedule "30 12 * **" --vm-memory 2048 --vm-cpus 4
I haven’t had success with either of the above alternatives. Does anyone have any suggestions that could help me?

Hi… As far as I know, the [[schedule]] syntax attempted in the first quote does not exist, :taruggiz_spiral:, nor is there a conceptually analogous substitute available within the bounds of fly.toml, really.

Over in fly m update, there is a flag of that name, but it’s limited to coarse-grained --schedule=monthly and similar. You cannot specify cron selectors with a particular day of the month—or fancy choreography of that kind, :degas_dancer:.

https://fly.io/docs/machines/flyctl/fly-machine-run/#start-a-machine-on-a-schedule

Perhaps you were thinking of the much heavier-weight Cron Manager, which debuted a year ago?

@thyagopcarvalho I’m interested in knowing where you found the [[schedule]] syntax!

  • Daniel

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