Drb log file tailer.

Posted by ezmobius Thu, 04 May 2006 17:04:21 GMT

Hot on the heels of my drb progress bar worker plugin is a new feature for it. THis one is an ajax log file tailer. Here’s a sneak peek.

Drb Log FIle Tailer

1 comment

Preview of DRbWorker plugin with ajax progress bars.

Posted by ezmobius Thu, 04 May 2006 03:31:00 GMT

So here is a little screencast preview of my next plugin. I got the proof of concept working today. You will be able to register your own classes that do long running background tasks with the drb server. And then start your classes from an ajax call. Then you periodically_call_remote to grab the progress of your worker which is access via a key you store in the session. This is the concpet:



Have a look at the screencast of the proof of concept in action.

View ScreenCast

I am planning to finish this up and have it ready to be released as a plugin soon ;-)

Tags ,  | 8 comments

Dead Simple Deployment

Posted by ezmobius Wed, 26 Apr 2006 05:20:00 GMT

I have been experimenting with mongrel clusters for the past week or so. I tested pound, balance and finaly settled on pen http://siag.nu/pen/ for a load balancer in front of the mongrel cluster. Pen was the fastest out of those three load balancers in my tests, and is dead simple to set up.

I created a pool of 6 mongrels on my macbook pro and ran pen in front of them. I was able to get 800-900req/sec for static files and 70-150 req/sec for dynamic full blown rails pages. It was also rock solid. I abused the hell out of it with httperf and ab and was very impressed with the performance and stability.

I want to say a huge thank you to Zed Shaw (author of mongrel) and the folks supporting his effort finacially. Mongrel is an awesome addition to the ruby world.

Not once did I get any 500 errors or zombied mongrel processes.

Pen can do either round-robin balancing or ‘sticky session’ adaptive routing. ‘sticky sessions’ means that you can get session affinity between requests. But in my tests round-robin was faster by a little bit. And if sessions are in the db or memcached or drb then sticky sessions don’t matter.

Here is a simple way to test this setup out for yourself. First compile pen:
$ curl -O http://siag.nu/pub/pen/pen-0.17.0.tar.gz
$ tar xzvf pen-0.17.0.tar.gz
$ cd pen-0.17.0
$ ./configure
$ make
$ sudo make install
Lets install the mongrel & mongrel_cluster gems
$ sudo gem install mongrel mongrel_cluster --include-dependencies
mongrel_cluster is a gem plugin for mongrel that makes it easy to manage a cluster of mongrels. Thanks to Bradley Taylor for making this available. You can read his blog about it here: http://fluxura.com/articles/2006/04/24/easy-mongrel-clustering-with-mongrel_cluster. Lets configure our rails app to use it. cd into your rails application’s root directory and run:
$ mongrel_rails cluster::configure -p 5000 -e production -a localhost
This will create the file:
$ cat config/mongrel_cluster.yml
--- 
num-procs: 1024
docroot: public
timeout: 120
cwd: /Users/ez/ez
log_file: log/mongrel.log
port: 5000
config_script: 
debug: false
environment: production
servers: 6
pid_file: log/mongrel.pid
address: localhost
mime_map:
This is the config file that the cluster::configure just made. The only thing I changed was the number of servers: which i set to 6. Now lets start the mongrel cluster:
$ mongrel_rails cluster::start
You can now stop or restart the cluster with these commands:
$ mongrel_rails cluster::stop
or
$ mongrel_rails cluster::restart
Then once the cluster is running we can fire up pen. This command runs pen in debug mode in the foreground so you can see the requests being handled by different mongrels. This is also using round robin. If you turn off -d(debug) and -f(foreground) it will be a little bit faster still.
$ sudo pen -r -a -f -d  localhost:80 localhost:5000 localhost:5001 \
localhost:5002 localhost:5003 localhost:5004 localhost:5005 localhost:5005

With pen running in the foreground and debug mode like this you can see pen balancing requests between our six mongrels. You will want to turn off the -d and -f switches when you want to run in production.

Then you can go use ab or preferably httperf to test the setup. I think you will agree this little pack of wolves…err.. mongrels is hungry! ;-)

I am very impressed with this setup and it consumes very little resources. Pen is the fastest, lightest HTTP load balancer that can be a front end for https as well, that I could find for free. Its about 5-10% faster then balance and pound in my tests. And I am getting better performance with this setup then I do with lighttpd->standalone fcgi listeners on my macbook.

Very cool stuff.

EDIT: With this type of setup you will need one IP address for each app you want to run. Or you can put lighty or apache in front of pen to use vhosting capabilities. I will post more instructions on how to do this if people need to see them.

Tags , , ,  | 69 comments

RailsConf Talk Suggestions?

Posted by ezmobius Wed, 19 Apr 2006 19:27:00 GMT

