Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support unix socket for HTTP #172

Closed
domenkozar opened this issue Apr 2, 2024 · 12 comments
Closed

Support unix socket for HTTP #172

domenkozar opened this issue Apr 2, 2024 · 12 comments
Labels
done Done, awaiting release enhancement New feature or request

Comments

@domenkozar
Copy link

See cachix/devenv#1091

@F1bonacc1
Copy link
Owner

F1bonacc1 commented Apr 2, 2024

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?

@domenkozar
Copy link
Author

Currently port 9999 is opened and I would like to see support for UNIX sockets, so that multiple process-compose can run in parallel.

@thenonameguy
Copy link
Contributor

thenonameguy commented Apr 3, 2024

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.

@adrian-gierakowski
Copy link
Contributor

You can run multiple instances of PC at different ports

@thenonameguy
Copy link
Contributor

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:
cachix/devenv#1091 (comment)

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.

@thenonameguy
Copy link
Contributor

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
Loading

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.

@F1bonacc1
Copy link
Owner

F1bonacc1 commented Apr 3, 2024

To sum up:

  1. The default behavior will be port based.
  2. I will provide a flag to start with UDS with ports disabled.
  3. The socket file name is optional (?).
  4. 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).

@F1bonacc1 F1bonacc1 added enhancement New feature or request need more info labels Apr 3, 2024
@adrian-gierakowski
Copy link
Contributor

If PC decides a random socket file, how would the client know which file to use when connecting?

@thenonameguy
Copy link
Contributor

thenonameguy commented Apr 4, 2024

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.

@domenkozar
Copy link
Author

domenkozar commented Apr 5, 2024

To sum up:

  1. The default behavior will be port based.
  2. I will provide a flag to start with UDS with ports disabled.
  3. The socket file name is optional (?).
  4. 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.

@F1bonacc1 F1bonacc1 added done Done, awaiting release and removed need more info labels Apr 6, 2024
@F1bonacc1
Copy link
Owner

Added in v1.2.0

@domenkozar
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
done Done, awaiting release enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants