How do you keep a service running forever?

The below is an example of a suite of apps deployed on Fly. They are non-public services that only listen to pubsub streams and index data. However, they have been suspending after a period of time ranging from 1 hour to 12 hours.

They will always suspend gracefully, without any of my code being the culprit.

app = 'x'
primary_region = 'iad'

  cmd = ['./tfi']


  internal_port = 8080
  force_https = true
  auto_stop_machines = false
  auto_start_machines = true
  min_machines_running = 2
  processes = ['app']

  size = 'shared-cpu-8x'

Even with such a configuration, the instances would keep terminating. Not sure why, but my logs clearly show that there was a termination command sent (Graceful shutdown). Are we missing anything in our configuration, thanks!

Been attempting various tactics like the auto_start_machines option and keeping 2 instances running rather than 1.

2024-04-07T02:55:00.530 app[x] iad [info] Application stopped

2024-04-07T02:55:00.867 app[x] iad [info] INFO Main child exited normally with code: 0

2024-04-07T02:55:00.880 app[x] iad [info] INFO Starting clean up.

2024-04-07T02:55:00.881 app[x] iad [info] [x] reboot: Restarting system

2024-04-07T02:55:01.022 runner[x] iad [info] machine exited with exit code 0, not restarting

We have plenty of people running apps “forever”. Our Shipping Logs · The Fly Blog app is an example of a non-public service that listen to pubsub streams.

The key to running forever is to not exit, and the logs you posted indicated that that is what is happening here.

What are the ENTRYPOINT and/or CMD in your Dockerfile?

1 Like

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