Archive Page 2
Backgroundrb is a great tool for getting cron like functionality in your Rails app, but it can be a pain if its not working correctly. I’m not going to go into how to get backgroundrb working, its rubyforge page has decent instructions for that, but what I will share are some tips on debugging a non-working worker.
Obviously check your RAILS_ROOT/log and check backgroundrb.log, backgroundrb_server.log, and backgroundrb_debug.log. I’ve found backgroundrb.log most useful, but many times I’ll restart backgroundrb by
script/backgroundrb stop
script/backgroundrb start #restart doesn’t work for me
and nothing will happen. Check your backgroundrb_server.log file and you may see that the ‘address is already in use”.
Type “top” into your command line (on a Linux system) and then press shift+M. You should get a nice list of services running and you’ll more than likely have a couple of rubys on there. For some reason backgroundrb doesn’t stop all the time when you tell it to and I’ve had to kill -9 the rubys and then restart backgroundrb and mongrel.
You may also notice that the backgroundrb ruby instance uses ALOT of memory! Make sure you have
:environment: production
in your backgroundrb.yml file in RAILS_ROOT/config. Otherwise backgroundrb is working in development mode.
Finally, to debug an syntax or other error try this.
1. open 2 command lines.
2. start your rails app with ruby script/server. Make sure to start it in development mode and not using mongrel_rails.
3. start backgroundrb in the other terminal.
4. watch the first terminal and you can see what background rb is doing and where exactly it gets messed up.
You can do this by monitoring the log file or tailing it, but I like this better and it provides you with more info.
Hope this helps any of you out.
Well, after a little bit of down time and some re-adjusting my slice at slicehost we’re back and I’ve gotten Royner up and running at royner.johnyerhot.com.
What is Royner?
Good question. Well, you sign up with either a Google Talk (Gtalk) or Jabber instant message screen name, give Royner a url for a RSS/ATOM feed (i.e. Feedburner)
Please give me some feed back on Royner. I didn’t put tons and tons of hours into Royner (the majority on Backgroundrb, which is working beautifully now), but I’d like to keep it alive if the demand is there.
There are some to-do’s left:
Set Royner up so that you can respond to IM’s with “OK” or something and Royner will quit looking for that key word.
Hasta pasta
Well I’ve finished consolodating my two hosting accounts, one at Godaddy (cheap Linux hosting) and my shared Rails hosting at OcsSolutions (which was very good for shared Rails host) to a 512 mb Ubuntu 7.10 ’slice’ at Slicehost. Was gonna go straight Debian, but figured what the hell. For any of you who don’t know, a ’slice’ is pretty much get VPS hosting account. This is my first VPS. I set up Apache/Rails proxy servers and your run of the mill LAMP servers for customers/clients and at work all the time, but this is MY first server that is all mine to mess with.
As mentioned, I decided to give Nginx a try. I have to admit, initial set up is very easy. I first setup the Rails enviornment and had Nginx proxy to two mongrels for each app. (I’m running two apps for four total Mongrels). No problem.
Next, I had to get php working. Not so easy.
I ended up looking for help and followed this, setting up php5 to run as fast-cgi. Ugh. To make things worse, I had to move over the Wordpress install from Godaddy. I assummed it would be easy as pie, and it was to an extent, but I ran into trouble with the way the virtual hosts configs nginx uses handle subdomains and .. long story short I had redirect loop happening and it just sucked.
I’m blabering on and on here, but in the end I’ve got everything up and running. We’ll see how Nginx works in the long term, but right now it seems pretty snappy and the memory footprint is much smaller than Apache.
So, Royner and another project of mine have a place to live and I’m just gonna do some final tweaks this weekend and then you can check them out.
Heres the week in review:
-Linux Mint home networking is now done and working beautifully. Had some trouble getting the onboard Via Chrome9 Video working correctly, but I followed the instructions here(compiling it from source) and everything was great. I wanted to use the OpenChrome driver instead of the VESA driver because the OpenChrome one has support for XvMC which accellerates all kinds of video (i.e. Xvid, mpeg4…). Only thing left to do is get a static IP so I can get to my machine from the outside world.
-Royner - I haven’t had much time to work on ironing out any of the kinks before a first release. Hopefully this week will be different. Thinking about Slicehost to host it, as I’ve heard great things about them. I’m also going to try out deprec for deployment, using Nginx instead of Apache. Should be interesting.
![]()
Other than thats, its another work week. See ya’ll.
I’m happy to say that I’m almost done with my newest project - Royner. It doesn’t live anywhere yet, just on my local machine, but heres what it is:
Really simple - you give Royner a feed (Atom, RSS, XML) and Royner monitors that feed for some keywords that you define. So, lets say you want to monitor the Slickdeals.net RSS feed of deals for “FAR” (Free after rebate). When something is posted that is free after rebate, Royner will send you an IM letting you know of the deal and the url. You could use it for whatever you want. Monitor blogs, Digg, hell, even your email.
Currently, only Jabber/GTalk is supported since it is the easiest to integrate.
Pretty neat eh?
Heres some screenies. Hopefully it will be ready for the public in a week or so.
![]()
![]()
![]()
The one thing I’ll say is this though - I used backgroundrb to monitor the feeds. Now, once I got it running ok, it worked wonderfully, but I swear it was the most difficult Rails plugin to get working. I spent an ENTIRE day trying to get it to work. In the end, I uninstalled and reinstalled the plugin and that did it. The first time I installed, for some reason an old version was installed and none of the documentation worked. Blah.
First I apologize, I’m watching Rambo III as I write this (preparing for the new Rambo {!!!!!}coming out this Friday) so I may screw some of this up.
This all started with a couple of great deals I saw on slickdeals.net.
1. Got 5 x 1024mb sticks of DDR2 667 Ram for $7 shipped after rebate.
2. Got a cheap (AM2) mATX ASUS mobo, case, and PSU for $50 shipped.
So, I ordered a Athlon X2 4000+ for $55 while I was at it. This got me a cheap as hell backup pc($112 for a dual core PC w/4 gigs ram and an extra stick for a rainy day). I already had a spare optical drive and an old IDE 40gig hard drive to throw at it. I’m not going to be using it for anything needing 3-d acceleration, so I’m going to stick with the onboard video.
Now, a while back I made a MythTV box consisting of the following:
Core 2 Duo e4300
1024mb ddr2 800mhz
2×320gig harddrives
Nvidia 7300gt
DVDRW
pcHDTV tv tuner (for DVR functionality)
running Linux Mint (didn’t have to install all those codecs)
Old Antec case and an Antec Earthwatts PSU (go green).
NOTE: having a HTPC has changed my life. Just like people who have TiVo will tell you, its awesome. I could never go back. You could put together a decent one for $300-400 if you tried and its wayyy worth it.
It works pretty well, and I know that its pretty high powered for a htpc, but I needed it to handle 1080p x264 rips, which the C2D can. I’ve got about 400 gigs of music, movies, and tv rips on it.
So here is the plan:
The new AMD build will be the front end, mainly running Mythtv and the current pc will be Jen’s computer/the server. Right now, I’ve setup Samba shares for all the media, and set up Firefly (aka mt-daapd) to share all the music as an iTunes share (for my Macbook Pro). I’m also going to use it as a Subversion repository.
So, tomorrow the parts for the AMD build will be here and I’ll have to transplant some parts to it - the TV tuner, possibly the vid card (we’ll have to see how the x2 4000+ handles video.. I hope it can handle HD x264 since the 7300gt won’t help with it. I’ll setup a fresh install of Mit + MythTv and be in configuration heaven for the majority of the night I’m guessing.
Stay tuned.
Thats as far as I got tonight. My crappy D-Link router was giving me trouble so I didn’t get as far as I wanted. Wish DD-Wrt would run on it.
Since I started my nice cushy “high paying” job, Jen and I have been putting quite a bit of money away (in preparation for the move and for a rainy day) and paying down our debt. We’ve got some moola stored away in a ingdirect savings account thats collecting a nice 4.1% interest rate, but I’ve been toying with the idea of playing the stocks.
A couple of months ago I opened a dummy portfolio at money.cnn.com using their ‘live portfolio’ do hickey. I’ve got next to zero experience with the markets. Our 403(b) is invested in the Vangaurd S&P 500 Index fund(hey can’t argue with 11% historic returns), but thats about it. My state pension I really have no control over. Thats the extent of our investments.  So I opened that dummy account to see what I could do.
Well, the first two weeks were great. Made about 10% with my mostly tech stock portfolio. The last two weeks, I’ve lost all that 10% and then another 10. So I’m down right now. Kind of glad it is fake money at this point, but I think this summer, when I’m hoping the market bottoms out, I’ll be ready to actually drop a couple grand on a real portfolio and get some good stocks for cheap.
I must admit I’m learning a ton. I’ve actually begun watching CNBC in the moring before work, bought Jim Cramer’s new book, and check the portfolio about 3-4 times a day. Its fun if anything.
Its a sad day. My iPod finally quit on me. I’m not exactly sure what is wrong with it, but it has served me well(3 years!).
Oh well, guess that means I should get an Touch. Or I could just do the cool thing and get an iPhone, but then I’d have to switch to AT&T or hack the iPhone to work with T-Mobile. I like my cheap-as-hell-but-oh-so-awesome plan with Sprint I have now though. $30 for unlimited text, data, and 500 minutes isn’t bad. Besides, I don’t use my cell enough to justify it.
Farewell iPod, you were my best friend for a long time.
Yeah, I came up with this little Rails rake task called ‘rake leaves’. It will just create a text file that has all your tables, column names, and their data types. I’ve always thought it would be handy to have this so you don’t need to switch to MySQL and spend the time to look it up.
Anyways, if you want to download it go for it. All you need to do is put leaves.rake in /lib/tasks and then from the console
$rake leaves
You’ll get a file called table_structure_whatever_the_date_is.txt.
You can download if right here.
This morning there was a guy in the rails IRC room asking about using helpers in his controller and I recently wrote an app that used the great pdf-writer gem to generate some pdfs and used helpers in the controller for formatting in the pdf. If you are going to generate very complicated pdfs, its best not to put your pdf formatting code directly in the controller, but if you need just a real quick pdf generated, this works great.
First, create a new class in your application controller:
class Helper
include Singleton
include ActionView::Helpers::PdfHelper #or whatever helpers you want
end
I wanted to use my pdf_helpers
..and then:
def pdf_helpers
Helper.instance
end
Will create an instance of your new class.
Now, go to your pdf controller (or whatever) and simply:
pdf.text pdf_helpers.my_crazy_helper(@foo.bar)
The pdf.text part is not the important part, thats just for pdf-writer, but what is is using “pdf_helpers.your_helper” to create a new instance of the helper class which will allow you to use that helper.
Latest Entries
Archives
Categories
- backgroundrb (1)
- Debt (2)
- Drupal (1)
- Family (3)
- Geeky (4)
- Google (1)
- Grandma's Marathon (1)
- happenings (1)
- iPod (1)
- Linux (4)
- Minnesota (1)
- money (1)
- MythTv (1)
- nginx (2)
- PHP (3)
- Programming (6)
- Rake Leaves (1)
- Royner (5)
- Ruby On Rails (10)
- Slicehost (2)
- stocks (1)