mina-deploy / mina

Blazing fast deployer and server automation tool

Home Page:https://rubygems.org/gems/mina

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to find out whether it's the first deployment (in the deploy command itself)?

jmuheim opened this issue · comments

(Related to #651)

I'd like to execute some commands depending on whether a deployment is the first one or not.

In the following pseudo code, I'm using a hypothetical first_deploy? method:

task :deploy do
  # uncomment this line to make sure you pushed your local branch to the remote origin
  invoke :'git:ensure_pushed'

  deploy do
    invoke :'git:clone'
    invoke :'deploy:link_shared_paths'
    invoke :'bundle:install'
    invoke :'rails:db_schema_load' if first_deploy?
    invoke :'rails:db_migrate'
    command %{#{fetch(:rails)} db:seed} if first_deploy?
    invoke :'rails:assets_precompile'
    invoke :'deploy:cleanup'

    on :launch do
      if first_deploy?
        invoke :'puma:start'
      else
        invoke :'puma:phased_restart'
      end
    end
  end
end

How can I achieve this?

I see that https://github.com/windy/mina-ng-puma offers the specific case of starting or restarting Puma:

phased_restart and restart need start puma correctly when puma is down.

Still, for loading the DB schema and seeding, a first_deploy? or similar is still needed.