Created
October 16, 2015 15:06
-
-
Save meconlin/d2d3780a6f1917094120 to your computer and use it in GitHub Desktop.
AWS SWF : kill stuck workflow executions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'aws-sdk' | |
require 'pry' | |
class SwfManager | |
def client | |
credentials = Aws::SharedCredentials.new(profile_name: 'default') | |
swf = Aws::SWF::Client.new( | |
region: 'us-east-1', | |
credentials: credentials | |
) | |
end | |
def list_workflow domain | |
p client | |
p domain | |
resp = client.list_open_workflow_executions({ | |
domain: domain, # required | |
start_time_filter: { # required | |
latest_date: Time.now, # required | |
oldest_date: (Date.today - 90).to_time, | |
} | |
# execution_filter: { | |
# workflow_id: "WorkflowId", # required | |
# }, | |
}) | |
resp.execution_infos.each do |wf| | |
id = wf.execution.workflow_id | |
purge_workflow domain, id | |
end | |
end | |
def purge_workflow domain, workflow_id | |
resp = client.terminate_workflow_execution({ | |
domain: domain, | |
workflow_id: workflow_id, | |
reason: "killed via script", | |
}) | |
p "domain : id : deleted : #{domain} : #{workflow_id} : #{resp}" | |
end | |
end | |
manager = SwfManager.new | |
manager.list_workflow "OptionHtmlParseDomain" | |
#manager.purge_workflow "OptionHtmlParseDomain", "WBA5A7C56GG146159" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment