crshman's Profile Page

Archive for » April, 2009 «

Monday, April 27th, 2009 | Author:

Hey All,

So today I was finally able to go on a fun photo shoot with Susan! She wanted to learn more about her SLR system and how to take pictures so I figured it’d be a fun trip to go play the role of the teacher for once. We took pictures State Street, the Santa Barbara Pier (Sterns Warf), Santa Barbara Mission and up in the Santa Barbara mountains. Here’s a link to my Gallery and some of my favorite shots are below:

Hope you enjoyed that! =D

Until next time…..Robert

Category: Photography  | Tags:  | Comments off
Thursday, April 23rd, 2009 | Author:

Hey All,

So I have an account over at JaguarPC and I love it a lot there, they support everything I need and help me with all that I ask. However, there seems to be a snafu/caveat what have you to running RoR (Ruby on Rails) apps at JPC. cPanel runs RoRs apps using a mongrel instance, this is fine and it works….but sometimes it dies and needs to be restarted. Highly annoying….I run my redmine installation off of one of these mongrel instances and I really can’t have it be down. So….I devised this little gem below to check if your mongrel instance is down, if so to restart it.

To use the script throw it in your cPanel root and add the following line to your crontab:


*/5 * * * * php ~/reboot.php

Be sure to update the command above to reflect what you named the script…..

Hopefully someone else finds it useful and if you need help with the script comment!

cPanel Ror Mongrel Reboot


<?php
/*
 *
 * cPanel Mongrel Rebooter - v0.1
 * Author: Robert Navarro <[email protected]>
 *
 */

/*
 * The siteCheck function has the following parameters
 *
 * $url - This is the url of the application you want to check
 * $searchString - This is the erroneous string you want search the site for
 * $appPath - This is the full path to your cPanel RoR app installation
 * $appPort - This is the port that your cPanel RoR app runs on
 *
 * You can find the application port by running:
 * # ps aux |grep mongrel |grep <your username>
 *
 */
siteCheck("http://<my redmine install>","502 Proxy Error","~/Sites/<my redmine install>/","12001");

function siteCheck($url,$searchString,$appPath,$appPort) {
 // open the remote URL for reading
 $fp = fopen($url, 'r') or die('Unable to open file '.$off_site.' for reading');

 $buffer = '';

 // read in chunks
 while(!feof($fp))
 {
 $buffer .= fgets($fp, 4096);
 }

 // strip HTML but leave the tags you want
 $output = strip_tags($buffer,'<a>
<ul>
	<li>
<h2>
<h1><span>');

 // convert all whitespace, tabs and newlines into one single whitespace
 $output = preg_replace('/\s+/', ' ', $output);

 if(strstr($output,$searchString)) {
 restart($appPath,$appPort);
 }
}

function restart($path,$port) {
 exec("cd $path;mongrel_rails start -p $port -d -e production -P $path/log/mongrel.pid");

}
?>

Category: Development  | Tags:  | 5 Comments