Help understanding fly machine configuration

Hello, I am trying to schedule a machine. I’m new to fly, and struggling a bit.

I have env vars and build parameters defined in my toml file. However, when the machine runs, it doesn’t find the env vars, and I can see it was built without the build parameters.

I tried specifying config path using -c in both fly deploy and fly m run, per the documentation (flyctl deploy · Fly Docs, flyctl machine run · Fly Docs)

fly deploy didn’t complain about -c, but fly m run did (-c: command not found).

fly m run also complained about -a-, -r, and –name`, all of which are included in the documentation.

Am I misunderstanding the documentation? How do I include my toml configuration in the image, or in the machine?

Here is the deploy command I am using to create the image:

flyctl deploy \
  --build-only \
  --push \
  -a <my app> \
  -c fly.toml \
  -r lax

Here is the machine command I am using to create the machine:

flyctl m run \
  <the image> \
   --schedule=hourly 
   --app <my app> \
   --name <my machine name>
   --config fly.toml

Any help is appreciated! TIA

Before I get into the meat of things, I want to give a brief overview of the differences between the apps platform (what you get with deploy) vs standalone machines (what you get with fly m [command]) You probably already know this! I just wanted to make sure we’re on the same page.

fly deploy and fly m run are pretty different - deploy is for the apps platform, which means it’s intended for an app where all of your machines run the same image and (usually) expose the same service.
fly m run is for machines, which is the building block for the apps platform, but a little bit lower level. There’s no fly.toml, for example, with just machines. The toml file is a description of an apps platform app, but fly m run sits at a level of abstraction below that.

Essentially, deploy/launch/fly apps [x] is for application hosting, and fly machine [x] is for VMs as a service.

With that out of the way:
there’s no easy way to get something from fly.toml into a standalone machine.
If you’re determined to use fly m run, you can pass -e ENVVAR=someval -e OTHERENV=newvalue to pass values to your machine.

Alternatively, you could just use fly deploy without --build-only --push, which would create machines as part of the apps platform, and sidestep the issue entirely.

As for fly m run complaining about -a, -r, and --name, that’s very strange. Do you happen to still have the console output logs for this? that’s definitely not right.

Thank you. I didn’t fully understand apps vs machines, so that was very helpful.

I don’t have the output saved, but it completed successfully, and at the bottom it printed out a line like this for each of those flags:
-c: command not found

FYI, I also specified -e name=value when I was experimenting, and got the same “command not found” error. The command was basically:

flyctl m run \
  <the image> \
  --schedule=hourly 
  -e SEND_EMAIL=true

at risk of interpreting pseudocode as real commands, I have to ask: could it just be that you were missing a backslash after --schedule=hourly to escape that newline?

Definitely possible. I was trying a 100 different things, so I could have easily messed that up and not noticed.

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