duck_punching

Ruby, Rails and tech. No ducks were harmed in the making of this blog.

ar_mailer gem forked on GitHub, goodies added

Now that GitHub has a gem server it allows the process of managing your own fork or customisation of a gem ridiculously easy. No need for your own gem server or shipping around gem files, just put it up on github and nominate it as a gem in the project config. GitHub will automatically compile the gems using a gemspec file if present. All the info you need is here so I won’t recap it any further.

A gem which I find essential for Rails apps which send out emails is ar_mailer by Eric Hodel of Seattle Ruby Brigade and Ruby Hitsquad fame and now the maintainer of RubyGems. But there a couple of things missing. One is the need for pid files to be generated when running as a daemon to allow effective management with monitoring tools and such.

Well there just so happened to be a patch by Dylan Egan in the ar_mailer forums to add this feature, but it has been overlooked for a long time. So I thought this would be a good chance to fork it and use the GitHub gem system as well. Its now forked it and patched with some tweaks to get it working and a few fixes for the tests which broke due to changes in the latest ZenTest gem.

The project for the gem is here. To use the new gem you need to remove the old one because of the way github names your gems. It uses github username as a prefix to the gem name. This means the old gem will be loaded instead of the new gem when required in your app. But the binary will be used from the new gem causing nasty problems.

To install, first add GitHub as a gem source

sudo gem sources -a http://gems.github.com

Then

sudo gem install adzap-ar_mailer

Now when the binary is run in daemon mode you will get the pid file you need. You can specify the pid file location in the command options like so

ar_sendmail -d -p ./log/ar_sendmail.pid

Any relative paths are expanded from the app directory. You can of course use an absolute path if you wish. The file gets removed on exit as you would expect.

The other major addition is not as visible. Its a Ruby based init.d script for managing mailer startup for one or more apps. It uses a yaml based config file where you specify the app settings for each app that needs a mailer instance running. See the README and demo config for more info.

Ruby, my hammer, is starting to make everything look a nail!

Remember this is GitHub, don’t like what I have done, then fork off!

UPDATE:
If you are getting an error running the ar_sendmail binary, this is due to GitHub to setting the permission on gem binary files incorrectly. The error would be

