Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capistrano and PlayFramework

I'm working on getting capistrano to publish my PlayFramework app, but I'm having some troubles with the run command.

What happens is that cap runs the play start command and it's seems to be firing up, but when i do a

ps aux | grep java

There is no play app running.

If I copy the command from the cap output and run it locally on the server it works properly.

Is the capistrano run command killing the subprocess that play spawns?

How do I prevent capistrano from killing the process?

My deploy.rb

default_run_options[:pty] = true
set :application, "Intranet"
set :domain, "intranet.example.com"
set :deploy_to, "/srv/#{domain}"
set :play_path, "/usr/local/play/play"
set :shared_path, "#{deploy_to}/shared"
set :app_pid, "#{shared_path}/pids/server.pid"
set :app_path, "#{deploy_to}/current"

set :scm, :git
set :user, "myuser"
set :repository, "[email protected]:intranet.git"

ssh_options[:forward_agent] = true
set :deploy_via, :remote_cache
set :keep_releases, 3

role :web, domain
role :app, domain
role :db, domain, :primary => true

namespace :deploy do
  task :start do
    run "rm -f #{app_pid};#{play_path} start #{app_path} --deps --pid_file=#{app_pid} --%prod"
  end

  task :restart do
    stop
    start
  end

  task :stop do
    run "#{play_path} stop #{app_path} --pid_file=#{app_pid}"
  end
end

namespace :play do
  desc "view running play apps"
  task :viewprocess do
    run "#{sudo} ps -ef | grep 'play/framework'"
  end

  desc "kill play processes"
  task :kill do
    run "#{sudo} ps -ef | grep 'play/framework' | grep -v 'grep' | awk '{print $2}'| xargs -i kill {} ; echo ''"
  end

  desc "view logfiles"
  task :tail_logs, :roles => :app do
    run "tail -f #{shared_path}/log/system.out" do |channel, stream, data|
      puts  # for an extra line break before the host name
      puts "#{channel[:host]}: #{data}"
      break if stream == :err
    end
  end

end
like image 639
Leon Radley Avatar asked Jun 16 '26 08:06

Leon Radley


1 Answers

Just to tell you that I succeeded in remote launching play by tweaking a bit your script and adding other stuff.
Your problem is that you must launch remote process in nohup + & but the & doesn't work in Capistrano for an unknown reason. I found a way around.
I was so motivated that I decided to make a play module of it.
The very first version of it is there: https://github.com/mandubian/play-capistrano

like image 148
mandubian Avatar answered Jun 21 '26 04:06

mandubian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!