Sha256: 39b7dc72100b94f18878783a561e51880272455fe28c1a1b953915d280da69cd
Contents?: true
Size: 1.71 KB
Versions: 1
Compression:
Stored size: 1.71 KB
Contents
require 'core/command' require 'core/tmux' module Nutella class Stop < Command @description = "Stops all or some of the bots in the current project" def run(args=nil) # Is current directory a nutella prj? if !Nutella.currentProject.exist? return end # Extract runid runid = args[0].to_s.empty? ? Nutella.currentProject.config["name"] : Nutella.currentProject.config["name"] + "_" + args[0] # Remove from the list of runs if Nutella.runlist.delete?(runid).nil? console.warn "Run #{runid} doesn't exist. Impossible to stop it." return end # Are we using the internal broker? If yes, stop it if Nutella.runlist.empty? and Nutella.config['broker'] == "localhost" stopBroker end # Extract project directory @prj_dir = Nutella.currentProject.dir # Stops all the bots Tmux.killSession(runid) # Deletes bots config file if it exists File.delete("#{@prj_dir}/.botsconfig.json") if File.exist?("#{@prj_dir}/.botsconfig.json") # Output success message if runid == Nutella.currentProject.config["name"] console.success "Project #{Nutella.currentProject.config["name"]} stopped" else console.success "Project #{Nutella.currentProject.config["name"]}, run #{args[0]} stopped" end end private def stopBroker pidFile = "#{Nutella.config["broker_dir"]}/bin/.pid" if File.exist?(pidFile) # Does the broker pid file exist? pidF = File.open(pidFile, "rb") pid = pidF.read.to_i pidF.close() Process.kill("SIGKILL", pid) File.delete(pidFile) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nutella_framework-0.1.0 | lib/core/commands/stop.rb |