mikelangelo-project / osv-microservice-demo

Simple Node.js Microservice application use to demonstrate the use of OSv and Capstan
13 stars 1 forks source link

Provide meta/run.yaml to simplify running #6

Closed miha-plesko closed 7 years ago

miha-plesko commented 7 years ago

While trying to provide meta/run.yaml to run this application I've encountered an annoying problem: keyvaluestore endpoint is not known on build time. So I would like to discuss how should we proceed. What one can do at the moment is:

# generate scripts in /run/...
$ capstan package compose micro

# set boot command to `runscript /run/master`
$ capstan run micro --boot master

# equivalent:
$ capstan run micro --execute "runscript /run/master"

# if I want to set environment variable I can do it like this
$ capstan run micro --execute "--env=MICRO_KEYVALUESTORE_ENDPOINT=172.16.1.205:9000 runscript /run/master"

What I'm thinking is that we should upgrade Capstan to be able to generate command with env variable:

# does not work yet, the --env flag needs to be implemented:
$ capstan run micro --boot master --env=MICRO_KEYVALUESTORE_ENDPOINT=172.16.1.205:9000

What do you think?

miha-plesko commented 7 years ago

@gberginc I'm asking upfront since I'm not sure if we should hack it like this or should we go into using cloud-init by Capstan and passing environment variables there.

gberginc commented 7 years ago

One of the things we've discussed in the past is how we should handle "run config options". I think this is one of the cases where this would be handy. Your proposal to expose --env as a separate cmd option that is then built into the run command is reasonable as we should not bother users with having to know that runscript OSv loader command exists at all.

The alternative that I see is that we use some sort of template variables (not sure, but perhaps {IP} in this example is something like this?). This would then construct the run command script with placeholders that could be replaced in the runtime, however I don't think there are real benefits over the env variables.

miha-plesko commented 7 years ago

I've removed [WIP] prefix from this PR since it is safe to merge it as it is.