Skip to content

Instantly share code, notes, and snippets.

@mbklein
Last active August 29, 2015 14:04
Show Gist options
  • Save mbklein/87ee43f169b0b69a6ae1 to your computer and use it in GitHub Desktop.
Save mbklein/87ee43f169b0b69a6ae1 to your computer and use it in GitHub Desktop.
How to restart a hung MasterFile in Matterhorn
empty = ActiveFedora::SimpleDatastream.xml_template.to_xml
mf = MasterFile.find(pid) # Load the MasterFile.
if mf.workflow_id.present?
begin
Rubyhorn.client.stop(mf.workflow_id) # Stop the existing workflow.
rescue # Keep going even if stopping the workflow fails.
end # This means there might be more cleanup later.
end
mf.mhMetadata.content = empty # Remove all Matterhorn-related fields.
mf.set_workflow # Reset the proper workflow.
mf.save # Save the MasterFile so delayed_job can find it.
mf.process # Re-submit the job to Matterhorn via delayed_job.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment