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

Ability to overwrite the default tasks #26

Closed
jb-san opened this issue Jun 29, 2012 · 7 comments
Closed

Ability to overwrite the default tasks #26

jb-san opened this issue Jun 29, 2012 · 7 comments

Comments

@jb-san
Copy link

jb-san commented Jun 29, 2012

are there plans to make it possible to overwrite the default tasks ?
I know I can fork it and make the changes, but I think its better to keep the forks to a minimum..


like if I use git
I think on the initial setup, it should just clone the repository, but on subsequent deploys it should just do a git fetch origin,

when I try to overwrite the git:clone task I get

-----> Cloning the Git repository
fatal: destination path '.' already exists and is not an empty directory.

no matter what i put in the

namespace :git do
  desc "Clones the Git repository to the release path."
  task :clone do
    queue "echo $PATH"
  end
end

it does echo the $PATH though..

@mikong
Copy link
Member

mikong commented Jun 29, 2012

I believe this is the default behavior of Rake. If you redefine a task, you're actually adding to the behavior of the original task. For example, this Rake tutorial mentions it a bit: http://jasonseifer.com/2010/04/06/rake-tutorial

There are ways to redefine Rake tasks that clears the original definition. Some of the solutions out there use the clear_actions method of Rake::Task.

One thing you could do is define a task that doesn't conflict with the git:clone task, e.g. name it git:checkout or something.

But if you're asking if Mina will provide a helper to easily override tasks, this is still up for debate. My gut feel is not to do this. It doesn't seem to be essential for most of the deployments out there (my guess). @rstacruz, what do you think?

Btw, @jb-san, issue #10 may be interesting for you. It's about optimizing the Git clone/checkout process.

@rstacruz
Copy link
Member

You can simply not do a "require 'git'" :)

On Jun 29, 2012, at 7:40 AM, Michael Galero
reply@reply.github.com
wrote:

I believe this is the default behavior of Rake. If you redefine a task, you're actually adding to the behavior of the original task. For example, this Rake tutorial mentions it a bit: http://jasonseifer.com/2010/04/06/rake-tutorial

There are ways to redefine Rake tasks that clears the original definition. Some of the solutions out there use the clear_actions method of Rake::Task.

One thing you could do is define a task that doesn't conflict with the git:clone task, e.g. name it git:checkout or something.

But if you're asking if Mina will provide a helper to easily override tasks, this is still up for debate. My gut feel is not to do this. It doesn't seem to be essential for most of the deployments out there (my guess). @rstacruz, what do you think?

Btw, @jb-san, issue #10 may be interesting for you. It's about optimizing the Git clone/checkout process.


Reply to this email directly or view it on GitHub:
#26 (comment)

@mikong
Copy link
Member

mikong commented Jun 30, 2012

@rstacruz, if we are only talking about git :) It's the specific case for jb-san, but that's just an example of the issue. So if someone would like to override deploy:cleanup, but still needs most of the tasks there.

@jb-san
Copy link
Author

jb-san commented Jun 30, 2012

I do realize that this is less clean, but could it not be a solution to when you do a mina init, it generates a deployment folder with, the deploy and setup and misc task defined, and the deploy.rb uses those ? that way you could have the default behavior of mina but easily override those tasks..

just a thought :)

@rstacruz
Copy link
Member

I would rather make the recommended path to be to implement your own tasks. For instance, you can make your own git:clone as app:git:clone. Making a 'deployment' folder would make it very difficult to update between Mina versions and it would litter people's repositories.

@mikong
Copy link
Member

mikong commented Jul 1, 2012

A new namespace app seems like the cleaner approach. A helper method that overrides rake tasks (if it's really needed) can be made as a generic rake extension gem, and shouldn't be part of the mina core. Might be interesting.

Anyway, thanks for bringing up this topic @jb-san. I'm closing this issue.

@mikong mikong closed this as completed Jul 1, 2012
@kml
Copy link

kml commented Aug 8, 2018

For example to override "log" task from mina/rails put this inside config/deploy.rb:

Rake::Task["log"].clear

desc 'Tail log from server'
task :log do
  set :execution_mode, :exec
  in_path "#{fetch(:shared_path)}/log" do
    command %{tail -F #{fetch(:rails_env)}.log /var/log/supervisor/puma.out.log}
  end
end

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

4 participants