Finally capistrano deployment

Posted on Thu Jun 21 @ 16:00:13

Today I managed to get capistrano deployment finished. I’ve never used capistrano before and it took me a few hours to set it up but at the end I managed it. :)

I’m using bzr as my VCS and mongrel_cluster behind nginx as web server so I had to customize the config/deploy.rb script. Also I’m using capistrano 2.0. Here is my config/deploy.rb:


    set :application, "munitic.com.hr" 
    set :repository,  "/opt/repo_mirror/#{application}" 
    set :deploy_to, "/var/www/apps/#{application}" 
    set :scm, :bzr
    set :checkout, "branch" 

    role :app, "www.munitic.com.hr" 
    role :web, "www.munitic.com.hr" 
    role :db,  "www.munitic.com.hr", :primary => true

    namespace :deploy do
      desc "Restart mongrel cluster" 
      task :restart, :roles => :app do
        run <<-CMD
          cd #{current_path} &&
          mongrel_rails cluster::restart
        CMD
      end

      task :start, :roles => :app do
        run <<-CMD
          cd #{current_path} &&
          mongrel_rails cluster::start
        CMD
      end

      task :stop, :roles => :app do
        run <<-CMD
          cd #{current_path} &&
          mongrel_rails cluster::stop
        CMD
      end
      task :before_update_code do
        `bzr push sftp://munitic.com.hr/opt/repo_mirror/#{application}`
      end

      task :after_update, :roles => :app do
        run "ln -s /var/www/apps/#{application}/shared/photos 
              #{current_path}/public/photos" 
      end
    end

I’ve used tips from here. I hope this helps someone!

Posted in Rails, 0 Comments Comments

Comments feed, looking for ideas

Posted on Thu May 17 @ 21:42:01

Today I managed to implement comments feed for the blog in about 5 minutes including deployment and mongrel cluster restart :) Now I’m looking for ideas what to implement next. If you have any suggestions please do drop a comment.

This adventure of learning rails by coding my own blog is really going well. Any comments are welcomed. I’m quite happy with the results so far. I’m also satisfied with the ease of development using rails and the wealth of plugins it has.

Now it would be really nice if I could use it on the job, but that wont happen simply because my firm is M$ only. Well thats life. It sucks I know :) Rails is so much more fun to code with. Testing with rails is simpler and better integrated than in ASP.NET. Also the code is shorter and more to the point and beautiful. All in all it as pure joy to code this blog engine of mine and I’ll continue to do so until I run out of ideas :)

As I said before, any comments, ideas are welcomed.

Posted in Rails, 3 Comments Comments

MetaWeblog API, Exception Notifier

Posted on Sun Apr 29 @ 23:08:08

Just today I implemented the MetaWeblog API for this blog and this post was published using ScribeFire plugin for Firefox. I followed the instructions from this blog post. It was really easy to follow the instructions and implement it into my custom blog. The only problem I’ve had was that I have a model named Category and because of that I had to change the Category ActionWebService::Struct name (I’ve used AWSCategory :).

A week or so ago I also implemented exception notification. Now every time an exception is raised inside my blog a mail is sent to me with the remote ip, user agent, url and the exception backtrace. Because of this I was able to fix some url bugs I didn’t noticed at first.

As for my injury I’m now fine and my foot has recovered. I still feel some small pain but the doctor said it will pass in a couple of days. For now I will not play any football or cageball, but I will do cycling if the weather permits it.

Update:

I’ve replaced acts_as_attachment plugin with attachment_fu. I only needed to replace acts_as_attachment with has_attachment in the model and move the public/#{table_name}/#{photo.id} folders to public/#{table_name}/0000/00#{photo.id}/ folders because of some changes in the attachment_fu namely this from file_system_backend.rb:36 in the backends folder of the attachment_fu plugin:


    def partitioned_path(*args)
        ("%08d" % attachment_path_id).scan(/..../) + args
    end

Posted in Rails, 0 Comments Comments

Replace apache for nginx

Posted on Tue Apr 17 @ 14:58:47

So today I replaced apache2 with nginx on my slice at slicehost and here is how I've done that.

First of all download nginx form here and unpack it somwere. The installation is a standard source installation. I've done it like this on my Debian Etch slice.



    # ./configure&nbsp; --with-http_ssl_module 
       --sbin-path=/usr/local/nginx \ 
       --conf-path=/usr/local/nginx/nginx.conf \
       --pid-path=/usr/local/nginx/nginx.pid 
    # make
    # sudo make install


After that I've customized nginx.conf for my needs following this example and I also used this startup script that I also customized. Now all that I needed to do was to copy the nginx startup script into /etc/init.d, make it executable, stop apache and start nginx. 



    # sudo cp /somewhere/nginx /etc/init.d/nginx
    # sudo chmod +x /etc/init.d/nginx
    # sudo update-rc.d nginx defaults
    # sudo update-rc.d -f apache2 remove 
    # sudo invoke-rc.d apache2 stop<br />
    # sudo invoke-rc.d nginx start


And that's it. Hope it helps someone :)
I will still keep apache installed. I might have some use of it somewhere or sometime :)

P.S. The nginx.conf example I am refering to is customized for a rails application using a cluster of two mongrel instances. For other examples please see here.

Posted in Linux, 2 Comments Comments

Photo commenting in the gallery

Posted on Mon Apr 16 @ 12:34:41

Thanks to the amazing rails web framework I was able to add photo commenting in the gallery in less than an hour. And I'm a rails newbie.  Just click on an image in the gallery and when lightbox2 finishes its job you will see a link called "Comments". If you click on it you will be redirected to the commenting page for that picture.

In other news, today I found out I would not go to the WinDays conference held in Opatija, Croatia because of my cageball injury. I have an appointment with the doctor on the 23rd. when I will find out if the casts are history or not. The WinDays conference starts on the 23rd. so no Opatija for me.

So bye bye Opatija see you next year :(

Posted in Rails, 0 Comments Comments

About me

Me
Full name: Ivica Munitic Age: 30
Profession: Developer
Email: ivica@munitic.com.hr

Latest articles

Categories

Archive

Feeds

Log in



 

Webfaction