Auto start/stop with SSH

Hey gang, I am hosting a gitea instance (basically open source github), which can be connected to via HTTPS or SSH. Given that this is my private version control, I don’t need it running 24/7 and would like to have it scale down when it is idle. Here’s the pertinent part of my fly.toml:

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

[[services]]
  internal_port = 2222
  protocol = "tcp"
  auto_stop_machines = 'stop'
  auto_start_machines = true
  
  [[services.ports]]
    port = 22

The HTTP portion of this works for another app I have, but unfortunately this does not appear to actually scale the app down, and I’m guessing it has something to do with the services section I added to get SSH to work. Any idea where I might have gone wrong?

Hm… I just tried a nearly identical configuration myself and it worked fine (auto-scaling to zero after ~8 minutes)…

app = "qua-melon"
primary_region = "ewr"
swap_size_mb = 512

[http_service]
  internal_port = 3000
  auto_stop_machines = "stop"
  auto_start_machines = true
  min_machines_running = 0
  processes = ["app"]

[[services]]
  internal_port = 2222
  protocol = "tcp"
  auto_stop_machines = "stop"
  auto_start_machines = true
  [[services.ports]]
    port = 22

A fly config validate --strict is generally a good idea whenever you see puzzling behavior on the Fly.io platform, particularly when it involves auto-scaling.

Also, I’d check the metrics in Grafana to make sure there aren’t spurious connections that you were unaware of. Your port 22 means that you probably have a dedicated IP address, and that could be a magnet for bot traffic, :honey_pot:

Hope this helps a little!


Aside: You can manually scale down with fly m stop. I do this with a similar Machine that I have—i.e., one that’s only for personal tinkering. It’s less convenient, but it’s easy to encapsulate it into a small local Bash script.

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