Heroku to Fly Migration with problem

I migrated my data from Heroku, which I use to show diabetes data in the Nightscout, to Fly with the tool provided by Fly (Heroku · Launch on Fly.io). After running for a long time and restartin several times, apparently it worked as it created an address with my name on Fly but the page does not display anything. The message in the browser it says “may be temporarily unavailable or may have been moved permanently”. Any idea what it could be?

When deploy, appear this type of errors

fly1

Hi @anapfb

I actually helped a friend with a Nightscout web monitor migration last week. See if the walk-through below helps.

Nightscout on Fly.io

Fly.io

Install flyctl:

Setup Fly.io account:

Setup MongoDB

Follow these instructions for creating MongoDB, Create an Atlas database. This is not required if migrating from Heroku, etc.

It should resemble:

mongodb+srv://username:password@deployment.mongodb.net/?retryWrites=true&w=majority

It will be used as MONGODB_URI in the app environment below.

Clone the Nightscout web monitor:

git clone https://github.com/nightscout/cgm-remote-monitor

Change working directory to cgm-remote-monitor

cd cgm-remote-monitor

Create a new Fly app:

fly apps create YOUR-UNIQUE-APP-NAME-GOES-HERE

Create the app configuration file:

Save the following to fly.toml

app = "<YOUR-UNIQUE-APP-NAME-GOES-HERE>"

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

[env]
  PORT = "8443"
  THEME="color"
  BASE_URL = "<YOUR-UNIQUE-APP-NAME-GOES-HERE>.fly.dev"
  DISPLAY_UNITS = "mg/dl"
  INSECURE_USE_HTTP = "true"
  MONGODB_COLLECTION = "entries"
  
[[services]]
  internal_port = 8443
  processes = ["app"]
  protocol = "tcp"
  script_checks = []

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

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

  [[services.http_checks]]
    interval = 30000
    grace_period = "5s"
    method = "get"
    path = "/"
    protocol = "http"
    restart_limit = 5
    timeout = 5000
    tls_skip_verify = false
    [services.http_checks.headers]

Create Nightscout API Secret

Create a secret passphrase, must be at least 12 characters.

It will be used as API_SECRET in the app environment below.

Add secrets to the app environment:

Adjust as needed. Further documentation can be found here

fly secrets set API_SECRET="<YOUR-UNIQUE-API-SECRET>" \
 MONGODB_URI="<YOUR-MONOGDB-URI-FROM-ATLAS>"

Allocate a public IP:

flyctl ips allocate-v4

Deploy the app:

fly deploy

Open app

fly open

@dusty

In fact, I prefer to migrate straight from Heroku to bring the history but if I can’t, I’ll do as you indicated. Your tutorial is really cool and easy to understand.

Thanks a lot!

Sounds good but I think all your history is in the DB. You could try reusing the MongoDB url from your Heroku app to verify.

2 Likes

I gave up on migrating automatically. I’ll do as dusty suggested.

Some questions:

What is the purpose of this?

cd cgm-remote-monitor

It seems to me that the steps work the same if I don’t change, as I was able to create the app without changing.

I created the app with flyctl launch and not with fly create. What’s the difference?

How to edit fly.toml and include this information?

cd cgm-remote-monitor simply changes your working directory to where the needed files ( ie: Dockerfile ) are located in order to create the application. Once in this directory you will need to create a new fly.toml file using your favorite text editor with the information from the walkthrough. Fly.toml docs

Thanks @dusty for your help!!!

I created fly.toml by launching flyctl but the only information created was the app (created the app) and the region. The rest of the information you said to create was not created. The release did not ask for this information. And obviously it looks like they are missing because Deploy fails. So I need to edit the fly.toml to include it but that link doesn’t say how to edit it.

The fly.toml file exists locally and is read by flyctl. By running fly launch it should’ve been created automatically for you ( on your local system ) .

Now, simply open the file in a text editor and copy/paste details from walkthrough ( updating app name where specified ). Once this is done run flyctl deploy.

Is port 8443 required? Keep receiving:
[info][GIN-debug] Listening and serving HTTP on :8080
→ v0 failed - Failed due to unhealthy allocations

Update:
I changed my toml file to port 8080, deployment went through and everything works fine!
Awesome instructions, thanks a lot :slight_smile:

1 Like