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

foreman added as development dependency #60

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
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ gem "postmark"

group :development, :test do
gem "guard-rspec", require: false
gem "foreman"
gem "pry-byebug"
end

Expand Down
5 changes: 4 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ GEM
roda-flow (~> 0.3)
thor (~> 0.19)
ffi (1.9.14)
foreman (0.82.0)
thor (~> 0.19.1)
formatador (0.2.5)
guard (2.14.0)
formatador (>= 0.2.4)
Expand Down Expand Up @@ -228,6 +230,7 @@ DEPENDENCIES
dry-view
dry-web (~> 0.5)
dry-web-roda (~> 0.4)
foreman
guard-rspec
i18n
inflecto
Expand All @@ -254,4 +257,4 @@ RUBY VERSION
ruby 2.3.1p112

BUNDLED WITH
1.12.5
1.13.2
2 changes: 2 additions & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
web: bundle exec puma --port=$PORT
worker: bundle exec rake que:work
3 changes: 3 additions & 0 deletions Procfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
web: bundle exec shotgun -p 3000 -o 0.0.0.0 config.ru
worker: bundle exec rake que:work
assets: npm start
27 changes: 27 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,30 @@ namespace :assets do
FileUtils.rm_rf("#{AppPrototype::Container.config.root}/public/assets")
end
end

require "que"
namespace :que do
desc "Process Que's jobs using a worker pool"
task :work do
$stdout.puts "Starting Que's jobs..."
# # When changing how signals are caught, be sure to test the behavior with
# # the rake task in tasks/safe_shutdown.rb.

stop = false
%w(INT TERM).each do |signal|
trap(signal) { stop = true }
end

at_exit do
$stdout.puts "Finishing Que's current jobs before exiting..."
Que.worker_count = 0
Que.mode = :off
$stdout.puts "Que's jobs finished, exiting..."
end

loop do
sleep 0.01
break if stop
end
end
end
4 changes: 4 additions & 0 deletions config/settings.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ development: &base
app_mailer_from_email:
bugsnag_api_key:
postmark_api_key:
que_worker_count: 1
que_wake_interval: 0.1
test:
<<: *base
database_url: 'postgres://localhost/app_prototype_test'
postmark_api_key: 'POSTMARK_API_TEST'
que_worker_count: 0
que_wake_interval: 0.1
production:
<<: *base
3 changes: 3 additions & 0 deletions system/app_prototype/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@ module Required
setting :bugsnag_api_key, Types::String

setting :postmark_api_key, Types::String

setting :que_worker_count, Types::Form::Int.default(0)
setting :que_wake_interval, Types::Form::Float.default(0.1)
end
end
2 changes: 2 additions & 0 deletions system/boot/que.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

container.register :connection, container["persistence.config"].gateways[:default].connection

Que.worker_count = container.settings.que_worker_count
Que.wake_interval = container.settings.que_wake_interval
Que.logger = container[:logger]
Que.mode = :sync if container.config.env == :test
Que.connection = container["que.connection"]
Expand Down