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

Implement -t flag from docker run (pseudo-terminal support) #64

Open
thenonameguy opened this issue Jul 5, 2023 · 5 comments
Open

Implement -t flag from docker run (pseudo-terminal support) #64

thenonameguy opened this issue Jul 5, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@thenonameguy
Copy link
Sponsor Contributor

thenonameguy commented Jul 5, 2023

Feature Request

Certain processes check if they are running within a terminal (bound std* streams, TERM env var, etc.)
A request came up on the devenv Discord to have a similar functionality to docker-compose, which simulates TTYs by default.

Use Case:

Running tailwindcss --watch via process-compose should not exit (as the underlying esbuild process checks for a pseudo-TTY).

Proposed Change:

Who Benefits From The Change(s)?

@jcf

Potentially could allow supplying stdin input in the TUI to interactive processes (shells).

Alternative Approaches

@F1bonacc1
Copy link
Owner

Hey @thenonameguy,

I was looking for something like this. I will give it a try.
It lacks Windows support, but I think I can work around that.

@thenonameguy
Copy link
Sponsor Contributor Author

thenonameguy commented Jul 6, 2023

Are you planning a similar approach? creack/pty#169
Might be worthwhile to contribute it to the pty upstream and integrate it into PC.

EDIT: some1 already wrapped it in Go: https://github.com/UserExistsError/conpty

@babariviere
Copy link

babariviere commented Nov 4, 2023

As a workaround, you can use socat like this:

processes:
  tailwind:
    command: socat - EXEC:'tailwindcss --watch',pty,setsid,ctty

It will create a fake tty for the process (in this case tailwind).

You can also use unbuffer from expect package.

processes:
  tailwind:
    command: unbuffer tailwindcss --watch

@thenonameguy
Copy link
Sponsor Contributor Author

thenonameguy commented Feb 14, 2024

I quite like the socat approach. Maybe we could support the https://docs.docker.com/engine/reference/commandline/compose_exec/ -T functionality with it, defaulting to false still.

So process-compose could alter the exec command if a tty: true option is set for a given process.
This could wrap the original command in a OS-specific wrapper script, that has a nice message to install socat, when it is missing in the environment.

@F1bonacc1
Copy link
Owner

Initial (no windows or STDIN) support was added in v0.88.0.
https://f1bonacc1.github.io/process-compose/configuration/#misc

I will keep it open to gather some feedback.

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

No branches or pull requests

3 participants