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

Sail commands don't exit correctly on quit #42

Open
dshafik opened this issue Dec 22, 2024 · 15 comments
Open

Sail commands don't exit correctly on quit #42

dshafik opened this issue Dec 22, 2024 · 15 comments

Comments

@dshafik
Copy link
Contributor

dshafik commented Dec 22, 2024

When running sail commands e.g. sail up inside Solo (Solo is running on the host, not inside sail), and quitting Solo, the sail command don't terminate.

This means that a command of sail npm run dev leaves vite running inside the container and when starting Solo again it won't start as the port is already in use.

I suspect that each command needs to be sent an explicit SIGTERM or SIGKILL when q is pressed inside the Solo UI.

@dshafik
Copy link
Contributor Author

dshafik commented Dec 22, 2024

I have figured out why this is happening… docker compose doesn't kill the process in the container on SIGTERM, only the docker command itself it seems. I think this is because when you do a Ctrl+C in the terminal, that is being forwarded to the underlying npm (or whatever) command which then exits and the docker process dies automatically.

You get this exact same behavior if you run docker compose exec with the -T flag (e.g. docker compose exec -T <container> <command>):

  -T, --no-TTY docker compose exec   Disable pseudo-TTY allocation. By default docker compose exec allocates
                                     a TTY.

To be clear, this isn't really an issue with Solo, but it should be documented that commands that expect a TTY (like docker/sail) cannot be used with Solo.

@aarondfrancis
Copy link
Collaborator

Hmm... I don't use Sail so I don't fully understand what's happening here. So when Solo tries to kill the process it just kills the docker compose process on the host machine and not the process inside of docker? Is there a way to kill that underlying process? It'd be nice if it just worked with Solo

@dshafik
Copy link
Contributor Author

dshafik commented Dec 24, 2024

So when Solo tries to kill the process it just kills the docker compose process on the host machine and not the process inside of docker?

Exactly. This isn't unique to sail but illustrative of a problem with a common Laravel tool lots of folks will be familiar with .

Is there a way to kill that underlying process? It'd be nice if it just worked with Solo

There are no easy solutions here, you either need to implement a virtual TTY in PHP, or spawn the process under another tool that does so.

@aarondfrancis
Copy link
Collaborator

All processes are now spawned with a PTY. Does this get us any closer?

@dshafik
Copy link
Contributor Author

dshafik commented Jan 31, 2025

@aarondfrancis This doesn't solve the issue in this ticket. This arguable makes things worse, any command that can take input will now stop solo from receiving the keyboard input (e.g. sail up and then you can't change tabs with the arrow keys).

@aarondfrancis
Copy link
Collaborator

Haha dang. Well I'd you have any ideas let me know!

@dshafik
Copy link
Contributor Author

dshafik commented Jan 31, 2025

@aarondfrancis I would roll back this change ASAP

@aarondfrancis
Copy link
Collaborator

Sorry, that's not viable at this point. If you can get me a reproduction I can look into it. I don't use sail though so you'll need to be explicit

@dshafik
Copy link
Contributor Author

dshafik commented Jan 31, 2025

@aarondfrancis any command that expects input will work, so sudo echo "Hello World" should do it (so long as it asks for your password)

@aarondfrancis
Copy link
Collaborator

Cool, thank you!

@aarondfrancis
Copy link
Collaborator

Ok I've got the sudo echo "Hello World" example working in #50, but I haven't had a chance to test it very thoroughly. I put screen in the middle and that seems to be working quite nicely!

@aarondfrancis
Copy link
Collaborator

@dshafik can you composer install that branch reference and see if it works for Sail?

@dshafik
Copy link
Contributor Author

dshafik commented Jan 31, 2025

@aarondfrancis this is way closer! With sail up (basically docker compose up) it doesn't allow input but it doesn't block moving between tabs (this is fine!). With sail npm run dev it still doesn't kill correct so it won't restart, but if I use sail npm run dev && sail exec beacon killall node as the command I can hit restart twice and it works, which is a big step forward.

It also solved an issue running sail pest (it would break the frame and then redraw after it was done, I suspect similar to ngrok that you mentioned had issues before).

At this point it's totally usable for me.

@aarondfrancis
Copy link
Collaborator

We're getting somewhere! If you want to allow input, you can try

Command::from('sail up')->interactive() and then hit i to go interactive.

@aarondfrancis
Copy link
Collaborator

aarondfrancis commented Feb 19, 2025

@dshafik I just cut a new release. Will you give it a go an let me know what you think? And if all is well can we close this one?

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

No branches or pull requests

2 participants