Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: bfad2878c0
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 51 lines (38 sloc) 1.025 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
#!/usr/bin/env ruby
#--
# Copyright (c) 2005 Tobias Lutke
#
#++
PORT = 3232


# Load the environment
require File.dirname(__FILE__) + '/server/config/environment.rb'

# change the current directory
Dir.chdir File.dirname(__FILE__)

# Setup webrick
puts "=> Vision starting at http://localhost:#{PORT}/"

trap("INT") { $webrick.shutdown }
trap("TERM") { $webrick.shutdown }

puts 'starting...'

begin
  mount(WEBrick::HTTPServer.new(:Port => PORT ))

  case RUBY_PLATFORM
  when /darwin/
    system("open http://localhost:#{PORT}/dashboard/")
  when /win/
    system("start http://localhost:#{PORT}/dashboard/")
  end

  $webrick.start
rescue => e
  
  if RUBY_PLATFORM && !$tried_to_kill
    $tried_to_kill ||= 3
    $tried_to_kill -= 1
    
    if $tried_to_kill > 0
      puts "Trying to stop existing vision process..."
      pid = `ps x | grep vision.rb`.to_a[0].split[0]
      Process.kill(:SIGTERM, pid.to_i)
      sleep(1)
    end
    retry
  end
  
  puts "Could not start vision, port #{PORT} already used."
end
Something went wrong with that request. Please try again.