开发者

Capistrano and PlayFramework

开发者 https://www.devze.com 2023-04-05 07:28 出处:网络
I\'m working on getting capistrano to publish my PlayFramework app, but I\'m having some troubles with the run command.

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, "git@store.example.com: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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消