From 92db2c6e6210a860a4de4baf8033428fbe72b7cc Mon Sep 17 00:00:00 2001 From: elijah Date: Sun, 14 Dec 2014 16:17:14 -0800 Subject: added TapiceroProcess, to handle starting and stopping tapicero during tests. --- bin/tapicero | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'bin') diff --git a/bin/tapicero b/bin/tapicero index d3a9bf8..ef063e5 100755 --- a/bin/tapicero +++ b/bin/tapicero @@ -7,6 +7,13 @@ require 'pathname' BASE_DIR = Pathname.new(__FILE__).realpath + '../..' +def error(msg) + if Tapicero.respond_to?(:logger) && Tapicero.logger + Tapicero.logger.error(msg) + end + puts(msg) +end + begin # # try without rubygems (might be already loaded or not present) @@ -27,9 +34,8 @@ end # Graceful Ctrl-C Signal.trap("SIGINT") do - Tapicero.logger.warn "Received SIGINT - stopping tapicero" - puts "\nQuit - leaving tapicero" - exit + error "Received SIGINT - stopping tapicero" + exit(0) end # this changes later, so save the initial current directory @@ -69,7 +75,8 @@ end begin Daemons.run("#{BASE_DIR}/lib/tapicero_daemon.rb", options) rescue SystemExit -rescue Exception => exc - puts exc.class.name + exc.to_s - puts exc.backtrace.join("\n") + error "Bye" +rescue StandardError => exc + error exc.class.name + " " + exc.to_s + error exc.backtrace.join("\n") end -- cgit v1.2.3