I wrote a rails app that uses mailman-rails gem to check a Gmail inbox for new messages and pull them in after reading them. It uses mailman-rails to have an always-live mailman listener watching the inbox for new messages.
It works fine in every way, except that when I push live to a production server hosted on AWS, the mailman server never stays on for more than 24-36 hours. I'm checking the logs, and I don't see any sort of critical error logged that caused the mailman listener to shut down, so I'm guessing that it's just killing itself or timing out?
Or is there something about the elastic nature of AWS EB that causes the server to restart periodically, which would obviously shut down the mailman?
Right now, I am manually SSHing into the server every time to run on mailman using rake mailman:start. What should I be doing instead?
Or how do I write a script that manually restarts mailman every 5 hours or so to make sure it's always on?
You can easily add a cron task using the AWS Elastic Beanstalk's .ebextensions and crontab.
https://stackoverflow.com/a/14110976/289316 is a great start, however I will say that you'll need to use the full path to bundle and call the command via:
/usr/local/bin/bundle exec rake mailman:restart
I achieved that part through the following: