runtimejs / runtime

[not maintained] Lightweight JavaScript library operating system for the cloud
http://runtimejs.org
Apache License 2.0
1.93k stars 128 forks source link

Environment Variables/Command Line Arguments #134

Open facekapow opened 7 years ago

facekapow commented 7 years ago

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?

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 commented 7 years ago

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"}}