Skip to content

Commit

Permalink
Added support for --trace argument to help out with troubleshooting.
Browse files Browse the repository at this point in the history
  • Loading branch information
nalanj committed Jan 24, 2012
1 parent ae1d354 commit 39bc832
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bin/tconsole
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

require File.join(File.dirname(__FILE__), "..", "lib", "tconsole")

TConsole::Runner.run
TConsole::Runner.run(ARGV)
8 changes: 6 additions & 2 deletions lib/tconsole.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Runner
SERVER_URI = "druby://localhost:8788"
# Spawns a new environment. Looks at the results of the environment to determine whether to stop or
# keep running
def self.run
def self.run(argv)
stty_save = `stty -g`.chomp

running = true
Expand All @@ -24,13 +24,17 @@ def self.run
# Set up our console input handling and history
console = Console.new

# set up the config
config = {:trace => false}
config[:trace] = true if argv.include?("--trace")

# Start the server
while running
# ignore ctrl-c during load, since things can get kind of messy if we don't

fork do
begin
server = Server.new
server = Server.new(config)

DRb.start_service(SERVER_URI, server)

Expand Down
14 changes: 12 additions & 2 deletions lib/tconsole/server.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
module TConsole
class Server
attr_accessor :config

def initialize(config)
self.config = config
end

def stop
DRb.stop_service
end
Expand All @@ -19,8 +25,12 @@ def load_environment
Rake.application.invoke_task("db:test:load")
Rake.application.invoke_task("test:prepare")
rescue Exception => e
puts "Error: Loading your environment failed."
puts " #{e.message}"
puts "Error - Loading your environment failed: #{e.message}"
if config[:trace] == true
puts
puts " #{e.backtrace.join("\n ")}"
end

return false
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/tconsole/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module TConsole
VERSION = "1.0.0"
VERSION = "1.0.1pre1"
end

0 comments on commit 39bc832

Please sign in to comment.