Tag Archive for 'ruby'

Tickling ruby apps every 5 minutes

I posted a while ago about the problems on DreamHost killing my ruby applications’ start-up. Currently I have a solution, yet it is experimental and certainly not reliable. To tickle the application every 5 minutes, the application processes won’t be idle and won’t be turned off by DreamHost. Since my application don’t get much traffic, I need this desperate measure to keep the application from dying. In return, I can access the applications in an instant as if they were  PHP applications.

My web application is small and lightweight since it uses Sinatra which is a very light framework, so I know it won’t be needing much resources. The starting up is the only problem, since running ruby applications on DreamHost creates a sudden spike on the ram by starting up.

To tickle the application, you need to create a cron job that will visit the application every 5 minutes.

*/5 * * * * /usr/bin/curl http://your-domain.com/ -s -o /dev/null

I noticed some odd behavior though. When you try to run another ruby application on the same server, the loading of my ‘tickled’ applications are also being delayed.

I had this idea a long while ago, and when I saw that this method being used by other ruby users hosted on DreamHost, I decided to try it out too.

Thinking of purchasing VPS Hosting

DreamHost has changed their rules lately. They have a script running which  kills processes that goes over their limit of 153600.00. That is of course since I’m hosted on a shared server, so they’re killing the processes calling my ruby applications.

2009-11-13 11:37:52 procwatch2 INFO: Process(pid=26603, name=’ruby1.8′, uid=thisismyid(#####), tty=None, cpu=4.6, rss=100552.0, vsize=174236.0): kill for total RAM (50276.00 self, 157280.00 total exceeds limit 153600.00)

When trying to access any of my ruby applications, even the Sinatra-powered ChanLu Dev, it takes more than a minute to load compared before when the loading time took only five seconds. There are other ruby applications I’m using, like Tracks and Redmine that I can’t live without. Also, I really don’t want to use other programming language for ChanLu. Let’s just say Ruby got me, and it took my heart away.

I know that I do need a private server if I want to host ruby applications, DreamHost also advised me to get one. I’m planning to purchase a VPS plan on another hosting company, because they’re more affordable. I just hope to have some more money to finance on this.

Error in installing do_mysql on Mac OSX

I’m not a fan of macs, and to add to my depression, Mac OSX have problems in installing the gems mysql and do_mysql. I tried the workaround found here. It didn’t work on the machine I’m using. The error I’m experiencing now is:

Building native extensions. This could take a while…
ERROR: Error installing do_mysql:
ERROR: Failed to build gem native extension.

/usr/local/bin/ruby extconf.rb –with-mysql-dir=/Applications/MAMP/Library –with-mysql-config=/Applications/MAMP/Library/bin/mysql_config
checking for mysql.h… *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

Provided configuration options:
–with-opt-dir
–without-opt-dir
–with-opt-include
–without-opt-include=${opt-dir}/include
–with-opt-lib
–without-opt-lib=${opt-dir}/lib
–with-make-prog
–without-make-prog
–srcdir=.
–curdir
–ruby=/usr/local/bin/ruby
–with-mysql-config
/usr/local/lib/ruby/1.9.1/mkmf.rb:362:in `try_do’: The complier failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /usr/local/lib/ruby/1.9.1/mkmf.rb:431:in `try_cpp’
from /usr/local/lib/ruby/1.9.1/mkmf.rb:809:in `block in have_header’
from /usr/local/lib/ruby/1.9.1/mkmf.rb:668:in `block in checking_for’
from /usr/local/lib/ruby/1.9.1/mkmf.rb:274:in `block (2 levels) in postpone’
from /usr/local/lib/ruby/1.9.1/mkmf.rb:248:in `open’
from /usr/local/lib/ruby/1.9.1/mkmf.rb:274:in `block in postpone’
from /usr/local/lib/ruby/1.9.1/mkmf.rb:248:in `open’
from /usr/local/lib/ruby/1.9.1/mkmf.rb:270:in `postpone’
from /usr/local/lib/ruby/1.9.1/mkmf.rb:667:in `checking_for’
from /usr/local/lib/ruby/1.9.1/mkmf.rb:808:in `have_header’
from extconf.rb:55:in `’

Gem files will remain installed in /usr/local/lib/ruby/gems/1.9.1/gems/do_mysql-0.10.0 for inspection.
Results logged to /usr/local/lib/ruby/gems/1.9.1/gems/do_mysql-0.10.0/ext/do_mysql_ext/gem_make.out

I don’t know even know what these development tools the error message is talking about. I was able to install all the other gems I needed except for these two. I do hope I’ll come across with a solution for this. Specially when I’m not used to the development environment on Mac Computers.