Module: Kaya::Commands
- Defined in:
- lib/kaya/commands/bye.rb,
lib/kaya/commands/help.rb,
lib/kaya/commands/stop.rb,
lib/kaya/commands/reset.rb,
lib/kaya/commands/start.rb,
lib/kaya/commands/install.rb,
lib/kaya/commands/restart.rb,
lib/kaya/commands/reset_suites.rb
Class Method Summary collapse
- .bye ⇒ Object
- .help ⇒ Object
- .install(origin = nil) ⇒ Object
- .reset ⇒ Object
- .reset_suites ⇒ Object
- .restart ⇒ Object
- .start(nodemon = false) ⇒ Object
- .stop ⇒ Object
Class Method Details
.bye ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/kaya/commands/bye.rb', line 3 def self.bye $K_LOG.debug "#{self}:#{__method__}" if $K_LOG self.stop FilesCleanner.delete_kaya_folder puts "Files cleanned" puts "She is gone!" end |
.help ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/kaya/commands/help.rb', line 3 def self.help $K_LOG.debug "#{self}:#{__method__}" if $K_LOG puts " Kaya has some commands: - install - start - stop - restart - reset Note: If you stop kaya and then you want to get it up and the port you are using is already in use you could use the following commands (Ubunutu OS): $sudo netstat -tapen | grep :8080 In this example we use the port 8080. This command will give you the app that is using the port. Then you could kill it getting its PID previously." end |
.install(origin = nil) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/kaya/commands/install.rb', line 3 def self.install origin=nil begin TaskRack.start([]) puts " A new folder called kaya was created. Check the configuration file with the name kaya_conf. You'll find some configuration values there. Take a look and set your preferences! Enjoy Kaya Thanks " puts "You don't have defined a cucumber.yml file. YOU SHOULD TO USE KAYA :)" if Kaya::Suites.cucumber_yml.empty? puts "Now, you can run bundle install and then `kaya start` command" rescue => e puts "\n\nERROR: #{e}\n\n #{e.backtrace}" end end |
.reset ⇒ Object
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 |
# File 'lib/kaya/commands/reset.rb', line 3 def self.reset $K_LOG.debug "#{self}:#{__method__}" if $K_LOG begin Kaya::Support::Configuration.get Kaya::Database::MongoConnector.new(Kaya::Support::Configuration.db_connection_data) print "\nCleanning database..." Kaya::Database::MongoConnector.drop_collections print "Done!\n\n" print "\nCleanning project..." Kaya::Support::FilesCleanner.start! print "Done!\n\n" if Kaya::Support::Configuration.use_git? Kaya::Support::Git.pull Kaya::Suites.update_suites else # NO GIT USAGE Kaya::Suites.update_suites end puts "PROFILES LOADED CORRECTLY \n\nRun `kaya start`" rescue => e puts "CANNOT CLEAN SYSTEM\n#{e}\n\n#{e.backtrace}" end end |
.reset_suites ⇒ Object
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 |
# File 'lib/kaya/commands/reset_suites.rb', line 3 def self.reset_suites $K_LOG.debug "#{self}:#{__method__}" if $K_LOG begin Kaya::Support::Configuration.get Kaya::Database::MongoConnector.new(Kaya::Support::Configuration.db_connection_data) print "\nCleanning suites from database..." Kaya::Database::MongoConnector.drop_collections print "Done!\n\n" print "\nCleanning project..." Kaya::Support::FilesCleanner.start! print "Done!\n\n" if Kaya::Support::Configuration.use_git? Kaya::Support::Git.pull Kaya::Suites.update_suites else # NO GIT USAGE kaya::Suites.update_suites end puts "PROFILES LOADED CORRECTLY \n\nRun `kaya start`" rescue => e puts "CANNOT CLEAN SYSTEM\n#{e}\n\n#{e.backtrace}" end end |
.restart ⇒ Object
3 4 5 6 7 |
# File 'lib/kaya/commands/restart.rb', line 3 def self.restart $K_LOG.debug "#{self}:#{__method__}" if $K_LOG self.stop self.start end |
.start(nodemon = false) ⇒ Object
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 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 94 95 96 97 98 99 100 101 102 |
# File 'lib/kaya/commands/start.rb', line 3 def self.start nodemon=false $K_LOG.debug "Starting Kaya" if $K_LOG begin Kaya::Support::Configuration.new $K_LOG.debug "Starting...\n\n#{Kaya::Support::Logo.logo}" if $K_LOG $K_LOG.debug "Checking config.ru file existance" if $K_LOG raise "ERROR --- kaya/config.ru file was not found. Try with `kaya prepare` command before `kaya start`" unless File.exist?("#{Dir.pwd}/kaya/config.ru") $K_LOG.debug "Checking unicorn.rb file existance" if $K_LOG raise "ERROR --- kaya/unicorn.rb file was not found. Try with `kaya prepare` command before `kaya start`" unless File.exist?("#{Dir.pwd}/kaya/unicorn.rb") Kaya::Support::Logo.show Kaya::Support::Configuration.show_configuration_values $K_LOG.debug "Connecting to database" if $K_LOG Kaya::Database::MongoConnector.new(Kaya::Support::Configuration.db_connection_data) $K_LOG.debug "Loading doc" if $K_LOG Kaya::Support::Documentation.load_documentation if Kaya::Support::Configuration.headless? $K_LOG.debug "Headless mode: ON - Checking xvfb existance" if $K_LOG res = Kaya::Support::Console.execute "xvfb-run" if res.include? "sudo apt-get install xvfb" puts " You have configured headless mode but xvfb package is not installed on your system. Please, install xvfb package if you want to run browsers in headless mode or set HEADLESS active value as false if you do not use browser in your tests." return end end puts "\n" $K_LOG.debug "Cleanning old kaya report files" if $K_LOG Kaya::Support::FilesCleanner.delete_kaya_reports() $K_LOG.debug "Old kaya report files cleanned" if $K_LOG $K_LOG.debug "Cleanning old kaya console files" if $K_LOG Kaya::Support::FilesCleanner.delete_console_outputs_files() $K_LOG.debug "Old kaya console files cleanned" if $K_LOG $K_LOG.debug "Clearing kaya log file" if $K_LOG Kaya::Support::FilesCleanner.clear_kaya_log $K_LOG.debug "Kaya log file cleanned" if $K_LOG $K_LOG.debug "Clearing sidekiq log file" if $K_LOG Kaya::Support::FilesCleanner.clear_sidekiq_log $K_LOG.debug "Sidekiq log file cleanned" if $K_LOG # To prevent showing suites as runnnig when service started recently reset all suites $K_LOG.debug "Reseting suites statuses" if $K_LOG Kaya::Suites.reset_statuses $K_LOG.debug "Suites statuses reseted" if $K_LOG puts "\n* Suites Status: Reseted" # Force results to reset or finished status $K_LOG.debug "Reseting defunct executions" if $K_LOG Kaya::Results.reset_defuncts $K_LOG.debug "Defunct execution reseted" if $K_LOG puts "\n* Results: Reseted".green kaya_arg = "-D" unless nodemon $K_LOG.debug "Starting Sidekiq" if $K_LOG Kaya::BackgroundJobs::Sidekiq.start $K_LOG.debug "Sidekiq Started" if $K_LOG # Start kaya app $K_LOG.debug "Starting Kaya" if $K_LOG Kaya::Support::Console.execute "unicorn -c #{Dir.pwd}/kaya/unicorn.rb -p #{Kaya::Support::Configuration.port} #{kaya_arg} kaya/config.ru" $K_LOG.debug "Kaya started" if $K_LOG # Save all kaya pids $K_LOG.debug "Saving PIDs for Kaya" if $K_LOG File.open("#{Dir.pwd}/kaya/kaya_pids", "a"){ |f| f.write Kaya::Support::Processes.kaya_pids.join("\n")} $K_LOG.debug "Kaya PIDs saved" if $K_LOG puts "\n\n* Kaya is succesfully Started!\n".green if $IP_ADDRESS puts "\n\n You can go now to http://#{$IP_ADDRESS}:#{Kaya::Support::Configuration.port}/kaya\n\n" $K_LOG.debug "You can go now to http://#{$IP_ADDRESS}:#{Kaya::Support::Configuration.port}/kaya" if $K_LOG end rescue => e $K_LOG.error "Error starting Kaya: #{e}#{e.backtrace}" if $K_LOG puts "An error ocurred while starting Kaya. See kaya log for more information.".red end end |
.stop ⇒ Object
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 |
# File 'lib/kaya/commands/stop.rb', line 3 def self.stop $K_LOG.debug "#{self}:#{__method__}" if $K_LOG Kaya::Support::Configuration.get # Get pids from saved file on start process if File.exist? "#{Dir.pwd}/kaya/kaya_pids" kaya_pids = IO.read("#{Dir.pwd}/kaya/kaya_pids").split("\n") # Kill all pids specified on file begin Kaya::Support::Processes.kill_all_these kaya_pids rescue end # Delete pid file File.delete("#{Dir.pwd}/kaya/kaya_pids") end if File.exist? "#{Dir.pwd}/kaya/sidekiq_pid" sidekiq_pid = IO.read("#{Dir.pwd}/kaya/sidekiq_pid").split("\n") begin Kaya::Support::Processes.kill_all_these sidekiq_pid rescue end File.delete("#{Dir.pwd}/kaya/sidekiq_pid") end # Evaluates if any pid could not be killed (retry) Kaya::Support::Processes.kill_all_these(Kaya::Support::Processes.kaya_pids) if Kaya::Support::Processes.kaya_pids.empty? puts " Kaya stopped!" else puts " Could not stop Kaya. If Kaya is still running please type `kaya help` to get some help" end end |