lib/skynet/skynet_launcher.rb in skynet-0.9.2 vs lib/skynet/skynet_launcher.rb in skynet-0.9.3

- old
+ new

@@ -1,14 +1,40 @@ # FIXME: should be a module class Skynet include SkynetDebugger - def self.new(options={}) + def self.start(options={}) + begin + mq = Skynet::MessageQueue.new + rescue Skynet::ConnectionError + if Skynet::MessageQueue.adapter == :tuplespace + ts_port = Skynet::CONFIG[:TS_SERVER_HOSTS].first.split(':').last + # puts "trying to make ts skynet_tuplespace_server --port=#{ts_port} --logfile=#{Skynet.config.logfile_location} --piddir=#{Skynet.config.skynet_pid_dir} --use_ringserver=#{Skynet.config.ts_use_ringserver} --drburi=#{Skynet.config.ts_drburi} start" + cmd = "skynet_tuplespace_server --port=#{ts_port} --logfile=#{Skynet.config.logfile_location} --piddir=#{Skynet.config.skynet_pid_dir} --use_ringserver=#{Skynet.config.ts_use_ringserver} --drburi=#{Skynet.config.ts_drburi} start" + pid = fork do + exec(cmd) + end + sleep Skynet::CONFIG[:TS_SERVER_START_DELAY] + end + end + + options[:script_path] = Skynet::CONFIG[:LAUNCHER_PATH] + if ARGV.detect {|a| a == 'console' } ARGV.delete('console') Skynet::Console.start elsif options[:worker_type] or ARGV.detect {|a| a =~ /worker_type/ } Skynet::Worker.start(options) else - Skynet::Manager.start(options) + if ARGV.include?('stop') + Skynet::Manager.stop(options) + else + options["daemonize"] = true if ARGV.include?('start') + Skynet::Manager.start(options) + end end end -end \ No newline at end of file + + def self.new(options={}) + warn("Skynet.new is deprecated, please use Skynet.start instead") + start(options) + end +end