Our app - Rails 4.1, Passenger 4, deployed with Capistrano 3.1.
When processing credit card transactions I log it pending in our DB and then hit Authorize.net to actually charge $. On success I update transaction in our system.
I want to make sure that Passenger does not restart while it's waiting for Authorize.net to respond. One option is to query DB to see if there are pending transactions and wait to restart Passenger.
How can I load Rails Env and access the model from Capistrano task? It's quite easy from rake task. Something like this in deploy.rb:
task :restart do
on roles(:app), in: :sequence, wait: 5 do
If Donations.pending == true
sleep 5
else
execute :touch, release_path.join('tmp/restart.txt')
end
end
end
I am open to other suggestions as well. I thank you in advance for any advice.