Thanks, really appreciate taking the time to help me out.
I think I've worked it out though with a little help from
https://gist.github.com/raw/21559/4a8d70c1c3f7874cd435be59a5ed89a6003284a4/deploy.rb
As my deploy.rb file includes "default_run_options[:pty] = true" the
run commands are executed via a pseudo-tty. It seems that you can't
start a daemon process in this without it stopping on hangup
(disconnect), at least not on CentOS - can't say for certain on others
although I would imagine so.
If however you prepend the run command with nohup everything works
correctly and the process stays running after the cap session ends. I
now have:
run "nohup #{deploy_to}/current/script/backgroundrb start --
environment=production"
Incidentally, if you take "default_run_options[:pty] = true" out of
deploy.rb the backgroundrb start command doesn't return and locks the
session. Jamis Buck briefly covers this here: http://weblog.jamisbuck.org/2007/10/14/capistrano-2-1
Thanks again, Andrew.
On 8 Feb 2009, at 17:47, Walter McGinnis wrote:
Hi,
You are correct. This topic's instructions might help:
http://kete.net.nz/documentation/topics/show/240-configuring-sudo-path-in-capistrano-deployments
We use backgroundrb as a part of Kete, an open source Rails app and
were running into issues with starting/stopping and gem installs.
Cheers,
Walter
On Feb 8, 2009, at 11:56 PM, [email protected] wrote:
Thanks guys,
I think it might be something to do with the capistrano login
session.
If I use essentially the same code as Samer for my cap task:
desc "Start Backgroundrb"
task :start_backgroundrb, :roles => [:app] do
run "#{deploy_to}/current/script/backgroundrb start --
environment=production"
end
I get the following output:
cap restart_backgroundrb
* executing `restart_backgroundrb'
* executing "/var/webapps/optics/current/script/backgroundrb start
--environment=production"
servers: ["192.168.10.60"]
Password:
[192.168.10.60] executing command
** [out :: 192.168.10.60] Starting BackgrounDRb ....
command finished
This updates the pid file with 4488. However look up the pid and
nothing:
$ ps aux | grep 4488
deploy 4534 0.0 0.0 3924 680 pts/1 S+ 10:30 0:00
grep 4488
If however I run the cap task's run command by hand on the server
via a normal ssh session (same user, "deploy") the pid generated
actually refers
to a running process:
$script/backgroundrb start --environment=production
$ps aux | grep 5080
deploy 5080 0.6 1.6 57536 51088 pts/1 S 10:44 0:00
ruby script/backgroundrb start --environment=production
deploy 5089 0.0 0.0 3920 676 pts/1 S+ 10:44 0:00
grep background
I guess there is something specific about the cap session that is
different to a regular ssh. If I can't find a solution, as
suggested I suppose I could use god/monit to restart the process
locally and just use the cap task to stop the backgroundrb process,
which it doesn't seem to have a problem with unlike starting.
Thanks for your help, Andrew.
On 7 Feb 2009, at 16:49, E. Johnson wrote:
It looks like the restart of backgroundrb failed to start
backgroundrb
because restart's stop-backgroundrb failed (nothing running, nothing
to stop), and quit the task.
If that's the case, perhaps a start_backgroundrb task is in order?
I'm
controlling backgroundrb via god, and calling them from capistrano
w/
the following task set:
$ cap -T |grep backgroundrb
cap restart_backgroundrb # restart backgroundrb servers
cap start_backgroundrb # start backgroundrb servers
cap stop_backgroundrb # stop backgroundrb servers
# Backgroundrb Server TASKS
%w(start stop restart).each do |cmd|
desc "#{cmd} backgroundrb servers"
task "#{cmd}_backgroundrb".to_sym, :roles => :app do
run "sudo #{god} #{cmd} backgroundrb"
end
end
hope that helps,
Erik
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
_______________________________________________
Backgroundrb-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/backgroundrb-devel
_______________________________________________
Backgroundrb-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/backgroundrb-devel
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
_______________________________________________
Backgroundrb-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/backgroundrb-devel