[capistrano] Re: Trapping Interrupts or otherwise ensuring an action on failure

2013-06-20 Thread Benjamin Fleischer
well, this is what works for me def write_deploy_lock(deploy_lock) put deploy_lock.to_yaml, deploy_lockfile, :mode => 0777 # Ensure the lockfile is removed on failure at_exit { exit_cleanup('exception on exit') if $! } trap('INT') { exit_cleanup('interrupt'); exit 1 }

Re: [capistrano] Re: Trapping Interrupts or otherwise ensuring an action on failure

2013-05-31 Thread Donovan Bray
Done in the write_deploy_lock function you may be able to leverage ruby's at_exit handler. http://trevoke.net/blog/2012/01/06/ruby-what-is-at_exit-and-how-to-write-tests-for-it/ On May 30, 2013, at 2:51 PM, Benjamin Fleischer wrote: > I also asked on IRC and torrancew led me to try this > >

Re: [capistrano] Re: Trapping Interrupts or otherwise ensuring an action on failure

2013-05-31 Thread Lee Hambley
Probably you are installing the trap too late. You might also look at Ruby's `at_exit` which might let you do what you need to do. - Lee Lee Hambley -- http://lee.hambley.name/ +49 (0) 170 298 5667 On 30 May 2013 23:51, Benjamin Fleischer wrote: > I also asked on IRC and torrancew led me to

[capistrano] Re: Trapping Interrupts or otherwise ensuring an action on failure

2013-05-31 Thread Benjamin Fleischer
I also asked on IRC and torrancew led me to try this before 'deploy:rollback', 'deploy:unlock' def write_deploy_lock(deploy_lock) put deploy_lock.to_yaml, deploy_lockfile, :mode => 0777 + # Ensure the lockfile is remove on Interrupt + trap("INT") { +STDERR