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

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

Open
jmuheim opened this issue Oct 2, 2019 · 2 comments

Comments

@jmuheim
Copy link

jmuheim commented Oct 2, 2019

(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?

@jmuheim
Copy link
Author

jmuheim commented Oct 9, 2019

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.

@jmuheim
Copy link
Author

jmuheim commented Oct 14, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant