laredotornado-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org
2007-Dec-04 16:12 UTC
starting ruby on rails with multiple applications
Hi, I''m using Fedora Core 5 Linux with the latest version of Ruby on Rails. I''m just learning it, but let''s say I''ve created two rails applications in the directories application1/ application2/ I can "cd" to application1 and run "ruby script/server" to start that application. But then must I do this for "application2" as well? Is there a generic way of starting all ruby-on-rails applications at once? Thanks, - Dave --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Phillip Koebbe
2007-Dec-04 16:35 UTC
Re: starting ruby on rails with multiple applications
I had a need of something like that once, so I came up with this scheme:
In each rails folder, I create three files:
app_start
app_stop
app_restart
app_start and app_stop contain the shell script calls necessary to
start the particular application. So if you are using Mongrel,
app_start might look something like
mongrel_rails start -p 3010 -e production -d
and app_stop would look like
mongrel_rails stop
That way each app_start/stop pair is specific to the application, but
general enough to be called via a universal script. Then I created
the universal script that would descend into the directory where all
the rails apps were (/var/www in this case), and if there was an
app_start, exec it. I named the script rails_ctrl and it looks like
this:
#! /usr/bin/ruby
# This script is used to launch all rails apps after a restart. It
assumes that each
# app will have a file named app_start in the project''s root
directory. This file needs
# to call mongrel_rails or mongrel_cluster with the proper parameters.
action = ARGV.at(0)
action ||= ''<none>''
action = action.downcase
app = ARGV.at(1)
if ![''start'', ''stop'',
''restart''].include?(action)
puts "rails_ctrl: Invalid action: #{action}"
exit
end
root_dir = ''/var/www/''
dirs = Dir.entries(root_dir)
dirs.each do |dir|
if ![''.'', ''..''].include?(dir) &&
dir == (app || dir)
d = "#{root_dir}#{dir}"
if File.directory?(d)
f = "#{d}/app_#{action}"
if File.file?(f)
Dir.chdir(d)
puts "Performing #{action} action on #{dir}..."
system(f)
end
end
end
end
This was just hacked together one day to suit my purposes, so it may
have some holes in it. Feel free to take it and modify to fit your
environment.
Peace,
Phillip
On Dec 4, 2007, at 10:12 AM,
laredotornado-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org wrote:
>
> Hi,
>
> I''m using Fedora Core 5 Linux with the latest version of Ruby on
> Rails. I''m just learning it, but let''s say I''ve
created two rails
> applications in the directories
>
>
> application1/
> application2/
>
>
> I can "cd" to application1 and run "ruby script/server"
to start that
> application. But then must I do this for "application2" as well?
Is
> there a generic way of starting all ruby-on-rails applications at
> once?
>
>
> Thanks, - Dave
>
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Stephan Wehner
2007-Dec-04 17:05 UTC
Re: starting ruby on rails with multiple applications
laredotornado-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org wrote:> Hi, > > I''m using Fedora Core 5 Linux with the latest version of Ruby on > Rails. I''m just learning it, but let''s say I''ve created two rails > applications in the directories > > > application1/ > application2/ > > > I can "cd" to application1 and run "ruby script/server" to start that > application. But then must I do this for "application2" as well?Sure.> Is there a generic way of starting all ruby-on-rails applications at > once?Rails applications don''t necessarily need to be "started". Your webserver can have virtual hosts set up so that app1.yourdomain.net and app2.yourdomain.net point to the Rails applications under application1 and application2. Then your webserver will take care of running those Rails applications as requests come in to app1.yourdomain.net or app2.yourdomain.net Look up "lighttpd virtual hosts" or "apache virtual hosts" on Google. Stephan -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---