Multiple processes: want to set process specific environment variables, but deployment fails because of missing command

I want to create multiple processes with specific environment variables per process. I could not find anything in the documentation, but looking at this topic, I thought the following would work:

...
[[processes]]
  name = 'web'
  entrypoint = ["/entrypoint"]
  cmd = ['']
  [[processes.env]]
  DD_SERVICE='web'

[[processes]]
  name = 'worker'
  entrypoint = ["/entrypoint"]
  cmd = ['supervisord -c /etc/supervisord.conf']
  [[processes.env]]
  DD_SERVICE='worker'

[[processes]]
  name = 'scheduler'
  entrypoint = ["/entrypoint"]
  cmd = ['cron -f']
  [[processes.env]]
  DD_SERVICE='scheduler'
...

When I deploy this, I get the following message:

==> Creating release
Error You specified a process for '{"cmd"=>[""], "entrypoint"=>["/entrypoint"], "env"=>[{"DD_SERVICE"=>"web"}], "name"=>"web"}' but it does not have a command defined. Double check the syntax for the [processes] section of your fly.toml https://fly.io/docs/reference/configuration/#the-processes-section

I saw on this topic that there were previously issues with cmd being defined as an empty string, could that be the case here as well? Or am I understanding the usage of this part of fly.toml completely wrong?

For reference, the current working config is as follows:

[processes]
  web = ''
  worker = 'supervisord -c /etc/supervisord.conf'
  scheduler = 'cron -f'
1 Like

That config is actually for machines, which is different than fly.toml (which is for Fly Apps). They aren’t quite the same. I know this is confusing.

There’s currently no way to set different env vars for different process types in an app. You’d need to run two apps for that.

If you only need, like, one env var, you could try this:

[processes]
  web = ''
  worker = 'MY_VAR=test supervisord -c /etc/supervisord.conf'
  scheduler = 'MY_VAR=test2 cron -f'
3 Likes

I see, I misread then. The snippet you shared won’t work, because the command is appended to the entrypoint, leading to something like /entrypoint ENV=var cron -f.

Do you have any idea if the kind of functionality I am looking for is to be expected some time?

Thanks for your help anyway.

I managed to figure it out, maybe someone will need it.

[processes]
  app = "some_command"
  worker = "bash -c 'MY_ENV=some_value another_command'"

You can do the action of the entry point in the command, and remove the entrypoint from the docker container, and instead have a CMD there you intent to replace. Worked for me.