« March 2008 | Main | June 2008 »
April 30, 2008
Multiple Rails applications with mod_rails on Ubuntu
It works as advertised!
The installer provides exhaustive built-in documentation, describes every step and suggests solution for every unmet requirement like “please install Apache headers with apt-get install apache2-prefork-dev
”. Other guys and we all can learn a lot
from mod_rails about how a perfect installer looks like.
At the end of the installation process it asks to put three configuration lines into apache configuration file although it does not tell how. According to online documentation the requirement is that these lines should be only executed once.
So my solution (in Debian way) is to
- create new passenger.load file in /etc/apache2/mods-available
- create a symbolic link to it
a2enmod passenger
Then I followed the documentation. But I had to make an additional change
to enable the FollowSymLinks
.
It was also not clear from the documentation how to set up multiple applications to the same VirtualHost and that RailsBaseURI
is allowed multiple times. So I had to experiment. Here is the result (works on Ubuntu 7.10):
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName myapps.example.com
DocumentRoot /home/passenger
RailsBaseURI /app1
RailsBaseURI /app2
<Directory /home/passenger>
AllowOverride All
</Directory>
</VirtualHost>
Then for every additional application you need to
- copy your application to some folder, e.g. /home/myprojects/app2
- set owner for your project folder to www-data:www-data
- create a link from
public
folder of your rails application to /home/passenger - add one line to your site configuration
RailsBaseURI /app2
- restart apache
I did not find any way to avoid last two tasks. Hopefully the next version of passenger will offer some sort of wildcard-based mass-RailsBaseURI.
Current mod_proxy advantages:
- no
ActionController::AbstractRequest.relative_url_root
requierd anymore - no obscure
mod_proxy_html
- SSL is now possible for multiple Rails applications on the same server (VirtualHosts on the same IP address do not work with SSL)
TODO:
- did not have time yet to configure with capistrano, simply checked in the file `tmp/restart.txt’. Every time I do ‘svn update’, the application is automatically restarted.
Posted by VladimirDobriakov at 9:15 PM
April 16, 2008
Create the most scalable HelloWorld application in the world with Google App Engine
If you have the luck to use the programming language and technology that Google uses, then you can use Google App Engine to host your web application and scale almost indefinitely.
Google App Engine is very different to Amazons’s approach.
- it serves code, so no virtual machines
- for web applications only (based on WSGI). WSGI is the de facto standard interface between a web server and a web application or framework in the Python world
- App Engine includes Python runtime (version 2.5.2)
- pure Python, no C extensions allowed
- includes non-relational data-store. Something that feels like tuple spaces?
- plus usual administration stuff
You can start the most scalable HelloWorld application in the world with the following lines:
from google.appengine.ext import webapp
class MyHandler(webapp.RequestHandler)
There will be nothing Google specific in the web part of your application. It is WSGI-based so you can host it at Google or within your own Apache HTTPD through mod_wsgi.
The bigger concern is this special data store, for which no open source replacement exist.
So you can not use a relational database with such distributed system like App Engine, but if you use this Google Datastore then you trapped into a dependency, that can not be removed easily. And introducing an additional abstraction layer for data access is not the way to success with a dynamic programming language, fast development and being happy.
Posted by VladimirDobriakov at 7:00 PM
April 4, 2008
Appearance matters
No, I am not talking about preparation for a date or for an interview. I am still talking about a prototype I am working on. Even if you told that there is no need for special styling and a professional web designer will prepare something two weeks later, and the application should simply work, so it is possible to play around a bit with it.
And because you love the semantical nature of the html you start with a pure html with this scientifical styling. That means no styling at all. But even if you are not a professional designer, exactly like me, you should take one or two hours to create some basic stylesheet to make the user interface pretty less ugly.
- create a rails layout and a partial for the navigation
- put all the items into the menu (even if you are going only to implement one use case / function in your prototype), it will give the page some structure
- use the color schema of the customer Powerpoint presentation for your CSS
- adjust the
display
attribute for relevant elements
For example, if you want the main navigation to be shown in one row at the top of the screen and you have implemented the menu as unordered list <ul>
then put something like
ul.main_menu li {
display: inline;
background-color: orange;
padding: 4px;
font-weight: bold;
}
into your CSS file.
Posted by VladimirDobriakov at 5:00 PM | Comments (0) | TrackBack
April 2, 2008
Rapid Prototyping with Rails
I am currently in Zürich and working on an extemely hot startup project there. The customer heard that with Rails you can prototype pretty fast…
I am working with two experienced Java- and J2EE- developer there, however they did not have any Ruby- or Rails- experience. So my task for this week is to create a prototype and at the same time to spread some Ruby but especially Rails knowledge among developers.
So after tree days:
- we have discussed the requiremnts and the problem domain with the project owner
- everybody has his devenv, mysql running
- new developers are confident in the usage of
rake
, scaffolding andscript/generate
in common, named routes and routing debugging - every developer created (and commited) his part of the model, along with rudimentary (adjusted scaffold-generated) user interface
- we have put some lookup-data into db data migrations
- we had an internal show and decided to make some changes on the workflow and the user interface
It is unbelievable, how much you can achive with learning/teaching Rails provided:
- people are open to the new concepts
- the motivation is high and there is a practical problem at hand
Posted by VladimirDobriakov at 11:01 PM | Comments (0)