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

feat(): add delayed job recipe #41

Merged
merged 1 commit into from
Feb 26, 2016
Merged
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ The following optional integrations are added too:
- [ActiveAdmin](http://activeadmin.info) for admin interfaces.
- [ActiveAdminAddons](https://github.com/platanus/activeadmin_addons) for some help with ActiveAdmin.
- [Pundit](https://github.com/elabs/pundit) for role-based authorization.
- [DelayedJob](https://github.com/collectiveidea/delayed_job) to execute longer tasks in the background.

A few more things are added to the project:

Expand Down
5 changes: 4 additions & 1 deletion lib/potassium/templates/application/assets/README.md.erb
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,7 @@ For managing uploads, this project uses [Paperclip](https://github.com/thoughtbo
<% end-%>
### Admin
As a way to speed up development of an admin interface, we're using [ActiveAdmin](https://github.com/activeadmin/activeadmin)

<% if selected?(:delayed_job) %>
### Queue System
For managing tasks in the background, this project uses [DelayedJob](https://github.com/collectiveidea/delayed_job)
<% end-%>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
use_delayed_job = Ask.confirm "Do you want to use delayed jobs?"
set(:delayed_job, use_delayed_job)
16 changes: 16 additions & 0 deletions lib/potassium/templates/application/recipes/delayed_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
if selected?(:delayed_job)
gather_gem "delayed_job_active_record"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

porque hay que agregar la gema "daemons"??

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

creo que como ahora usamos heroku, y el comando se agrega en el Procfile, ya no hay necesidad de esto.
Heroku se encargara de mantener corriendo ese proceso.

Ademas como bien pusiste en el Procfile ya no usariamos el comando bin/delayed_jobs mencionado ahi, sino que el task que provee activejob...

mmmm, pensandolo bien.... usamos activejob para delayed_jobs en platanus??? cual crees que la practica comun?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ActiveJob es relativamente nuevo y no he tenido mucha oportunidad de verlo en un proyecto nuevo. Sin embargo, es mucho más simple y escalable usarlo que no (en tanto, si la bd se vuelve un cuello de botella gracias a DJ, uno puede migrar casi con nada a resque, sidekiq u otros). Por eso creo que deberíamos usarlo de ese modo.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok,
entonces habria que sacar daemons, ya que vamos a usar activejob, vamos ha echar a andar el proceso con las tareas que provee activejobs, ademas de que heroku se encarga de el proceso.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

De acuerdo con lo que dice @juliogarciag , saco daemons entonces.


delayed_job_config = "config.active_job.queue_adapter = :delayed_job"
application(delayed_job_config)

after(:gem_install) do
generate "delayed_job:active_record"

if selected?(:heroku)
gsub_file "Procfile", /^.*$/m do |match|
"#{match}worker: bundle exec rake jobs:work"
end
end
end
end
2 changes: 2 additions & 0 deletions lib/potassium/templates/application/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
eval_file "recipes/asks/database.rb"
eval_file "recipes/asks/devise.rb"
eval_file "recipes/asks/admin.rb"
eval_file "recipes/asks/delayed_job.rb"
eval_file "recipes/asks/pundit.rb"
eval_file "recipes/asks/i18n.rb"
eval_file "recipes/asks/api.rb"
Expand All @@ -33,6 +34,7 @@
eval_file "recipes/devise.rb"
eval_file "recipes/admin.rb"
eval_file "recipes/angular_admin.rb"
eval_file "recipes/delayed_job.rb"
eval_file "recipes/pundit.rb"
eval_file "recipes/testing.rb"
eval_file "recipes/production.rb"
Expand Down