/usr/bin/ar_sendmail:19:in `load': no such file to load -- ar_sendmail (LoadError)
	from /usr/bin/ar_sendmail:19

To fix it you need to run this ugly (please let me know a better way to get a gem path!!)

GEMS_PATH=`gem env path`
GEM_NAME='adzap-ar_mailer'
sudo chmod 755 $GEMS_PATH/gems/$GEM_NAME*/bin/*

Now you should be able to execute it as a normal user.

UPDATE 2:
Fixed the update fix and made it version non-specific

UPDATE 3:
GitHub fixed the file permissions issue so the work around is not needed anymore.

23 comments

23 Comments so far

  1. Georges October 2nd, 2009 1:32 am

    My company has wrestled with ar_mailer in the past and it has mostly satisfied our needs, but we figured there had to be a better way.
    Mass mailing in rails has always been a pain in the ass, so why not cut it out of the app and have a dedicated process for it?

    We took a stab at making this kind of solution, take a look: http://blog.twg.ca/2009/09/rails-mass-mailing-it-shouldnt-be-this-complicated

    Would love to get your feedback on the idea.

  2. Amelie Griffiths May 19th, 2010 6:45 pm

    my favorite gemstone is none other than diamond. the most expensive and priceless gemstone ever.*~~

  3. Alex Allen July 21st, 2010 4:09 am

    Diamonds and Rubys are my favorite gemstones, i like the color red and the sparkle of diamond.*,`

  4. Cordless Screwdriver ` October 12th, 2010 1:25 pm

    the best gemstones would be diamond and topaz, red rubies are great too`,;

  5. Isopropyl Alcohol : October 23rd, 2010 11:15 pm

    the best and ultimate gemstone is of course diamond because it sparkles and very expensive’:*

  6. physiotherapy November 17th, 2010 2:48 pm

    Pretty nice post. I just stumbled upon your blog and wanted to say that I have really enjoyed browsing your blog posts. In any case I’ll be subscribing to your feed and I hope you write again soon!

  7. Metal Railings December 14th, 2010 4:03 am

    gemstones are expensive but when you give a ring with gemstone to your girlfriend, she would really like it ;*”

  8. Wood Shelf January 25th, 2011 1:58 am

    ~~~ I am very thankful to this topic because it really gives up to date information ‘–

  9. Nappy Rash February 7th, 2011 3:35 pm

    *;~ thank you for posting a topic about this stuff, i was looking for it. ;-*

  10. california king bedding May 6th, 2011 4:38 am

    Pretty section of content. I just stumbled upon your weblog and in accession capital to assert that I acquire in fact enjoyed account your blog posts. Any way I will be subscribing to your feeds and even I achievement you access consistently fast.

  11. Belkin Router May 20th, 2011 9:40 pm

    What a nice website. I absolutely admire your Page about Stethoskop und Belkin Router! http://www.opernundkulturreisen.de/?path=guestbook Stethoskop und Belkin Router

  12. best ptc sites June 4th, 2011 11:02 pm

    Very interesting information!Perfect just what I was looking for!

  13. dating tips June 18th, 2011 12:20 am

    I really like your wordpress web template, exactly where would you obtain it from?

  14. USMLE books July 9th, 2011 12:14 pm

    Details your post. This method study pastimes everybody considerably along with as a result of you, When i acquired different matters. It absolutely was very worthwhile. Site. Bravo. You reside.

  15. Adriana Weeks July 24th, 2011 6:15 pm

    Whoa – nice short post, Does any one know R there cheaper SMS message marketing services 4 shops @ California than 12stores.com? They only cost $9 / 30 days, but my friend Collin said me there is, unfortunately he could not recall its name. I actually start to get suspicion that he remembered wrongly.

  16. Ester Barginear July 29th, 2011 2:46 pm

    Just about all of what you articulate is astonishingly precise and that makes me wonder the reason why I had not looked at this in this light previously. Your article truly did switch the light on for me personally as far as this subject matter goes. Nonetheless there is 1 point I am not too comfy with and while I attempt to reconcile that with the actual central idea of the position, permit me see what the rest of your subscribers have to point out.Nicely done.

  17. online computer trainings August 6th, 2011 1:53 pm

    27. Wow, wonderful blog layout! How long have you been blogging for? you make blogging look easy. The overall look of your web site is excellent, as well as the content!

  18. minigamez August 18th, 2011 9:59 pm

    Excellent site, keep up the good work my colleagues would love this.

  19. Virgilio Kinman August 26th, 2011 9:26 am

    I recently wouldn’t depart your internet site earlier than indicating i really enjoyed the common details any person contribute towards your wedding guests? Is certainly usually yet again constantly in an effort to research crosscheck fresh threads

  20. Devin Ebling September 4th, 2011 7:54 am

    Hello my family member! I wish to say that this post is amazing, nice written and come with approximately all vital infos. Iˇ¦d like to look more posts like this .

  21. aprons for men October 20th, 2011 3:06 am

    For a few people, there’s nothing better than spending time with the cooking developing cooking treats for the whole family members. The only real part that will is apparently a negative may be the mess that is certainly left later on! Thank goodness, you don’t need to being section of the clutter, as possible don cooking aprons to help keep your self clear. Cooking aprons are available in many styles as well as slashes, so you will have no problem discovering engineered to be the two flattering and also functional; you simply need to understand best places to search.

  22. uptodate January 5th, 2012 5:42 pm

    English I own feeblly, but regularly I read you with the help online the translator from google. Thanks for interesting posts

  23. Online dating market January 16th, 2012 12:04 am

    Just about every day good-looking girls get approached by guys who want them for sex. Most of these guys are not very good looking which is not the most important thing in the…

Leave a reply

Mexico