Welcome Guest | Login

ar_sendmail suddenly stopped working

I've got a cron job running the following command:
/usr/local/bin/ar_sendmail -c /<path to root of application>/ -b 20 -o
once every 5 minutes.

Everything was running fine until 9/26/2007 at 1:40pm when I started getting emails everytime the job runs:

Unhandled exception uninitialized constant Email(NameError):
./config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:123:in `const_missing'
./config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:131:in `const_missing'
/usr/local/lib/ruby/gems/1.8/gems/ar_mailer-1.3.1/lib/action_mailer/ar_sendmail.rb:9:in `const_get'
/usr/local/lib/ruby/gems/1.8/gems/ar_mailer-1.3.1/lib/action_mailer/ar_sendmail.rb:9:in `path2class'
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `inject'
/usr/local/lib/ruby/gems/1.8/gems/ar_mailer-1.3.1/lib/action_mailer/ar_sendmail.rb:9:in `each'
/usr/local/lib/ruby/gems/1.8/gems/ar_mailer-1.3.1/lib/action_mailer/ar_sendmail.rb:9:in `inject'
/usr/local/lib/ruby/gems/1.8/gems/ar_mailer-1.3.1/lib/action_mailer/ar_sendmail.rb:9:in `path2class'
/usr/local/lib/ruby/gems/1.8/gems/ar_mailer-1.3.1/lib/action_mailer/ar_sendmail.rb:382:in `initialize'
/usr/local/lib/ruby/gems/1.8/gems/ar_mailer-1.3.1/lib/action_mailer/ar_sendmail.rb:340:in `new'
/usr/local/lib/ruby/gems/1.8/gems/ar_mailer-1.3.1/lib/action_mailer/ar_sendmail.rb:340:in `run'
/usr/local/lib/ruby/gems/1.8/gems/ar_mailer-1.3.1/bin/ar_sendmail:5
/usr/local/bin/ar_sendmail:16:in `load'
/usr/local/bin/ar_sendmail:16

My email.rb model is nestled in the models folder and looks good, and all my config files are setup properly. Emails that are sent via the site are being saved to the emails table...ar_sendmail just won't send them.

Any ideas?

Thanks in advance.

2007-10-02 03:40 PM

OK....ended up solving my own issue.  Looks like the -c switch in ar_sendmail is flakey, I had to cd to my application root before ar_sendmail would run.
To solve my cron issue, I wrote the following little script:

#!/bin/sh
cd ~/<path to application root>
/usr/local/bin/ar_sendmail -b 20 -o

saved it to mail_processor.sh in the root of my account, chmod'd it to 755, and setup a cron job like so:
*/5 * * * * ~/mail_processor.sh

Works like a charm!  Hopefully, this helps out someone else who runs into a similar issue.

2007-10-02 09:33 PM

Hey I'm glad you got it running.  However, on a shared server you should run ar_sendmail in daemon mode -- ar_mailer crons are classic for causing load problems and tech support may give you grief.  

2007-10-03 03:49 AM

I saw that there was a daemon mode for ar_mailer, but documentation for the plugin is poor at best. The help is helpless. How would I throttle ar_mailer in daemon mode?  If you have any links that my googling hasn't come up with, it would be appreciated.

2007-10-03 12:08 PM


I believe you can run ar_sendmail as a daemon using the -d switch. The command you run should be something like:

/usr/local/bin/ruby /usr/local/bin/ar_sendmail -d --batch-size <SomeNumberHere> --chdir /path/to/railsapp --environment production
BTW, ar_sendmail --help should give you the list of available options.

2007-10-03 12:50 PM

I'm trying to be a good citizen and use daemon mode, but I've had the daemon spontaneously shut down on me less than a day after I started it (not sure exactly how long). Here's the command I use:

cd /home/myself/myrailsapp && /usr/local/bin/ruby /usr/local/bin/ar_sendmail -d --batch-size 4 --delay 60 --environment production
I set up an "@reboot" cron job to restart it like I have for my mongrel instance, but the server didn't restart anyway, so I don't know why the daemon shut down. Any ideas?

2007-10-09 01:36 PM

Hi Banjerluke,

You  can run a cronjob that checks if ar_sendmail is running. If it's not running, the script should restart ar_sendmail.

2007-10-09 03:16 PM

Hello,
I've recently started using ar_mailer. I'm curious how a daemon differs from a cronjob. And how might a cronjob that checks if ar_sendmail is running look? Thanks.

2007-11-23 07:54 AM

Hi - When you run it as daemon it runs continuously and process the requests as it comes. But when you run it as a cron it will only process the request when the cron job runs. And we suggest you to run it as Daemon. You can refer the bash script in this thread to check if ar_sendmail is running. If you are finding it difficult to modify the script you can just post a ticket to the support team to the help you out with it. Thank you

2007-11-23 08:39 AM

HostingRails Support

Hello Guest! In order to post you must be an active client with us, please log in or sign up today!