Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mina:deploy runs tasks twice for some reason #316

Closed
snitko opened this issue May 26, 2015 · 2 comments
Closed

mina:deploy runs tasks twice for some reason #316

snitko opened this issue May 26, 2015 · 2 comments

Comments

@snitko
Copy link

snitko commented May 26, 2015

I have a custom non Rails and it seems that when I run mina deploy it executes certain tasks twice (namely install:* and daemons:*). Here's the script:

require 'mina/bundler'
require 'mina/git'
require 'mina/rvm'
require 'yaml'

LOCAL_SETTINGS = YAML.load_file(File.dirname(__FILE__) + '/local_settings.yml')
set :project_local_dir, File.expand_path(File.dirname(__FILE__) + "/../" + LOCAL_SETTINGS['project_dir'])

set :domain, 'deploy@mega-app'
set :port, 22
set :forward_agent, true
set :term_mode, :pretty

set :addons, {
  payment_ui: 'mega-app/payment_ui'
}
set :gems, {
  'mega-app-server' => 'server',
  'mega-app'        => 'engine'
}

# For system-wide RVM install.
set :rvm_path, '/usr/local/rvm/scripts/rvm'

task :environment do

  stage_param = ENV['to']
  if stage_param == 'production'
    set :stage, 'production'
    set :server_port, 9695
    invoke :'rvm:use[ruby-ruby-2.2-head@production]'
  else
    set :stage, 'staging'
    set :server_port, 9696
    invoke :'rvm:use[ruby-ruby-2.2-head@staging]'
  end

end

desc "Deploys the current version to the server."
task :deploy => :environment do

  invoke :'upload:addons'
  invoke :'upload:gems'
  invoke :'install:addons'
  invoke :'install:gems'
  invoke :'daemons:restart'

  run_local!(:local)
  run!

end

namespace :upload do

  task :addons => :environment do
    to :local do
      queue "echo '-----> Packaging and uploading addons'"
      addons.each do |addon_name, addon_path|
        queue "echo '  Packaging and uploading #{addon_name}'"
        dir = "#{project_local_dir}/#{addon_path}"
        queue "#{project_local_dir}/mega-app/deployment/git-archive-all.sh #{dir}/#{addon_name}-master.tar --tree-ish master"
        queue "rsync -avze 'ssh' --delete #{dir}/#{addon_name}-master.tar #{domain}:/home/deploy/.mega-app-#{stage}/addons/"
        queue "rm #{dir}/#{addon_name}-master.tar"
      end
    end
  end

  task :gems => :environment do
    to :local do
      queue "echo '-----> Uploading gems'"
      gems.each do |gem_name, gem_path|
        queue "echo '  Building and uploading #{gem_name}'"
        dir = "#{project_local_dir}/#{gem_path}"
        queue "cd #{dir} && rake build"
        queue "rsync -avze 'ssh' --delete #{dir}/pkg/*.gem #{domain}:/home/deploy/mega-app-gems/#{stage}/"
      end
    end
  end

end


namespace :install do

  task :addons => :environment do
    dir = "/home/deploy/.mega-app-#{stage}/addons"
    in_directory dir do
      queue "echo '-----> Installing addons'"
      addons.each do |addon_name, addon_path|
        queue "echo '  Installing #{addon_name} into #{dir}'"
        queue "mkdir -p #{addon_name}"
        queue "tar -C #{addon_name} -xvf #{addon_name}-master.tar"
        queue "cd #{addon_name} && bundle"
      end
    end
  end

  task :gems => :environment do
    queue "echo '-----> Installing rubygems'"
    dir = "/home/deploy/mega-app-gems/#{stage}/"
    in_directory dir do
      gems.each do |gem_name, gem_path|
        queue "echo '  Installing #{gem_name}'"
        queue "gem install $(ls #{gem_name}* -Art | tail -n 1) --no-ri --no-rdoc"
      end
    end
  end

end

namespace :daemons do

  task :start => :environment do
    queue "echo '-----> Starting mega-app-server daemon at port #{server_port}'"
    queue "mega-app-server -p #{server_port} --config-dir=~/.mega-app-#{stage} --daemonize --pid ~/.mega-app-#{stage}/mega-app.pid"
  end

  task :stop => :environment do
    queue "echo '-----> Stopping mega-app-server daemon'"
    queue "if test -f '~/.mega-app-#{stage}/mega-app.pid'; then kill $(cat ~/.mega-app-#{stage}/mega-app.pid);fi"
  end

  task :restart => :environment do
    invoke :'daemons:stop'
    invoke :'daemons:start'
  end

end

Can you shed some light as to why this might be happening?

@snitko snitko changed the title Runs tasks twice for some reason mina:deploy runs tasks twice for some reason May 26, 2015
@d4be4st
Copy link
Member

d4be4st commented Jul 5, 2015

can you maybe give as a mina deploy -v output to see where exacly is the problem?

@d4be4st
Copy link
Member

d4be4st commented Jul 8, 2016

One year without response. closing

@d4be4st d4be4st closed this as completed Jul 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants