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

Capture Interrupt error (Ctrl+c) and cleanly exit #67

Merged
merged 1 commit into from
Jun 13, 2017

Conversation

kinow
Copy link
Member

@kinow kinow commented May 29, 2017

Another request, now from a fellow developer that was working on a dashboard created with Smashing. While fixing exceptions, he mentioned that having one less exception could help identifying errors.

He was talking about the Interrupt error that we have in logs when we stop the command with a CTRL+C.

$ smashing start
Thin web server (v1.6.4 codename Gob Bluth)
Maximum connections set to 1024
Listening on 0.0.0.0:3030, CTRL+C to stop
For the twitter widget to work, you need to put in your twitter API keys in the jobs/twitter.rb file.
^C/var/lib/gems/2.3.0/gems/smashing-1.0.0/lib/dashing/cli.rb:89:in `system': Interrupt
	from /var/lib/gems/2.3.0/gems/smashing-1.0.0/lib/dashing/cli.rb:89:in `run_command'
	from /var/lib/gems/2.3.0/gems/smashing-1.0.0/lib/dashing/cli.rb:64:in `start'
	from /var/lib/gems/2.3.0/gems/thor-0.19.4/lib/thor/command.rb:27:in `run'
	from /var/lib/gems/2.3.0/gems/thor-0.19.4/lib/thor/invocation.rb:126:in `invoke_command'
	from /var/lib/gems/2.3.0/gems/thor-0.19.4/lib/thor.rb:369:in `dispatch'
	from /var/lib/gems/2.3.0/gems/thor-0.19.4/lib/thor/base.rb:444:in `start'
	from /var/lib/gems/2.3.0/gems/smashing-1.0.0/bin/smashing:9:in `<top (required)>'
	from /usr/local/bin/smashing:23:in `load'
	from /usr/local/bin/smashing:23:in `<main>'

This pull request simply wraps the call to system capturing the Interrupt error, and printing an exit message. Based on this commit of power.

What others think of this change? With this code, the command would print.

$ smashing start
Thin web server (v1.6.4 codename Gob Bluth)
Maximum connections set to 1024
Listening on 0.0.0.0:3030, CTRL+C to stop
For the twitter widget to work, you need to put in your twitter API keys in the jobs/twitter.rb file.
^CExiting...

Cheers
Bruno

Copy link
Contributor

@tyler-mauthe-hs tyler-mauthe-hs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Merge that sucker.

@kinow kinow merged commit 1ea92c8 into Smashing:master Jun 13, 2017
@kinow
Copy link
Member Author

kinow commented Jun 13, 2017

Thanks for reviewing it @tyler-mauthe-hs !!!

@kinow kinow added this to the 1.1.0 milestone May 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants