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

lucky dev Ctrl+C does not wait until the process manager exits #570

Closed
ZimbiX opened this issue Nov 1, 2020 · 0 comments · Fixed by #572
Closed

lucky dev Ctrl+C does not wait until the process manager exits #570

ZimbiX opened this issue Nov 1, 2020 · 0 comments · Fixed by #572

Comments

@ZimbiX
Copy link
Contributor

ZimbiX commented Nov 1, 2020

When I run lucky dev and at any point press Ctrl+C to stop it, sometimes the output is unclean, still logging process exits after my next terminal prompt has shown. This seems to be due to lucky dev not waiting for the process manager to exit when it receives the SIGINT signal.

It's most evident when using Foreman, since it's a bit slower to react to Ctrl+C than Overmind. Without a way to select the process manager in use, I've been forcing use of foreman by disabling my binaries which have higher priority:

sudo mv /usr/bin/overmind /usr/bin/overmindx
sudo mv /usr/local/bin/heroku /usr/local/bin/herokux

Example:

Screenshot from 2020-11-01 17-25-06

It looks like a fix would involve catching the interrupt before running the process manager

Signal::INT.trap do
  puts "Int"
end

Process.run("foreman", ["start", "-f", "Procfile.dev"], output: STDOUT, error: STDERR)

which works:

Screenshot from 2020-11-01 17-28-45

I reckon this could be added here:

private def run(process, args)
process.run command, args,
output: STDOUT,
error: STDERR,
shell: true
end

I'll start working on a PR.

ZimbiX added a commit to ZimbiX/lucky_cli that referenced this issue Nov 1, 2020
…le the signal and finish - rather than us immediately exiting and leaving it to log shutting down messages from the background

Resolves luckyframework#570. I've just used the approach I suggested there.

I wasn't sure how/if to write a spec for this, so I haven't. Is that acceptable?

To test it manually, I ran this from my app directory before and after the change to verify the behaviour:

```bash
$ crystal run ~/Projects/lucky_cli/src/lucky.cr -- dev
```
jwoertink added a commit that referenced this issue Nov 6, 2020
…le the signal and finish - rather than us immediately exiting and leaving it to log shutting down messages from the background (#572)

* lucky dev: When Ctrl+C is pressed, wait for the child process to handle the signal and finish - rather than us immediately exiting and leaving it to log shutting down messages from the background

Resolves #570. I've just used the approach I suggested there.

I wasn't sure how/if to write a spec for this, so I haven't. Is that acceptable?

To test it manually, I ran this from my app directory before and after the change to verify the behaviour:

```bash
$ crystal run ~/Projects/lucky_cli/src/lucky.cr -- dev
```

* Update src/lucky_cli/process_runner.cr

* oops. formatted

Co-authored-by: Jeremy Woertink <jeremywoertink@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant