Closed domenkozar closed 7 months ago
Hey @domenkozar,
Can you please explain what is the ask here?
Maybe the flag --no-server
to disable the process-compose server can help?
Process Compose should run on Windows. Is the proposal to maintain both ports and UNIX sockets?
Currently port 9999 is opened and I would like to see support for UNIX sockets, so that multiple process-compose can run in parallel.
What Domen is asking for really is a file-based socket, that is easy to spawn more of, without conflict (think tmpfile in a pre-specified folder).
The port 9999 is just a default value for devenv as the current default port commonly conflicts with other HTTP servers.
Support should be added to the process-compose CLI as well to use this method of communicating, by accepting the file path as an env var/explicit arg.
Is the proposal to maintain both ports and UNIX sockets?
Yes.
Maybe the flag --no-server to disable the process-compose server can help?
That helps for the short term, but it's common to have multiple devenv instances running in parallel (subfolders in a monorepo with different process graphs).
The --no-server
would band-aid the problem, but losing CLI/RPC access would be not a good tradeoff.
You can run multiple instances of PC at different ports
You can run multiple instances of PC at different ports
Thanks, but this is clear to everyone, see the original reply from @domenkozar from yesterday: https://github.com/cachix/devenv/issues/1091#issuecomment-2031063105
To be able to provide an automatic way in devenv to not have port conflicts (without remembering which ports are taken), a file-based socket with a random name allows an external wrapper of process-compose to handle this.
graph TD
subgraph project1[Random Project 1]
devenv-1[devenv]
process-compose-1[Process Compose port 9999]
devenv-1 --> process-compose-1
end
subgraph project2[Random Project 2]
devenv-2
process-compose-2[Process Compose port 9999]
devenv-2 --> process-compose-2
end
The goal would be to support running 2 random projects at the same time on the same host, without modifying anything. Think of picking 2 random devenv/process-compose projects of of Github.
To sum up:
Question: If no socket file name is provided should the default be random: /tmp/process-compose-<random>.sock
or predefined: /tmp/process-compose.sock
?
Random advantage:
Predefined advantage:
If PC decides a random socket file, how would the client know which file to use when connecting?
Here's how the Clojure NREPL server solves it (that does random port assignment):
It randomly chooses an open available port at runtime and writes the number to a gitignored .nrepl-port
file.
Clients then always look at that file (or the closest file like by walking up the FS tree) to know which port to connect to.
A similar approach could be done with the UDS (.process-compose-uds
), although with the above, it might not even be necessary.
To sum up:
- The default behavior will be port based.
- I will provide a flag to start with UDS with ports disabled.
- The socket file name is optional (?).
- The UDS mode won't be available on Windows.
Question: If no socket file name is provided should the default be random:
/tmp/process-compose-<random>.sock
or predefined:/tmp/process-compose.sock
?Random advantage:
- Can start multiple projects with 0 configuration.
Predefined advantage:
- Clients can connect without additional flags (except UDS mode).
What's important for devenv is to be able to specify the socket path, as we want to store it into $DEVENV_RUNTIME
to avoid long paths that sockets are sensitive to.
Something like defaulting to $TMPDIR/process-compose-{pid}.pid
and being to override it with $PC_SOCKET_PATH
would be ideal.
Added in v1.2.0
Thank you!
See https://github.com/cachix/devenv/issues/1091