Skip to content

WIP: Fly commands

Keith Schacht edited this page May 28, 2024 · 3 revisions

DATABASES

fly machines list -a the-bot-db

Adding DB regions:

Get the ID of a replica machine: https://fly.io/apps/the-bot-db/monitoring

fly machine clone --region atl ##### -a the-bot-db

Removing DB regions:

fly machine stop -a the-bot-db ##### fly machine destroy -a the-bot-db #####

Find volume: https://fly.io/apps/the-bot-db/volumes fly volumes destroy -a the-bot-db #####

Changing DB memory

fly m update e82423eb073078 --vm-memory 256 -a the-bot-db

Changing DB swap

class Fly < SDK
  def key
    raise "self.key is undefined. You need to override this method."
  end

  def bearer_token
    `fly auth token`.chop
  end

  def get(url)
    SDK::Get.new(url, ->{ key }, ->{ bearer_token })
  end

  def post(url)
    SDK::Post.new(url, ->{ key }, ->{ bearer_token })
  end

  def patch(url)
    post(url)
  end
end

reload!; fly = Fly.new; config = fly.get("https://api.machines.dev/v1/apps/the-bot-db/machines/e82423eb073078").no_params.config
config.init.swap_size_mb = 512
new_config = fly.post("https://api.machines.dev/v1/apps/the-bot-db/machines/e82423eb073078").params({ config: config }).config

APP