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 do a proper finish hook? #425

Closed
devvmh opened this issue Aug 29, 2016 · 1 comment
Closed

How to do a proper finish hook? #425

devvmh opened this issue Aug 29, 2016 · 1 comment

Comments

@devvmh
Copy link
Contributor

devvmh commented Aug 29, 2016

Related to #424, the code I provided there doesn't do what I'd like. Given these two tasks

namespace :notification do
  notifier = Slack::Notifier.new('https://hook.bearychat.com/=bw6KQ/incoming/2d9481657d9013eb61cb41d3708f39a8')
  task :start_deploy do
    notifier.ping %(mina 1.x test - start deploy task ran)
    command %(echo 'started')
  end

  task :finish_deploy do
    notifier.ping %(mina 1.x test - finish deploy task ran)
    command %(echo 'finished')
  end
end

I get this output:

       started
       Elapsed time: 0.00 seconds
       finished
       Elapsed time: 0.00 seconds
-----> Creating a temporary build path
-----> Deploy finished
-----> Building
-----> Moving build to /home/deploy/mina-deploys/minatest/cure/releases/20160815063411
-----> Build finished
-----> Launching
-----> Updating the /home/deploy/mina-deploys/minatest/cure/current symlink
-----> Done. Deployed version 20160815063411
       Elapsed time: 1.47 seconds

What I would like is for the finish_deploy output (and slack notification) to run after passenger is restarted, like so:

       started
       Elapsed time: 0.00 seconds
-----> Creating a temporary build path
-----> Deploy finished
-----> Building
-----> Moving build to /home/deploy/mina-deploys/minatest/cure/releases/20160815063411
-----> Build finished
-----> Launching
-----> Updating the /home/deploy/mina-deploys/minatest/cure/current symlink
-----> Done. Deployed version 20160815063411
       Elapsed time: 1.47 seconds
       finished
       Elapsed time: 0.00 seconds

Is there a way to make mina do what I want?

@devvmh devvmh changed the title How to do a finish hook? How to do a proper finish hook? Aug 29, 2016
@devvmh
Copy link
Contributor Author

devvmh commented Aug 29, 2016

Ah, got it, I need to change this

task deploy: :environment do
  deploy do
    run(:local) { invoke :'notification:start_deploy' }
    invoke :'git:clone'
    # ...other commands...
    invoke :'deploy:cleanup'

    on :launch do
      invoke :'passenger:restart'
      run(:local) { invoke :'notification:finish_deploy' }
    end
  end
end

to this

task deploy: :environment do
  run(:local) { invoke :'notification:start_deploy' }

  deploy do
    invoke :'git:clone'
    # ...other commands...
    invoke :'deploy:cleanup'

    on :launch do
      invoke :'passenger:restart'
    end
  end

  run(:local) { invoke :'notification:finish_deploy' }
end

@devvmh devvmh closed this as completed Aug 29, 2016
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