2

I'm using Mina (a simpler alternative to Capistrano) to deploy my ruby websites, and I am trying to run some tasks once the current symlink has been updated.

So far, here's what I have in my deploy.rb file:

desc "Deploys the current version to the server."
task :deploy => :environment do
  deploy do
    invoke :'git:clone'
    invoke :'deploy:link_shared_paths'
    invoke :'bundle:install'

    to :launch do
      invoke :restart
    end
  end
end

desc "Manually restart Thin web server"
task :restart do
  in_directory "#{deploy_to}/current" do
    queue! %[bundle exec thin restart -C "#{thin_yml}"]
  end
end 

My problem is that when Mina hits the to :launch block, the current symlink has not yet been updated, so either it does not exist (if it is the 1st deployment for this project) or it's still pointing to the n-1 release (and thus, the server uses an outdated version of the project).

So I'd like to be able to invoke my :restart task once the new release has been moved to the release directory and the current symlink has been updated.

Clément
  • 12,299
  • 15
  • 75
  • 115
Pierre-Adrien
  • 2,836
  • 29
  • 30
  • is it possible to call `queue :'restart'` instead of invoking it directly? – phoet Nov 07 '13 at 13:50
  • Actually no, the ``queue`` command allows to run bash commands only. You meant to queue the ``:restart`` task instead of running it instantly if I'm correct. Actually, there seems to be something that is run after the ``to :launch do`` block according to tests I've made with ``mina deploy --verbose``, and that's what I'd need here, I think. – Pierre-Adrien Nov 07 '13 at 18:19
  • I am having the same issue. Found any solution? – edwardmp Sep 06 '14 at 20:49
  • I'm not alone anymore, yaaay ! Unfortunately, found no solution so far (I must admit I stopped looking into it). Currently, I manually use my ``mina restart`` task after a deploy. That's not perfect, but better than nothing, I guess. – Pierre-Adrien Sep 06 '14 at 21:14
  • 1
    Having the same issue since when I started using Mina. I'll add a bounty, want a fix. – edwardmp Jun 18 '15 at 22:34

1 Answers1

0

I think it's a bug of Mina. in_directory seems to not work properly when used inside a to context. A quick and dirty workaround would be adding @commands[:default] = commands(@to) at the end of the in_directory block.

desc "Manually restart Thin web server"
task :restart do
  in_directory "#{deploy_to}/current" do
    queue! %[bundle exec thin restart -C "#{thin_yml}"]
    @commands[:default] = commands(@to)
  end
end 
egwspiti
  • 957
  • 5
  • 10