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.
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?