module Deployinator::Helpers::DeployHelpers

Public: helper methods to interact with deploy processes

Public Instance Methods

get_deploy_process_title(stack=nil, stage=nil) click to toggle source

Public: get the process title for the deployment process of a specific stage in a stack

Parameters:

stack - name of the stack
stage - name of the stage

Returns the title as a string or nil on error

# File lib/deployinator/helpers/deploy.rb, line 61
def get_deploy_process_title(stack=nil, stage=nil)
  return nil if (stack.nil? or stage.nil?)
  "Deployinator - deploy #{stack}:#{stage}"
end
get_list_of_deploys() click to toggle source

Public: get a list of all currently running deploys

Returns an array of hashes of the form {:stack => stackname, :stage

> stagename}

# File lib/deployinator/helpers/deploy.rb, line 10
def get_list_of_deploys
  ret = []
  raw = `pgrep -d, -l -f Deployinator`.strip.split(",")
  raw.each do |deploy|
    deploy = deploy.strip
    if deploy =~ /Deployinator - deploy (\S+?):(\S+?)$/
      ret << {:stack => $1, :stage => $2}
    end
  end
  ret
end
is_deploy_active?(stack, stage) click to toggle source

Public: get the activity status of the deploy for a certain stack and stage

Parameters:

stack - name of the stack
stage - name of the stage

Returns true for a running deploy or false for a deploy that is not running

# File lib/deployinator/helpers/deploy.rb, line 46
def is_deploy_active?(stack, stage)
  if deployname = get_deploy_process_title(stack,stage)
    return system("pgrep -f '#{deployname}'")
  end
  false
end
stop_deploy(stack, stage) click to toggle source

Public: stop a running deploy indentified by stack and stage

Parameters:

stack - name of the stack
stage - name of the stage

Returns true if the deploy was stopped and false on error

# File lib/deployinator/helpers/deploy.rb, line 30
def stop_deploy(stack, stage)
  if deployname = get_deploy_process_title(stack,stage)
    return system("pkill -f '#{deployname}'")
  end
  false
end