Manage multiple Ruby versions with Phusion Passenger

The context

I want to launch many passenger with many version of ruby installed and with diffĂ©rent gemset, etc… RVM is a part of the solution but can’t allow to execute different version of passenger.

The problem

I want to find a way to use passenger with many version of rails and many versions of ruby. For the first problem we can use bundler but for the second, it is a problem. If we want use many ruby versions, passenger recommand this way : http://blog.phusion.nl/2010/09/21/phusion-passenger-running-multiple-ruby-versions/ . So We can see that passenger team say we can use passenger as standalone and launch each instance as daemon. It is quite easy but the problem if your server crash or anything else you have to relaunch each instance of passenger by hand. It’s so boring…

The solution

Here is a script which allow to centralize the execution of daemons. You can find passengers on Gitorious.

You have to specify configuration in /etc/passenger-projects like this :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
;Config sample for passengers
;Default path for this config file: /etc/passenger-project
;You can customize this path in the passengers script (CONFIG_FILE)

[project_name]
;required parameters
path=/path/to/the/project

;optional parameters
;- user - default: 'passenger'
user=my_user

;- env - default: production
env=my_env

;- socket_path - default: /var/run/passenger/[project_name].socket
socket_path=/path/to/file.socket

;- pid_path - default: /var/run/passenger/[project_name].pid
pid_path=/path/to/file.pid

;- gemset - add this to use rvm with a specific gemset or ruby version
gemset=1.9.2@mygemset

You can now use the script :

1
$ passengers start
1
$ passengers start gitorious

The allowed action are “start, stop, status”. You can start, stop each daemon automatically

Hope this can helps others :)

One thought on “Manage multiple Ruby versions with Phusion Passenger