Using fork in Ruby on Rails for creating parallel process
-
29-10-2019 - |
Question
I have a Rails 3 app in production with Passenger on Apache. I have this code:
class Billing < ActiveRecord::Base
after_save :sendEmails
private
def sendEmails
fork do
UserMailer.clientBilling(self.user, self).deliver
end
end
end
In localhost, when the app creates a billing, after it is saved, the app sends an email to the user, everything works fine. But in the server, after the app creates a billing, it throws me errors related to the gem MySQL2, errors like "MySQL server has gone away" or "Connection lost", and the app doesn't send the emails. If I remove the fork it works fine, but I want to use fork, I want to create a separated process because it takes to long when sending emails. What could be the problem?
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow