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

Add rake after_party:reset #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ after 'deploy:update_code', 'db:migrate', 'db:seed', 'deploy:after_party'

This will ensure your deploy tasks always run after your migrations, so they can safely load or interact with any models in your system.

You can also reset the list of executed tasks by running:

```console
rake after_party:reset
```

This will allow all tasks to be re-run the next time `rake after_party:run` is executed. While you probably wouldn't want to execute the above command on a production database, it can be handy while working in development.

##Asyncronous runs

Well yes, a long-running deploy task will halt your deployment, thanks for noticing. Sometimes you might want your task to finish before you switch the symlink and your new code is in production. Sometimes, you just want to start the task, and forget about it. In that case do this:
Expand Down
4 changes: 2 additions & 2 deletions lib/after_party/railtie.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
require 'after_party'
require 'after_party'
require 'rails'
module AfterParty
class Railtie < Rails::Railtie
#railtie is loaded from lib/after_party.rb. So all load paths need to be relative to /lib
rake_tasks do
load "tasks/deploy_task_runner.rake"
load "tasks/reset_task_runner.rake"
end

initializer "load_task_record_models" do
Expand All @@ -19,4 +19,4 @@ class Railtie < Rails::Railtie
end


end
end
14 changes: 14 additions & 0 deletions lib/tasks/reset_task_runner.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace :after_party do

# Use this task if you want to clear the table that After Party uses to track
# the tasks that have already been run. This allows you to execute rake after_party:run
# and re-run all of the tasks (which is useful in development).

desc "resets the database so all tasks can be run again"
task :reset => :environment do

TaskRecord.delete_all
puts (TaskRecord.count == 0 ? "Success! You may now rerun all tasks using 'rake after_party:run'" : "There was a problem during the reset (the task_record table should be empty, but it is not).")

end
end