Machines now supports multiple processes within a VM. To use it, add processes
to your machines config. processes
has the structure:
"processes": [
{
"name": "web",
"entrypoint": ["/bin/bash", "-c"],
"cmd": ["some", "command"],
"env": {
"HELLO": "world"
},
"user": "flyio" // optional
},
{
"name": "logger",
"entrypoint": ["/bin/bash", "-c"],
"cmd": ["some", "other", "command"],
"env": {
"WORLD": "hello"
}
},
...
]
An example config
{
"config": {
"image": "senyo/watagwan:latest",
"processes": [
{
"name": "web",
"entrypoint": ["/bin/bash"],
"cmd": ["loop1.sh"],
"env": {
"PROC_ID": "1"
}
},
{
"name": "logger",
"entrypoint": ["/bin/bash"],
"cmd": ["loop2.sh"],
"env": {
"PROC_ID": "2"
}
}
],
"env": {
"VERSION": "1.2.3",
},
"services": [
{
"ports": [
{
"port": 443,
"handlers": [
"tls",
"http"
]
},
{
"port": 80,
"handlers": [
"http"
]
}
],
"protocol": "tcp",
"internal_port": 8080
}
]
}
}
This is a first iteration to supporting the sidecar pattern where each process has its own image and can run in its own process namespace.
That’s all there is to it. Now, here’s what you need to know:
- As mentioned above, processes run within the same VM. This is different than the
[processes]
directive in an app config. - When any of your processes exit/dies, the entire VM is shutdown.
- You can’t use a different image for each process (we’re working on this). Everything you need for each process to run must be contained within your docker image.
- Processes run in the same process namespace (we’re working on this too).
- Environment variables can be defined at a global scope and a process scope (see the
env
config option in theprocess
definition).
5.1. Each process will be spawned with the globally scoped environment variables and its process scoped environment variables. If the same environment variable is defined in at both scopes, the process scope wins.
5.2. When you SSH into a running machine, only the globally scoped environment variables are in the environment.
Give it some mileage and let us know if you run into any issues or have questions.