I will be speaking about Rails Deployment amongst other things during my talk at RailsCONf this June in Chicago. I wanted to open up a discussion here about what the audience would like to have me cover.

So this is your chance to let me know what topics or issues you would like to hear about. Mostly the talk will cover deployment issues and server setups and whatnot. But I do have a few tricks up my sleeve as well ;)

So tell me what you want me to talk about in the comments and you can help shape my presentation!

Tags , , , , , , ,  | 8 comments

Rails Workshop For Good

Posted by ezmobius Mon, 10 Apr 2006 04:28:00 GMT

I’m proud to announce the Workshop For Good Rails class I am teaching.
http://www.workshopforgood.org

It is a two day intensive workshop teaching Ruby on Rails. I will be teaching it along with Jeff Casimir and Amy Hoy of slash7 fame.

The workshop will take place Saturday, May 20th and Sunday, May 21st from 9AM to 5PM. All activities will take place at the César Chávez Public Charter High School Capitol Hill campus at 709 12th Street SE, Washington, DC, 20003.

This workshop is cool because all proceeds go to benefit the César Chávez Public Charter School. This is an underfunded public high school in DC.

I am donating my time to teach the class because I believe in helping out where I can. The two day workshop is only $400($200 for students) So it is a bit cheaper then other rails workshops I see going on. If you can make it to DC in late May please do. The class is targeted at beginner/intermediate Railers. But I promise to cover whatever you want to see if you are already more advanced with rails.

This is a great cause so please people, link to this site or blog about it a bit would you? I would love to sell out and give this high school as much funds as we can ;-)


http://www.workshopforgood.org

Tags , ,  | 2 comments

My RailsConf talk proposal was accepted!!

Posted by ezmobius Thu, 16 Mar 2006 23:47:00 GMT

So I just found out that my talk proposal to speak at the First Internationl RailsConf was accepted!

I am totally stoked and honored that I was chosen. There were a ton of talk proposals to go through to come up with a final decision and I am very happy to say that I made the final cut.

My talk will be about rails deployment. And I hope to have the beta release of my Rails Deployment book released in pdf form before RailsConf.

Thanks to the organizers of RailsConf and a deep thanks for letting me speak. This event will go down in history as rails mindshare grows and grows. It’s been an exciting ride on the rails for me. I stumbled upon rails when I was trying to decide whether to learn python or ruby as a step up from PHP. The original screencast sealed my fate and the last 19 months on rails has been an eye opener to say the least.


I will see you all at RailsConf and look forward to putting faces to all the names of folks I know from irc or the rails and ruby-talk mailing lists and all the other railsers I only know from cyberspace.


irb(main):003:0> Ezra.respond_to? :stoked
=> true

Tags , , , , , , ,  | 6 comments

A hint of what's to come...

Posted by ezmobius Tue, 28 Feb 2006 00:46:00 GMT

Here are a few screens of what’s next ;-)

Tags , , ,  | 8 comments

Intel iMac

Posted by ezmobius Mon, 27 Feb 2006 23:01:13 GMT

So Last week I got a 17” intel iMac because I really wanted one and my 17” powerbook was on its last leg and needed to be sent to AppleCare.

Just a few quick notes here… It is great, and excellent machine for $1299! Compiling source code feels like a snappy linux box, the text fly’s by instead of crawling. And most things are just more responsive. So if anyone is teetering on the edge, go ahead and get one you will be happy with it.

I am also getting a new macbook pro provided by my new job(Yay!) so i will be rocking the all intel OSX scene soon. These machines are awesome and one of the coolest things to happen to osx in a while.

4 comments

A new job for me.

Posted by ezmobius Mon, 27 Feb 2006 22:08:00 GMT

So I am moving on from my job at http://yakimaherald.com. I have taken a job in Spokane WA working for a software development company that develops software for the insurance industry. Not the sexiest industry but I will get to do all ruby and rails programming on debian and freebsd servers so it is the sexiest technology ;^)

So my old job at the Yakime Herald Newspaper is up for grabs. And the company is willing to relocate the right candidate. So if you are interested in a very fun job working with nice people doing rails/ruby work then check out the job and send in a resume. You can see the job posting and get contact info here: http://jobs.rubynow.com/jobs/show/201

Tags  | 8 comments

New plugin acl_system

Posted by ezmobius Mon, 20 Feb 2006 07:20:00 GMT


UPDATE! NEW REPO URL & FEATURES!


Welcome to the acl_system plugin for rails. This plugin is designed to give you a flexible declarative way of protecting your various controller actions using roles. It’s made to site on top of any authentication framework that follows a few conventions. You will need to have a current_user method that returns the currently logged in user. And you will need to make your User or Account model(or whatever you named it) have a has_and_belongs_to_many :roles. So you need a model called Role that has a title attribute. Once these two things are satisfied you can use this plugin.

