Deploying two apps in the same organisation

There seems to be some sort of issue doing this for me, I have two SvelteKit applications and I got one deployed a month ago, now I try to deploy another in the same organisation and the health check keep on failing even though I’m using the exact same setup as the existing app which is working in that organisation. I have however noticed that the image from the fly registry seem to reference some parts of the other app when it’s pushing the image for the new app.

I think there needs to be more guide on how to handle multiple app deployment on the platform.

Hi,

Could you show the toml files for both apps, and env setup too, if any.
Some example logs/entries of the build/deploy process and the subsequent logs should also help.

So I destroyed both apps and tried to launch the original one that was working before again, now it too won’t start. The toml for this app is

# fly.toml file generated for lnkd on 2021-12-31T13:13:31Z

app = "lnkd"

kill_signal = "SIGINT"
kill_timeout = 5
processes = []

[env]
  PORT = "8080"

[experimental]
  allowed_public_ports = []
  auto_rollback = true

[[services]]
  http_checks = []
  internal_port = 8080
  processes = ["app"]
  protocol = "tcp"
  script_checks = []

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

  [[services.ports]]
    handlers = ["http"]
    port = 80

  [[services.ports]]
    handlers = ["tls", "http"]
    port = 443

  [[services.tcp_checks]]
    grace_period = "1s"
    interval = "15s"
    restart_limit = 6
    timeout = "2s"

I’m using a Docker file for the build process, here is the content of the Dockerfile

# Install dependencies only when needed
FROM node:alpine AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN npm install -g pnpm
RUN pnpm install --frozen-lockfile

# Rebuild the source code only when needed
FROM node:alpine AS builder
WORKDIR /app
COPY . .
COPY --from=deps /app/node_modules ./node_modules
ARG VITE_SUPABASE_URL
ARG VITE_SUPABASE_ANON_KEY
ARG VITE_PUBLIC_APP_LINK_URL
ENV VITE_SUPABASE_URL=$VITE_SUPABASE_URL
ENV VITE_SUPABASE_ANON_KEY=$VITE_SUPABASE_ANON_KEY
ENV VITE_PUBLIC_APP_LINK_URL=$VITE_PUBLIC_APP_LINK_URL
ENV NODE_ENV=production
RUN echo $NODE_ENV
RUN echo $VITE_PUBLIC_APP_LINK_URL
RUN echo $VITE_SUPABASE_URL
RUN echo $VITE_SUPABASE_ANON_KEY
RUN npm install -g pnpm
RUN pnpm build && pnpm install --prod --ignore-scripts --prefer-offline

# Production image, copy all the files and run next
FROM node:alpine AS runner
WORKDIR /app

ENV NODE_ENV production
RUN echo $NODE_ENV
# RUN addgroup -g 1001 -S nodejs
# RUN adduser -S nextjs -u 1001

COPY --from=builder /app/build ./build
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json

EXPOSE 3000
CMD ["npm", "run", "start"]

The logs currently look like

