Class: OptimusPrime::Cannon
- Inherits:
-
Object
- Object
- OptimusPrime::Cannon
- Defined in:
- lib/optimus_prime.rb
Instance Attribute Summary collapse
-
#op_port ⇒ Object
readonly
Returns the value of attribute op_port.
Class Method Summary collapse
Instance Method Summary collapse
- #current_path ⇒ Object
-
#initialize(options = {}) ⇒ Cannon
constructor
A new instance of Cannon.
- #optimus_prime_path ⇒ Object
- #start_server ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Cannon
Returns a new instance of Cannon.
64 65 66 67 |
# File 'lib/optimus_prime.rb', line 64 def initialize(={}) @options = @op_port = $port end |
Instance Attribute Details
#op_port ⇒ Object (readonly)
Returns the value of attribute op_port.
62 63 64 |
# File 'lib/optimus_prime.rb', line 62 def op_port @op_port end |
Class Method Details
.fire!(port, options = {}) ⇒ Object
57 58 59 60 |
# File 'lib/optimus_prime.rb', line 57 def self.fire!(port, ={}) $port = port self.new().start_server end |
Instance Method Details
#current_path ⇒ Object
99 |
# File 'lib/optimus_prime.rb', line 99 def current_path; `pwd`.chomp; end |
#optimus_prime_path ⇒ Object
95 96 97 |
# File 'lib/optimus_prime.rb', line 95 def optimus_prime_path File.('../', __dir__) end |
#start_server ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/optimus_prime.rb', line 69 def start_server return system("echo '\nOptimus is already priming :)\n\n'") if File.exist?("#{current_path}/tmp/pids/optimus_prime.pid") unless File.directory?("#{current_path}/tmp/pids") system("echo 'Creating tmp/pid' && mkdir -p #{current_path}/tmp/pids") end unless File.exist?("#{current_path}/tmp/pids/optimus_prime.pid") if not `lsof -i:#{op_port}`.empty? return system("echo '\n\n------> Ooops looks like this port is already in use\n-------> Please kill it!!!\n'") end system("echo '\nStarting Optimus Prime\n'") if @options[:multi_threaded] puts system("thin start -c #{optimus_prime_path} -p #{op_port} -P #{current_path}/tmp/pids/optimus_prime.pid -l #{current_path}/optimus_prime.log --threaded -p 7011 --threadpool-size #{@options[:thread_pool] || 16} -d") else puts system("thin start -c #{optimus_prime_path} -p #{op_port} -P #{current_path}/tmp/pids/optimus_prime.pid -l #{current_path}/optimus_prime.log -D -d") end while :starting_server sleep(2) and break if File.exist?("#{current_path}/tmp/pids/optimus_prime.pid") end end end |