What you describe sounds kind of painful. I'm assuming that you are  
already using Capistrano for something.

I had to solve a similar problem so as to allow multiple  
"stages" (dev, qa, uat, prod, ...) to run
on a single host without port or directory clashes. It was amazingly  
easy with capistrano and
the capistrano-ext gem, which allows you to create stage-specific  
config files.

I would create the file dynamically as part of the deploy with code  
that looks like that below.

Peter


def build_monit_config( application, application_id, stage, stage_id,  
instance)

     monit_config = "########## Monit Configuration File\n\n"
     monit_config << "\n#   stage: #{stage}\n#   stage ID: #{stage_id} 
\n#   instance: #{instance}\n\n#   Produced automatically at:  
#{Time.now}\n"
     first_port = fetch(:start_port)
     top_port = first_port + fetch(:num_proc) - 1
     first_port.upto(top_port) { |i|
       @path = "/var/www/domains/signalpatterns.com/#{application}/ 
#...@stage}/#...@instance}"
       @log_dir = "#...@path}/htdocs/current/log"
       @config_dir = "#...@path}/htdocs/shared/config"
       @pid_dir =      "#...@path}/htdocs/shared/pids"
       cfg = <<-CMD
          check process #{application}-#{i} with pidfile #...@pid_dir}/ 
#{application}-mongrel.#{i}.pid
          start program = "/usr/bin/mongrel_rails cluster::start -C  
#...@config_dir}/mongrel_cluster.yml -v --clean --only #{i}"
          stop program = "/usr/bin/mongrel_rails cluster::stop -C  
#...@config_dir}/mongrel_cluster.yml -v --force --only #{i}"
          if failed url http://localhost:#{i}/monit
             with timeout 10 seconds
          then restart
          if failed url http://localhost:#{i}/monit
             with timeout 10 seconds for 2 cycles
          then
             exec "/bin/bash -c 'kill -9 `cat #...@pid_dir}/ 
#{application}-mongrel.#{i}.pid`'"
          group #...@id}
          ##########
       CMD
       monit_config << cfg
     }
   monit_config
end


On Mar 2, 2009, at 9:50 AM, Gerhardus Geldenhuis wrote:

>
> Hi
> I want to create custom config files and would appreciate any tips if
> anyone has attempted the same thing.
>
> I am planning to do it in the following way:
> Download the config files using run command with svn
> insert and append the config files using the run command with sed and
> awk based on the servers in my roles.
>
> Typically what I am going to do is setup our modjk loadbalancer
> according the the list of tomcat application servers.
>
> We also loadbalance accross our apaches that run modjk and I intend
> using capistrano to build/customize there config files too.
>
> What I am trying to achieve is that after having build the servers the
> only other step I need to do is write a capistrano config and then run
> 1 or 2 cap commands to deploy new configs and applications to my
> environment.
>
> Eventually I can reverse the steps; write the config file first which
> then takes care of building the virtual servers and configuring them.
>
> Regards
> >


--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---

Reply via email to