Capistrano recipe to restart standalone passenger server

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

Problem
You want to be able to use different ruby versions with passenger and by following the article here, you have set up your server to server the second version with a standalone passenger version. If you do that you cannot use the ‘touch tmp/restart.txt’ command to restart the standalone passenger server.

Solution
What you would need to do in your config/deploy.rb file, and assuming that your standalone passenger runs on a port (4000) different from the default (3000), is to replace the following:

with

Find out the repositories permissions in gitolite

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

Problem

You would like to know what permission and for which repositories you have as a certain user when using gitolite to host your repositories.

Solution

Assuming that your gitolite user is gitolite and you have two different servers (server_a and server_b) with two different users (deploy_a and deploy_b) you can find out the permsissions by running the following:

Capistrano staging/production/demo recipe for precompiling assets

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

Problem

You have upgraded to rails 3.1.x, 3.2.x and you want capistrano to automatically precompile your assets and do the deployment in your various deployment environments (staging. production, demo etc).

Solution

First add a new directory in your server’s shared folder named assets

Then add the following line to your Capfile:

And finally have your deploy environment file (deploy/staging.rb | deploy/prodution.rb) as follows:

Javascript file not compiled in production with Rails asset pipeline

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

Problem

You have updated your application to the new 3.1.x or 3.2.x rails, and you are using the new asset pipeline.
You have a javascript file (example.js) that is only called in a specific view or conditionally (especially for css).
The application works fine in the development environment but when deploying in the production (or staging) server, you get an error like the following in the log file:

Solution

As the new asset pipeline puts everything together in one file, your file that is called from a different place cannot be found.
Even if you include your example.js in the application.js manifest file with a //= require example, you still get the same error.
It is possible to compile a single javascript file separately from all the other ones.
So what you have to do is include the following into your necessary environment file (staging.rb, production.rb etc), or in the application.rb file if it going to be used in more than one environments.

Make sure that you include the .js in the code above, and then redeploy with capistrano cap staging|production deploy.

Using Postfix to send out emails from development environment in Rails

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

Problem

You want to be able to send emails from your development enironment using Postfix in your (K)Ubuntu pc.

Solution

First you would need to install postfix:

and then you would need to change an option in postfix to not use tls, so change /etc/postfix/main.cf:

and change the smtpd_use_tls from yes to no:

restart your postfix server:

and then setup your config/development.rb as follows:

Command line mail message with postfix in (K)ubuntu

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

Problem

You have installed postfix in your local development machine (sudo apt-get install postfix), and you want to test sending emails from the command line using mail email_address@someone.com

 

Solution

You would first need to install the mailutils package:

then you can send an email by:

and you can send it by pressing Ctrl+D