I won’t bore you with the details of how and why. I have my mongrels
running under the “apache” user id.
In /Library/LaunchDaemons (on the server) create files called
org.rubyforge.mongrel.8000 org.rubyforge.mongrel.8001, etc. One such
file looks like this:
Note that you want to change the WorkingDirectory. The 8000’s change to
8001, etc for each of the files.
To get so that the apache user can control the mongrels, add this to
/etc/sudoers (on the server):
apache ALL=(root) NOPASSWD: /bin/launchctl unload
/Library/LaunchDaemons/org.rubyforge.mongrel.*
apache ALL=(root) NOPASSWD: /bin/launchctl load
/Library/LaunchDaemons/org.rubyforge.mongrel.*
To get so that capistrano can control this remotely, my Cap file has
this in it:
namespace :deploy do
desc “The start task is used by :cold_deploy to start the application
up”
task :start, :roles => :app do
run “sudo /bin/launchctl load
/Library/LaunchDaemons/org.rubyforge.mongrel.*”
end
desc “Restart the mongrel cluster”
task :restart, :roles => :app do
run “sudo /bin/launchctl unload
/Library/LaunchDaemons/org.rubyforge.mongrel."
run "sudo /bin/launchctl load
/Library/LaunchDaemons/org.rubyforge.mongrel.”
end
desc “Stop the mongrel cluster”
task :stop, :roles => :app do
run “sudo /bin/launchctl unload
/Library/LaunchDaemons/org.rubyforge.mongrel.*”
end
desc “Hook to set up database.yml”
task :after_update_code, :roles => :app do
db_config = “#{shared_path}/config/database.yml.production”
run “cp #{db_config} #{release_path}/config/database.yml”
end
end
HTH,
pedz