Skip to content
This repository has been archived by the owner on Jul 3, 2020. It is now read-only.

Environment Variables/Command Line Arguments #134

Open
facekapow opened this issue Oct 28, 2016 · 1 comment
Open

Environment Variables/Command Line Arguments #134

facekapow opened this issue Oct 28, 2016 · 1 comment

Comments

@facekapow
Copy link
Contributor

This was brought to my attention by @aafrey on Gitter.

This is already kind of possible by using kernel command line arguments (--append and __SYSCALL.getCommandLine()), but it's neither officially supported nor elegant.

Why?

  • Well, servers need a way to use hidden variables, especially with open source server code
  • Also, it allows to quickly change a value when starting up a VM, instead of digging in to the code

How to pass them in?

  • Maybe another argument for runtime-cli
  • ...or maybe this could be another use for runtime.json

Problems with each implementation:

  • As an argument: there's no way to make it persistent (unless you script the running)
  • As a property in runtime.json: if you .gitignore it so that you don't accidentally leak the variables, you're also gitignoring a file that might contain settings you do want to commit (e.g. v8.flags)

Possible solution:

Implement both? That way, you can make unimportant variables persistent by adding them to runtime.json, while keeping ultimately secret variables as arguments.

How to get them?

Well, process.env!

@iefserge
Copy link
Member

iefserge commented Nov 6, 2016

Yeah, great idea!

I think passing env variables through command line is the best option. So the same initrd bundle can be used in different environments (development/production etc). runtime.js should probably not expose raw command line to the app, and we can remove --append option as well.

Running something like this:

runtime start -ENODE_ENV=production -ESECURE_KEY=abc

can internally do this:

runtime start --append={"env":{"NODE_ENV":"production","SECURE_KEY":"abc"}}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants