ruby - When a task fails on a server, run a different task on only that server -
i have capistrano task restarts background job on multiple servers. sometimes, job have died on server, , restart command fail because job isn't running. in case i'd call start task (rather restart task). here's attempt:
namespace :job desc "restart job" task :restart, :roles => :app output = nil begin run "sudo restart myjob deploy=true name='myjob1'" |channel, stream, data| output = data end rescue capistrano::commanderror => error if output.match("restart: unknown instance: myjob") puts "****** warning ***** job not running -- starting it" start else puts "some other unknown error, die" raise error end end end desc "start job" task :start, :roles => :app run "sudo start myjob deploy=true name='myjob1'" end end
the problem i've done above, when call "start", run start task on servers, when want run on server died. maybe can pass host start command somehow? haven't been able find how tho. cheers.
Comments
Post a Comment