So lets take a look at the sugar you get from using this plugin. Keep in mind that the !blacklist part isn’t really necessary here. I was just showing it as an example of how flexible the permissions string logic parser is.
class PostController < ApplicationController
  before_filter :login_required, :except => [:list, :index]
  access_control [:new, :create, :update, :edit] => '(admin | user | moderator)',
                 :delete => 'admin & (!moderator & !blacklist)' 
Of course you can define them all seperately if they differ at all.
class PostController < ApplicationController
  before_filter :login_required, :except => [:list, :index]
  access_control :new => '(admin | user | moderator) & !blacklist',
                 :create => 'admin & !blacklist',
                 :edit => '(admin | moderator) & !blacklist',
                 :update => '(admin | moderator) & !blacklist',
                 :delete => 'admin & (!moderator | !blacklist)' 
And you can also use :DEFAULT if you have a lot of actions that need the same permissions.
class PostController < ApplicationController
  before_filter :login_required, :except => [:list, :index]
  access_control :DEFAULT => '!guest' 
                [:new, :create, :update, :edit] => '(admin | user | moderator)',
                 :delete => 'admin & (!moderator & !blacklist)'
There are two callback methods you can use to define your own success and failure behaviors. If you define permission_granted and/or permission_denied as protected methods in your controller you can redirect or render and error page or whatever else you might want to do if access is allowed or denied.
class PostController < ApplicationController
  before_filter :login_required, :except => [:list, :index]
  access_control :DEFAULT => '!guest' 
                [:new, :create, :update, :edit] => '(admin | user | moderator)',
                 :delete => 'admin & (!moderator & !blacklist)'

  # the rest of your controller here

  protected

  def permission_denied
    flash[:notice] = "You don't have privileges to access this action" 
    return redirect_to :action => 'denied'
  end

  def permission_granted
    flash[:notice] = "Welcome to the secure area of foo.com!" 
  end

end
There is also a helper method that can be used in the view or controller. In the view its handy for conditional menus or stuff like that.
<% restrict_to "(admin | moderator) & !blacklist" do %>
  <%= link_to "Admin & Moderator only link", :action =>'foo' %>
<% end %>
So the gist of it is that in the access_control controller macro, you can assign permission logic strings to actions in your controller. You supply a hash of :action => ‘permissions string” pairs. Any action not in the list is left open to any user. Any action with a logic string gets evaluated on each request to see if the current user has the right role to access the action. The plugin has a small recursive descent parser that evaluates the permission logic strings against the current_user.roles.

The way this works is that you have your User model and a Role model. User <= habtm => Role. So when an action that is access_control’ed gets requested the permission logic string gets evaluated against the current_user.roles . So a prerequisite of using this plugin is that you add a Role model with a title attribute that has_and_belongs_to_many User models. And you need to have a current_user method defined somewhere in your controllers or user system. Luckily the acts_as_authenticated plugin has the current_user defined already.

So here is the schema of this application including the Post model and the User and Role model plus the habtm join table:

ActiveRecord::Schema.define(:version => 3) do
  create_table "posts", :force => true do |t|
    t.column "title", :string, :limit => 40
    t.column "body", :text
  end
  create_table "roles", :force => true do |t|
    t.column "title", :string
  end
  create_table "roles_users", :id => false, :force => true do |t|
    t.column "role_id", :integer
    t.column "user_id", :integer
  end
  create_table "users", :force => true do |t|
    t.column "login", :string, :limit => 40
    t.column "email", :string, :limit => 100
    t.column "crypted_password", :string, :limit => 40 
    t.column "salt", :string, :limit => 40
    t.column "created_at", :datetime
    t.column "updated_at", :datetime
  end
end

And so thats pretty much it for now. You add the roles to the Role.title attribute like admin, moderator and blacklist like above. These can be anything you want them to be, roles, groups or whatever. Then you can use as many nested parens and logic with & | ! as you want to define your complex permissions for accessing your controller. Make sure that your access_control gets called after the login_required before_filter because we assume that you are already logged in if you made it this far and then we eval the permissions logic.

You will want to define these access_control in each controller that needs specific permissions. unless you want to protect the same actions in all controllers, then you can put it in application.rb but I dont recommend it.

Stay tuned as I will be adding another macro method to use in your models to define precisions permissions for accessing your models soon. All suggestions or critiques are welcome.

You can get it here from svn. Keep in mind this is alpha stuff and subject to change so check back for updates and please report any bugs.

http://opensvn.csie.org/ezra/rails/plugins/dev/acl_system2/

Tags , , ,  | 71 comments

Older posts: 1 ... 11 12 13 14 15