Heroku - worker support
andreasklinger opened this issue · 12 comments
Hi guys
It seems letter_opener_web won't be much of use on heroku. I would assume that most people use workers to send their emails.
As far as i understand this workers and all dynos have isolated environments. Thus it can't really reach the same /tmp
directory.
Thinking about it makes as a lot of sense.
A workaround would be s3 support i guess. Unfortunately i personally can't implement that right now. But i think it would be worth the note in the README that it only works on heroku under certain conditions. Simply to save the time of the next person ;)
best wishes
Andreas
Yeah, sorry that you had trouble with that :-( The only scenario where letter_opener_web works fine on Heroku is when you have a single dyno with no mails being sent on the background.
I'm just not sure about keeping mails on S3, maybe Redis would be an easier approach? I initially thought of keeping things on the app's DB, but that will end up polluting our schema.rb
with dev only stuff.
I don't have a strong need for getting this gem to work on Heroku apart from the demo app, so it is something I might not work on for a while.
Completely fine and understandable. If i'd have a bit more of time i'd build this feature because your gem kicks ass.
Imho just add a note in the Readme - maybe just link to this issue - just to save the next person some time
Happened to me too.
I'm not familiar with how Heroku is set up, but at Engine Yard, as part of the deploy process, you are able to use deploy hooks. In the deploy hooks, you can symlink to shared resources and directories, so I have it set up so that before the app restarts, I do this:
run "mkdir -p #{config.shared_path}/system/letter_opener"
run "ln -nfs #{config.shared_path}/system/letter_opener #{config.release_path}/tmp/letter_opener"
and then everything works great, no matter how many instances I have running...
The resolution for now seems to be the notice in the README. Since this is a few years old, I'm going to close it. If this is still a concern, re-open.
what if there was an option to store emails in redis?
That or storing it on a DB would also work
Still a concern for me. Could use this for Heroku when sending mails with deliver_later. However, if I'm the only one, it might not be worth the trouble :p
Any suggestions on how to test (mass) mails in staging environments on Heroku without sending them to real people?
There's a Heroku add-on that does this, there may be others: https://elements.heroku.com/addons/mailtrap
If anyone has troubles with using this gem on Heroku with multiple workers, I solved this issue with this PR: #129
If the PR is not merged, you can use the updated version the following way:
gem 'letter_opener_web', git: 'https://github.com/pdabrowski6/letter_opener_web', branch: 'support-for-s3'
If anyone has troubles with using this gem on Heroku with multiple workers, I solved this issue with this PR: #129
If the PR is not merged, you can use the updated version the following way:
gem 'letter_opener_web', git: 'https://github.com/pdabrowski6/letter_opener_web', branch: 'support-for-s3'
A brilliant solution for AWS S3 users. However, it's still not a universal solution for those who run Rails server and background servers (such as Sidekiq) separately.