Just upgraded to Hardy two days ago. Is it nice? Yes. Is there any problems with it? Yes.
Installation was fast as usual, took around 20 mins. Video settings, sound card, network card ... are all setup and ready to go after the system rebooted itself. Firefox 3 looks better than ever, however, I can't seem to get a connection?!?
What's more weird is that I can actually goto google.com, but everything else will time out on me!
After hours of searching, some dude suggested that I should decrease the MTU (maximum transmission unit) from 1500 (standard for ethernet) to 1492 by typing the following command
sudo ifconfig eth0 mtu 1492
amazingly, my connection is back to normal! (if anyone know why that is, can you please educate me on this issue? I really like to know the reason behind this!)
J
Monday, April 28, 2008
Deployment: Part 2
As I mentioned in the last post, we got past SVN.
We finally came to Mongrel Cluster. This was a major headache. Apparently, Capistrano is broken when it comes to handling Mongrel Cluster. Simply following the Capistrano's site tutorial will not work.
The first step around this was to get the Palm Tree gem on the local machine:
>sudo gem install palmtree
This will include some recipes that we can use with our deploy.rb that you need to run Capistrano.
Next, add this to the top:
require 'palmtree/recipes/mongrel_cluster'
This will include the recipe needed to fix the deployment scripts. Basically, it rewrites the deploy script that comes with Capistrano. All you really need to know is that it works ;)
Next, generate a mongrel_cluster.yml by following the "Mongrel Cluster Setup" in this wiki. Check this into your repository as we'll need it.
Add this line to your deploy.rb:
set :mongrel_conf, "root_of_the_app/config/mongrel_cluster.yml"
Last thing we need to add is to tell Capistrano not to use sudo:
set :use_sudo, false
When all this is finally done, make sure that everything is in your repository. We can now attemtp a deploy:
cap deploy:cold
Make sure you use cold, as this should be the first time you're deploying. A deploy:cold is different than a simple deploy because it assumes that your servers are not running yet. Hopefully everything went right here. This should get you past Mongrel Cluster.
The next would be take a look at how to customize your deploy, such as starting other servers that you would potentially need.
We found the "after_stop", "after_start", and "after_restart" helpful for handling our other servers. Make sure that you put them in the deploy namespace ;)
Good luck!
W
We finally came to Mongrel Cluster. This was a major headache. Apparently, Capistrano is broken when it comes to handling Mongrel Cluster. Simply following the Capistrano's site tutorial will not work.
The first step around this was to get the Palm Tree gem on the local machine:
>sudo gem install palmtree
This will include some recipes that we can use with our deploy.rb that you need to run Capistrano.
Next, add this to the top:
require 'palmtree/recipes/mongrel_cluster'
This will include the recipe needed to fix the deployment scripts. Basically, it rewrites the deploy script that comes with Capistrano. All you really need to know is that it works ;)
Next, generate a mongrel_cluster.yml by following the "Mongrel Cluster Setup" in this wiki. Check this into your repository as we'll need it.
Add this line to your deploy.rb:
set :mongrel_conf, "root_of_the_app/config/mongrel_cluster.yml"
Last thing we need to add is to tell Capistrano not to use sudo:
set :use_sudo, false
When all this is finally done, make sure that everything is in your repository. We can now attemtp a deploy:
cap deploy:cold
Make sure you use cold, as this should be the first time you're deploying. A deploy:cold is different than a simple deploy because it assumes that your servers are not running yet. Hopefully everything went right here. This should get you past Mongrel Cluster.
The next would be take a look at how to customize your deploy, such as starting other servers that you would potentially need.
We found the "after_stop", "after_start", and "after_restart" helpful for handling our other servers. Make sure that you put them in the deploy namespace ;)
Good luck!
W
Saturday, April 26, 2008
Deployment: Part 1
So we're nearing the stage of our deployment and decided to perform a dry run on J's spare computer. We installed the Ubuntu server on his machine, along with all the stuff we needed (SSH, Ruby, Rails, gems, etc.)
We then decided to go with Ubuntu server + Apache + Mongrel Cluster + Capistrano for an action-packed deployment. We decided on Ubuntu since we have had such a good impression with them and have had experience with troubleshooting on an Ubuntu machine. Apache + Mongrel Cluster seems to be a fast-growing standard, although there are many configurations to choose from. We had been doing research and found that this configuration would be the most painless. As well, this configuration is supposed to handle very well. We used Capistrano to help with our deployment and to make maintenance much easier when deploying on a remote server.
Basically, the whole setup revolved around Capistrano. So... off we went to figure out how to use it. This took us a very long time as we had to troubleshoot some problems.
The first problem that was not even mentioned on the Capistrano site was logging into the remote server with a particular username. In the examples, they simply say to just use:
role :app, my.server.com
However, this will log you into the remote server with the username you have with the local machine. This is not what we wanted, so we ended up having to attach the username in front:
role :app, username@my.server.com
Next, when the server was trying to checkout our repository from SVN, it crapped out. We added this to our deploy.rb to get around this:
default_run_options[:pty] => true
Now, our deploy ran fine, until we got to Mongrel Cluster T.T
Hopefully this will get you out of the rough, unless you're using Mongrel Cluster, which I'll cover in the next post.
W
We then decided to go with Ubuntu server + Apache + Mongrel Cluster + Capistrano for an action-packed deployment. We decided on Ubuntu since we have had such a good impression with them and have had experience with troubleshooting on an Ubuntu machine. Apache + Mongrel Cluster seems to be a fast-growing standard, although there are many configurations to choose from. We had been doing research and found that this configuration would be the most painless. As well, this configuration is supposed to handle very well. We used Capistrano to help with our deployment and to make maintenance much easier when deploying on a remote server.
Basically, the whole setup revolved around Capistrano. So... off we went to figure out how to use it. This took us a very long time as we had to troubleshoot some problems.
The first problem that was not even mentioned on the Capistrano site was logging into the remote server with a particular username. In the examples, they simply say to just use:
role :app, my.server.com
However, this will log you into the remote server with the username you have with the local machine. This is not what we wanted, so we ended up having to attach the username in front:
role :app, username@my.server.com
Next, when the server was trying to checkout our repository from SVN, it crapped out. We added this to our deploy.rb to get around this:
default_run_options[:pty] => true
Now, our deploy ran fine, until we got to Mongrel Cluster T.T
Hopefully this will get you out of the rough, unless you're using Mongrel Cluster, which I'll cover in the next post.
W
Friday, April 25, 2008
IE Address Bar
This is really starting to annoy me. In FF, if you type in a URL in the address bar without the http:// and no www, it is smart enough to put them in for you.
However, in IE, without the www, it doesn't know how to prepend the http:// to your address. This gets really annoying when you're constantly trying to go to localhost or a specific IP address for testing.
Sorry for the rant...
W
However, in IE, without the www, it doesn't know how to prepend the http:// to your address. This gets really annoying when you're constantly trying to go to localhost or a specific IP address for testing.
Sorry for the rant...
W
Thursday, April 17, 2008
Responds_to_parent loc error
If the rjs inside your responds_to_parent block ended up removing the iframe from your html page, the loc variable will no longer be defined.
Besides having an ugly error message on your firebug console, it can actually cause problems for the javascripts on that page as well.
In order the get around this problem, you'll need to do the following patches:
in parent_selector_assertion.rb and responds_to_parent.rb
replace all occurrence of
(3 in parent_selector_assertion, 1 in responds_to_parent)
J
Besides having an ugly error message on your firebug console, it can actually cause problems for the javascripts on that page as well.
In order the get around this problem, you'll need to do the following patches:
in parent_selector_assertion.rb and responds_to_parent.rb
replace all occurrence of
(3 in parent_selector_assertion, 1 in responds_to_parent)
loc.replace('about:blank');and that's it!
withif (window.loc) { loc.replace('about:blank'); }
J
Pluralize
Have you ever had to write some sort of if/else condition to display a sentence involving an object count? Something like 1 person, 2 people, etc.
Well, RoR has a nifty little method called pluralize. All you do is feed it the number and a string, and it will attempt to figure out exactly what you want.
For example:
pluralize(1, 'person') # '1 person'
pluralize(2, 'person') # '2 people'
I thought this was pretty neat and wanted to share with you guys. There are a lot of little methods tucked away in the RoR API, and I encourage you to look through them to help minimize your development time on mundane things like this. Enjoy!
W
Well, RoR has a nifty little method called pluralize. All you do is feed it the number and a string, and it will attempt to figure out exactly what you want.
For example:
pluralize(1, 'person') # '1 person'
pluralize(2, 'person') # '2 people'
I thought this was pretty neat and wanted to share with you guys. There are a lot of little methods tucked away in the RoR API, and I encourage you to look through them to help minimize your development time on mundane things like this. Enjoy!
W
Wednesday, April 16, 2008
respond_to + render :partial
RoR has a very quick way to turn your web application into a web service that supports API hooks into your application. It does this using the respond_to method. It's as simple as doing something like:
respond_to do |format|
format.html # automatically calls the corresponding view
format.js #automatically calls the corresponding rjs
format.xml { render :xml => @user.to_xml # or other XML stuff }
end
It's that simple!
Well, there's one odd thing that got me for a little bit. I'm not sure if it's a bug, but when I tried to render a partial in the format.js block, I got an error that it could not find the corresponding template:
respond_to do |format|
format.js { render :partial => 'my_partial' }
end
I found that very odd, but not fixable... I tried adding '.html.erb' to the end of my_partial:
format.js { render :partial => 'my_partial.html.erb' }
And magic! It worked! I'm almost sure this isn't the way RoR is suppose to handle this, but in the meantime, it works! Small hack, but I'm happy :D If any one else runs into this problem, drop a comment, or even better, if you know why or how to solve this, let me know!
W
respond_to do |format|
format.html # automatically calls the corresponding view
format.js #automatically calls the corresponding rjs
format.xml { render :xml => @user.to_xml # or other XML stuff }
end
It's that simple!
Well, there's one odd thing that got me for a little bit. I'm not sure if it's a bug, but when I tried to render a partial in the format.js block, I got an error that it could not find the corresponding template:
respond_to do |format|
format.js { render :partial => 'my_partial' }
end
I found that very odd, but not fixable... I tried adding '.html.erb' to the end of my_partial:
format.js { render :partial => 'my_partial.html.erb' }
And magic! It worked! I'm almost sure this isn't the way RoR is suppose to handle this, but in the meantime, it works! Small hack, but I'm happy :D If any one else runs into this problem, drop a comment, or even better, if you know why or how to solve this, let me know!
W
Subscribe to:
Posts (Atom)