# Dynamically change which app a ruby process runs

**URL:** <https://www.ruby-forum.com/t/dynamically-change-which-app-a-ruby-process-runs/119883>\
**Category:** Rails\
**Created:** [November 11, 2007, 9:48pm UTC](https://www.ruby-forum.com/t/dynamically-change-which-app-a-ruby-process-runs/119883 "2007-11-11T21:48:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![chillexistence](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ee7513/32.png) [@chillexistence](https://www.ruby-forum.com/u/chillexistence)\
**Post date:** [November 11, 2007, 9:48pm UTC](https://www.ruby-forum.com/t/dynamically-change-which-app-a-ruby-process-runs/119883/1 "2007-11-11T21:48:45Z")

</div>

Is there anyway to tell a running ruby process to dynamically switch to  
a different rails app? That is, without killing the process and  
starting up a new ruby vm.

Say I have two rails apps:

$ rails test1  
$ rails test2  
$ cd test1  
$ script/server  
running…

A ruby vm starts up and serves requests based on all the logic in the  
test1 app. Then, without killing the vm, can I switch and make it act  
as if script/server was launched from the test2 directory?

The idea is to dynamically do this based on the domain of the request.  
So [test1.mydomain.com](http://test1.mydomain.com) and [test2.mydomain.com](http://test2.mydomain.com) each run different apps.  
But, I don’t need separate vms running for each app. This way I could  
have hundreds of apps, all sharing the same vm or same few vms if using  
mongrel cluster. Each ruby vm takes at least 20 megs of memory, so it’s  
not practical to have one for each app if you have hundreds of apps.  
Thanks!
