Hi there, I''m having some difficulties finding some decent info on getting Switchtower to function for my needs. I''ve read most of the Switchtower doc on http://manuals.rubyonrails.com/read/chapter/97, however it''s not answering some potent questions I have. 1. The doc mentions, as an example, using an SVN repos at http://svn.switchtower.com/flipper/trunk What if I only access my SVN repos through SSH? When you set the repository in the deploy.rb file what do you put for this line? set :repository, "http://svn.switchtower.com/flipper/trunk" I would ''normally'' access my repository like this: svn co svn+ssh://USERNAME@11.22.33.44/home/svn/repos/app app 2. The second question I have is when dealing with defining the roles in the deploy.rb file. I run all my development on non-standard ports (because my ISP blocks the standard ports... grrr!). The example they used was the following: role :app, "simple.switchtower.com" role :web, "simple.switchtower.com" role :db, "simple.switchtower.com" I have yet to experiment because of trying to figure out question 1''s issues. But, once I get that working, would the following work if all of them were running on port 45000 as an example? role :app, "simple.switchtower.com:45000" role :web, "simple.switchtower.com:45000" role :db, "simple.switchtower.com:45000" 3. I''m using Lighttpd currently as my server. Am I going to have to get Apache working so I can use Switchtower? Sorry for all the noobie questions! Thanks! Dave Hoefler
On Jan 26, 2006, at 9:47 AM, Dave Hoefler wrote:> Hi there, > > I''m having some difficulties finding some decent info on getting > Switchtower to function for my needs. I''ve read most of the > Switchtower doc on http://manuals.rubyonrails.com/read/chapter/97, > however it''s not answering some potent questions I have. > > 1. The doc mentions, as an example, using an SVN repos at > http://svn.switchtower.com/flipper/trunk > What if I only access my SVN repos through SSH? When you set the > repository in the deploy.rb file what do you put for this line? > > set :repository, "http://svn.switchtower.com/flipper/trunk" > > I would ''normally'' access my repository like this: > svn co svn+ssh://USERNAME@11.22.33.44/home/svn/repos/app appYou would put the "svn+ssh://...." text in the :repository variable, in this case. Basically, whatever the address of your repository, that''s what you put there. (Note, however, that ST won''t work with file:// repositories--the repo has to be accessible both from the local host and the remote host.)> 2. The second question I have is when dealing with defining the roles > in the deploy.rb file. I run all my development on non-standard ports > (because my ISP blocks the standard ports... grrr!). The example they > used was the following: > > role :app, "simple.switchtower.com" > role :web, "simple.switchtower.com" > role :db, "simple.switchtower.com" > > I have yet to experiment because of trying to figure out question 1''s > issues. But, once I get that working, would the following work if all > of them were running on port 45000 as an example? > > role :app, "simple.switchtower.com:45000" > role :web, "simple.switchtower.com:45000" > role :db, "simple.switchtower.com:45000"What do you mean, "running"? The app names here are only used as targets for SSH, so as long as SSH is running on the default port (22), you should be fine. If it isn''t, you can specify the ssh port via the ssh_options hash: ssh_options[:port] = 45000> 3. I''m using Lighttpd currently as my server. Am I going to have to > get Apache working so I can use Switchtower?Nope, lighttpd works ok as long as you don''t have to restart it via switchtower. (For some reason no one has yet determined, if you try to restart lighttpd via switchtower, lighttpd shuts down just fine but never starts up again.) If you use externally spawned fastcgi listeners (as described in the third chapter of the ST manual, I believe) you should be just fine.> Sorry for all the noobie questions!No worries! ST documentation has a ways to go, yet. - Jamis
On Jan 26, 2006, at 11:59 AM, Jamis Buck wrote:> On Jan 26, 2006, at 9:47 AM, Dave Hoefler wrote: > >> Hi there, >> >> I''m having some difficulties finding some decent info on getting >> Switchtower to function for my needs. I''ve read most of the >> Switchtower doc on http://manuals.rubyonrails.com/read/chapter/97, >> however it''s not answering some potent questions I have. >> >> 1. The doc mentions, as an example, using an SVN repos at >> http://svn.switchtower.com/flipper/trunk >> What if I only access my SVN repos through SSH? When you set the >> repository in the deploy.rb file what do you put for this line? >> >> set :repository, "http://svn.switchtower.com/flipper/trunk" >> >> I would ''normally'' access my repository like this: >> svn co svn+ssh://USERNAME@11.22.33.44/home/svn/repos/app app > > You would put the "svn+ssh://...." text in the :repository > variable, in this case. Basically, whatever the address of your > repository, that''s what you put there. (Note, however, that ST > won''t work with file:// repositories--the repo has to be accessible > both from the local host and the remote host.) > >> 2. The second question I have is when dealing with defining the roles >> in the deploy.rb file. I run all my development on non-standard ports >> (because my ISP blocks the standard ports... grrr!). The example they >> used was the following: >> >> role :app, "simple.switchtower.com" >> role :web, "simple.switchtower.com" >> role :db, "simple.switchtower.com" >> >> I have yet to experiment because of trying to figure out question 1''s >> issues. But, once I get that working, would the following work if all >> of them were running on port 45000 as an example? >> >> role :app, "simple.switchtower.com:45000" >> role :web, "simple.switchtower.com:45000" >> role :db, "simple.switchtower.com:45000" > > What do you mean, "running"? The app names here are only used as > targets for SSH, so as long as SSH is running on the default port > (22), you should be fine. If it isn''t, you can specify the ssh port > via the ssh_options hash: > > ssh_options[:port] = 45000 > >> 3. I''m using Lighttpd currently as my server. Am I going to have to >> get Apache working so I can use Switchtower? > > Nope, lighttpd works ok as long as you don''t have to restart it via > switchtower. (For some reason no one has yet determined, if you try > to restart lighttpd via switchtower, lighttpd shuts down just fine > but never starts up again.) If you use externally spawned fastcgi > listeners (as described in the third chapter of the ST manual, I > believe) you should be just fine.I noticed that it seems to start every other time that the restart task is run (when a lighttpd restart was included in the task). I changed my deploy.rb around, and now it starts reliably. Here are the tasks that I added: desc "Restart lighty" task :before_restart, :roles => :app do run "kill -9 `cat /home/#{user}/var/run/lighttpd.pid`" end desc "Restart lighty" task :after_restart, :roles => :app do run "/usr/local/sbin/lighttpd -f /home/#{user}/web/lighttpd/config/ lighttpd.conf" end> >> Sorry for all the noobie questions! > > No worries! ST documentation has a ways to go, yet. > > - Jamis > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
On Jan 26, 2006, at 10:05 AM, Joseph Hosteny wrote:> I noticed that [lighttpd] seems to start every other time that the > restart task is run (when a lighttpd restart was included in the > task). I changed my deploy.rb around, and now it starts reliably. > Here are the tasks that I added: > > desc "Restart lighty" > task :before_restart, :roles => :app do > run "kill -9 `cat /home/#{user}/var/run/lighttpd.pid`" > end > > desc "Restart lighty" > task :after_restart, :roles => :app do > run "/usr/local/sbin/lighttpd -f /home/#{user}/web/lighttpd/ > config/lighttpd.conf" > endFascinating! Thanks for this work-around, Joseph. I''m anxious to try it out and see if it works for me. I''m still mystified as to why this works, and the other doesn''t... Very odd. - Jamis
Perhaps the problem is lighttpd shutting down slowly, so when the start happens, the .pid file is still around. Perhaps just a sleep between stop and start, or a loop to wait for the .pid file to go away? -- -- Tom Mornini On Jan 26, 2006, at 9:22 AM, Jamis Buck wrote:> On Jan 26, 2006, at 10:05 AM, Joseph Hosteny wrote: > >> I noticed that [lighttpd] seems to start every other time that the >> restart task is run (when a lighttpd restart was included in the >> task). I changed my deploy.rb around, and now it starts reliably. >> Here are the tasks that I added: >> >> desc "Restart lighty" >> task :before_restart, :roles => :app do >> run "kill -9 `cat /home/#{user}/var/run/lighttpd.pid`" >> end >> >> desc "Restart lighty" >> task :after_restart, :roles => :app do >> run "/usr/local/sbin/lighttpd -f /home/#{user}/web/lighttpd/ >> config/lighttpd.conf" >> end > > Fascinating! Thanks for this work-around, Joseph. I''m anxious to > try it out and see if it works for me. I''m still mystified as to > why this works, and the other doesn''t... Very odd. > > - Jamis > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
On Jan 26, 2006, at 10:27 AM, Tom Mornini wrote:> Perhaps the problem is lighttpd shutting down slowly, > so when the start happens, the .pid file is still > around. > > Perhaps just a sleep between stop and start, or a > loop to wait for the .pid file to go away?That''s what I thought, too, but even a 10s sleep doesn''t seem to help. I haven''t try looping to wait for the pid file to disappear, though. Has anyone else tried that? - Jamis
Jamis, Thanks for the info. That helped a lot actually! I was actually excited to see this error pop up: rake deploy (in /Users/dhoefler/RubyProjects/rlog) loading configuration /usr/lib/ruby/gems/1.8/gems/switchtower-0.10.0/lib/switchtower/recipes/standard.rb loading configuration ./config/deploy.rb executing task deploy transaction: start executing task update_code querying latest revision... ssh: connect to host 12.123.12.12 port 22: Connection refused svn: Connection closed unexpectedly ssh: connect to host 12.123.12.12 port 22: Connection refused svn: Connection closed unexpectedly ssh: connect to host 12.123.12.12 port 22: Connection refused svn: Connection closed unexpectedly ssh: connect to host 12.123.12.12 port 22: Connection refused svn: Connection closed unexpectedly ssh: connect to host 12.123.12.12 port 22: Connection refused svn: Connection closed unexpectedly svn: ''.'' is not a working copy svn: ''.'' is not a working copy (proceed to an endless loop of the previous line) If it matters, I''m trying to connect to my Ubuntu box. I did change the port option in the config deploy to: ssh_options[:port] = 43022 This is odd though, I can SSH in just fine using an alternate port (ssh -p 43022 12.123.12.12) . I think there''s something I''m forgetting to set up with SVN. Hmm... -Dave On 1/26/06, Tom Mornini <tmornini@infomania.com> wrote:> Perhaps the problem is lighttpd shutting down slowly, > so when the start happens, the .pid file is still > around. > > Perhaps just a sleep between stop and start, or a > loop to wait for the .pid file to go away? > > -- > -- Tom Mornini > > > On Jan 26, 2006, at 9:22 AM, Jamis Buck wrote: > > > On Jan 26, 2006, at 10:05 AM, Joseph Hosteny wrote: > > > >> I noticed that [lighttpd] seems to start every other time that the > >> restart task is run (when a lighttpd restart was included in the > >> task). I changed my deploy.rb around, and now it starts reliably. > >> Here are the tasks that I added: > >> > >> desc "Restart lighty" > >> task :before_restart, :roles => :app do > >> run "kill -9 `cat /home/#{user}/var/run/lighttpd.pid`" > >> end > >> > >> desc "Restart lighty" > >> task :after_restart, :roles => :app do > >> run "/usr/local/sbin/lighttpd -f /home/#{user}/web/lighttpd/ > >> config/lighttpd.conf" > >> end > > > > Fascinating! Thanks for this work-around, Joseph. I''m anxious to > > try it out and see if it works for me. I''m still mystified as to > > why this works, and the other doesn''t... Very odd. > > > > - Jamis > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
On Jan 26, 2006, at 9:22 AM, Jamis Buck wrote:> On Jan 26, 2006, at 10:05 AM, Joseph Hosteny wrote: > >> I noticed that [lighttpd] seems to start every other time that the >> restart task is run (when a lighttpd restart was included in the >> task). I changed my deploy.rb around, and now it starts reliably. >> Here are the tasks that I added: >> >> desc "Restart lighty" >> task :before_restart, :roles => :app do >> run "kill -9 `cat /home/#{user}/var/run/lighttpd.pid`" >> end >> >> desc "Restart lighty" >> task :after_restart, :roles => :app do >> run "/usr/local/sbin/lighttpd -f /home/#{user}/web/lighttpd/ >> config/lighttpd.conf" >> end > > Fascinating! Thanks for this work-around, Joseph. I''m anxious to > try it out and see if it works for me. I''m still mystified as to > why this works, and the other doesn''t... Very odd. > > - JamisPlease note that if you do it this way that you will eventually end up leaving zombie fcgi dispatchers laying around taking up memory. You need to also kill the dispatchers with kill -9 before you restart lighty. Of course if you are using stand alone dispatchers then the reaper will work to restart those. Here are my tasks for restarting lighty _and_ the dispatchers. This works for me every time with switchtower. desc "Restart lighty" task :before_restart, :roles => :app do pid_of_lighty = `ps axww | grep lighttpd | grep -v grep | grep myapp.lighttpd.conf` pids_of_dispatchers = `ps axww | grep dispatch.fcgi | grep -v grep | grep /yhr/public/dispatch.fcgi` lighty = pid_of_lighty.scan(/\d*/).first dispatchers = pids_of_dispatchers.split(/\n/).map {|line| line.scan (/\d*/).first } run "kill -9 #{lighty} #{dispatchers.join('' '')}" end desc "Restart lighty" task :after_restart, :roles => :app do run "/usr/local/sbin/lighttpd -f /etc/myapp.lighttpd.conf" end Note that you need to replace the last grep''s in each of the first ps commands to match something unique to your specific lighty and rails app if you are running more then one lighty on the server so that it only affects the lighty and dispatchers for that particular rails app. Cheers- -Ezra Zygmuntowicz Yakima Herald-Republic WebMaster http://yakimaherald.com 509-577-7732 ezra@yakima-herald.com