2021-12-31T13:19:00.586 runner[2632c003] fra [info]Starting instance
2021-12-31T13:19:00.620 runner[2632c003] fra [info]Configuring virtual machine
2021-12-31T13:19:00.621 runner[2632c003] fra [info]Pulling container image
2021-12-31T13:19:05.803 runner[2632c003] fra [info]Unpacking image
2021-12-31T13:19:08.036 runner[2632c003] fra [info]Preparing kernel init
2021-12-31T13:19:08.410 runner[2632c003] fra [info]Configuring firecracker
2021-12-31T13:19:08.557 runner[2632c003] fra [info]Starting virtual machine
2021-12-31T13:19:08.691 app[2632c003] fra [info]Starting init (commit: 7943db6)...
2021-12-31T13:19:08.708 app[2632c003] fra [info]Preparing to run: `docker-entrypoint.sh node ./build` as root
2021-12-31T13:19:08.719 app[2632c003] fra [info]2021/12/31 13:19:08 listening on [fdaa:0:34db:a7b:23c3:2632:c003:2]:22 (DNS: [fdaa::3]:53)
2021-12-31T13:19:09.117 app[2632c003] fra [info]Listening on 0.0.0.0:3000
2021-12-31T13:25:15.672 runner[7033f4e6] cdg [info]Starting instance
2021-12-31T13:25:15.701 runner[7033f4e6] cdg [info]Configuring virtual machine
2021-12-31T13:25:15.702 runner[7033f4e6] cdg [info]Pulling container image
2021-12-31T13:25:19.687 runner[7033f4e6] cdg [info]Unpacking image
2021-12-31T13:25:26.941 runner[7033f4e6] cdg [info]Preparing kernel init
2021-12-31T13:25:27.862 runner[7033f4e6] cdg [info]Configuring firecracker
2021-12-31T13:25:28.054 runner[7033f4e6] cdg [info]Starting virtual machine
2021-12-31T13:25:28.174 app[7033f4e6] cdg [info]Starting init (commit: 7943db6)...
2021-12-31T13:25:28.191 app[7033f4e6] cdg [info]Preparing to run: `docker-entrypoint.sh node ./build` as root
2021-12-31T13:25:28.200 app[7033f4e6] cdg [info]2021/12/31 13:25:28 listening on [fdaa:0:34db:a7b:5b66:7033:f4e6:2]:22 (DNS: [fdaa::3]:53)
2021-12-31T13:25:28.577 app[7033f4e6] cdg [info]Listening on 0.0.0.0:3000
2021-12-31T13:25:55.946 proxy[7033f4e6] cdg [error]Health check status changed 'passing' => 'critical'
2021-12-31T13:30:30.627 runner[7033f4e6] cdg [info]Shutting down virtual machine
2021-12-31T13:30:30.740 app[7033f4e6] cdg [info]Sending signal SIGINT to main child process w/ PID 510
2021-12-31T13:30:31.742 app[7033f4e6] cdg [info]Main child exited with signal (with signal 'SIGINT', core dumped? false)
2021-12-31T13:30:31.742 app[7033f4e6] cdg [info]Starting clean up.
2021-12-31T13:41:14.150 runner[702dafc9] cdg [info]Starting instance
2021-12-31T13:41:14.177 runner[702dafc9] cdg [info]Configuring virtual machine
2021-12-31T13:41:14.179 runner[702dafc9] cdg [info]Pulling container image
2021-12-31T13:41:16.238 runner[702dafc9] cdg [info]Unpacking image
2021-12-31T13:41:16.243 runner[702dafc9] cdg [info]Preparing kernel init
2021-12-31T13:41:16.981 runner[702dafc9] cdg [info]Configuring firecracker
2021-12-31T13:41:17.109 runner[702dafc9] cdg [info]Starting virtual machine
2021-12-31T13:41:17.221 app[702dafc9] cdg [info]Starting init (commit: 7943db6)...
2021-12-31T13:41:17.238 app[702dafc9] cdg [info]Preparing to run: `docker-entrypoint.sh npm run start` as root
2021-12-31T13:41:17.249 app[702dafc9] cdg [info]2021/12/31 13:41:17 listening on [fdaa:0:34db:a7b:5b66:702d:afc9:2]:22 (DNS: [fdaa::3]:53)
2021-12-31T13:41:17.938 app[702dafc9] cdg [info]> lnkd@0.0.1 start
2021-12-31T13:41:17.938 app[702dafc9] cdg [info]> node build/index.js
2021-12-31T13:41:18.215 app[702dafc9] cdg [info]Listening on 0.0.0.0:3000
2021-12-31T13:46:28.954 runner[702dafc9] cdg [info]Shutting down virtual machine
2021-12-31T13:46:29.067 app[702dafc9] cdg [info]Sending signal SIGINT to main child process w/ PID 510
2021-12-31T13:46:30.068 app[702dafc9] cdg [info]Main child exited with signal (with signal 'SIGINT', core dumped? false)
2021-12-31T13:46:30.069 app[702dafc9] cdg [info]Starting clean up.
  1. Could you try with a grace_period of 10s, and then tighten it up till it fails.
    Can also generally use fly checks list
    https://fly.io/docs/getting-started/troubleshooting/#health-checks-failing

  2. Don’t know if the below matters, but worth correcting?
    Should be ENV key=value right? That is, a missing =

I literally don’t know what changed but I destroyed the apps again and deployed them and they seem to be working now. I haven’t done any code change so not sure what is going on.

1 Like

Great stuff, it could still be the grace_period, as completing the build-out within 1s can be a hit or miss. Of course, will let someone else also weigh in, but that’d be the first thing to bump up if you see similar behaviour again.

BTW, Happy New Year!