Setting a minimum number of instances to keep running when using auto start/stop

@senyo this has been working pretty well. But i noticed that it does not respect process groups.

app = "brick-drop-co"
primary_region = "ord"

[build]
  strategy = "canary"

[processes]
  web = "litefs mount -config /etc/litefs.web.yml"
  dir = "litefs mount -config /etc/litefs.directus.yml"

#[http_service]
#  internal_port = 8080
#  force_https = true
#  auto_stop_machines = true
#  auto_start_machines = true
#  min_machines_running = 1
#  processes = ["web"]
#
#  [http_service.concurrency]
#    type = "connections"
#    hard_limit = 50
#    soft_limit = 25
#
#  [http_service.http_options.response.headers]
#    X-Process-Group = "web"
#    X-Frame-Options = "SAMEORIGIN"
#    X-XSS-Protection = "1; mode=block"
#    X-Content-Type-Options = "nosniff"
#    Referrer-Policy = "strict-origin-when-cross-origin"
#    Content-Security-Policy = "default-src 'self' 'unsafe-inline' 'unsafe-eval' data:; img-src * data:; font-src * data:; style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'; connect-src *; frame-src *; object-src *; media-src *; child-src *; form-action *; frame-ancestors *; block-all-mixed-content; upgrade-insecure-requests; manifest-src *; worker-src *; prefetch-src *;"
#
#  [[http_service.checks]]
#    grace_period = "240s"
#    interval = "120s"
#    method = "GET"
#    timeout = "10s"
#    path = "/"

[[services]]
  internal_port = 8080
  protocol = "tcp"
  auto_stop_machines = true
  auto_start_machines = true
  min_machines_running = 1
  processes = ["web"]

  [[services.http_checks]]
    interval = "15s"
    grace_period = "5s"
    method = "get"
    path = "/"
    protocol = "http"
    timeout = "5s"
    tls_skip_verify = true

  [[services.ports]]
    handlers = ["http"]
    port = 80
    force_https = true
    [services.ports.http_options.response.headers]
      X-Process-Group = "web"

  [[services.ports]]
    handlers = ["tls", "http"]
    port = 443
    [services.ports.http_options.response.headers]
      X-Process-Group = "web"

[[services]]
  internal_port = 8054
  protocol = "tcp"
  auto_stop_machines = true
  auto_start_machines = true
  min_machines_running = 1
  processes = ["dir"]

  # TODO: remove this once we have a way to set up a TCP service
  [[services.ports]]
    handlers = ["http"]
    port = 3000
    force_https = false
    [services.ports.http_options.response.headers]
      X-Process-Group = "dir"

  [services.concurrency]
    type = "connections"
    hard_limit = 25
    soft_limit = 20

  [[services.http_checks]]
    interval = "15s"
    grace_period = "5s"
    method = "get"
    path = "/admin/login"
    protocol = "http"
    timeout = "5s"
    tls_skip_verify = true

[checks]
  [checks.dir]
    grace_period = "5s"
    interval = "15s"
    method = "get"
    path = "/admin/login"
    port = 8054
    timeout = "5s"
    type = "http"
    processes = ["dir"]

[mounts]
  source = "litefs"
  destination = "/var/lib/litefs"
  processes= ["web", "dir"]

[metrics]
  port = 9091       # default for most prometheus clients
  path = "/metrics"

I can’t use the http_service because of another issue (Hanging on 'Configuring firecracker" in ORD - #5 by Zane_Milakovic), so ignore that.

But as you can see each service has min_machines_running = 1.

When I have only 2 VMs in the app, this shows -

ord [info] Downscaling app brick-drop-co in region ord from 2 machines to 1 machines. Automatically stopping machine 080e442c5405d8

As you can see, it’s my primary region, and it has ports. I know I can connect too it externally.

Luckily the one it shuts down, is the one that starts up fast. Not sure why it picks web to be the process group that shuts down. Maybe its deploy order?

But it’s not respected, and thinking about setting minimum to 2.

About to clone and setup HA, and add another region, so have not tried this yet, but wanted to report the bug for you all.

1 Like