Comments (4)
sorry guys.
I found this doc, https://github.com/chanks/que/blob/master/docs/advanced_setup.md.
but, I don't know how to setting my unicorn.rb.
Please tell me about setting with unicorn.
from que.
Hello -
I don't believe anyone has tried to get Que working with Unicorn yet. I believe you would want to set config.que.mode = :off
in your application configuration and then set Que.mode = :async
in each worker after forking, but I don't have an example of how you'd do that with Unicorn. If you figure it out, please let me know and I'll add it to the docs.
from que.
OK, setting verified.
Please check bellow.
(I have no skill to pull request for doc. sorry.)
config/application.rb
require File.expand_path('../boot', __FILE__)
・・・・#omit
require "que"
Bundler.require(:default, Rails.env)
module App
class Application < Rails::Application
・・・・#omit
# Que
Que.mode = :off
・・・・#omit
end
and,
config/unicorn.rb
(this config include my original.)
APP_DIR = File.expand_path("../../", __FILE__)
preload_app true
worker_processes (ENV['RAILS_ENV'] == 'development' ? 1 : 2)
working_directory APP_DIR
timeout 30
unless ENV['RAILS_ENV'] == 'development'
listen File.expand_path("tmp/sockets/unicorn.sock", ENV['RAILS_ROOT']), :backlog => 64
else
listen 3000
end
pid File.expand_path("tmp/pids/unicorn.pid", ENV['RAILS_ROOT'])
stderr_path File.expand_path('log/unicorn.log', ENV['RAILS_ROOT'])
stdout_path File.expand_path('log/unicorn.log', ENV['RAILS_ROOT'])
before_fork do |server, worker|
old_pid = "#{ server.config[:pid] }.oldbin"
if File.exists?(old_pid) && server.pid != old_pid
begin
sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
Process.kill(sig, File.read(old_pid).to_i)
rescue Errno::ENOENT, Errno::ESRCH
# someone else did our job for us
end
end
defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
end
after_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT'
end
# Que
require 'yaml'
require "active_record"
require 'que'
config = YAML.load(File.read("config/database.yml"))["#{ENV['RAILS_ENV']}"]
ActiveRecord::Base.establish_connection(config)
Que.connection = ActiveRecord
Que.mode = :async
defined?(ActiveRecord::Base) and
ActiveRecord::Base.establish_connection
end
thank you so much.
It's very good.
from que.
Good! I'm glad you got it working. I'll shorten up your configuration and add it to the docs soon.
from que.
Related Issues (20)
- Need support for draining queues HOT 3
- Support JRuby
- best way to re-activate a job HOT 2
- Que::ActiveRecord::Model.by_args incompatible with ActiveJob JobWrapper HOT 1
- Flaky Errors HOT 2
- Proper way of removing Que from project? HOT 3
- Schema version comment doesn't end up in Rails structure.sql HOT 3
- Que v1 should state that it's incompatible with ruby 3 HOT 2
- Tests fail in Docker on Apple Silicon
- Timeline for v2.0.0. release HOT 1
- Remove unnecessary trigger that notifies about job state transitions HOT 2
- Deprecated method used in connection.rb HOT 1
- Check that all que migrations have been applied at startup HOT 1
- Detect Que schema version missing due to bug in Rails schema dump - affects all versions of Rails 7 prior to 7.0.3
- Migration to v. 2.2.0 failed HOT 2
- Stats about failing jobs HOT 2
- upgrading from v0 to v2 when already on ruby 3 HOT 5
- Migrating from 1.0.0.beta4 to 1.4.1 HOT 5
- Que fails to calculate args and kwargs on Ruby 3.2 with ActiveJob HOT 1
- Migration fails when adding Que to a new project (with rspec) HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from que.