Displaying 19 results from an estimated 19 matches for "before_fork".
2010 Nov 09
2
AMQP and Unicorn (mq gem)
...config.after_initialize do
Qusion.start(:user => ''guest'',:pass => ''mypass'')
end
However, when I publish messages to the queue,
it just isn''t posted. It silently fails.
I''ve then tried to put this on config/unicorn.rb:
before_fork do |server,worker|
Qusion.start(:user => ''guest'',:pass => ''mypass'')
MQ.new.queue(''jobs'').publish(''hey!'')
end
And the hey! message is posted.
However, it only works from here, the MQ.new.queue on the app code
fails s...
2013 Jan 20
6
preload_app = true causing - ActiveModel::MissingAttributeError: missing attribute: some_attr
Greetings,
I''m getting this - ActiveModel::MissingAttributeError: missing
attribute: some_attr - on a random basis under a unicorn server,
running rails 3.2 and ruby 1.9.3
As the case of the last poster in the following thread -
https://github.com/rails/rails/issues/1906 - I too am able to resolve
this issue by settingpreload_app to false.
However, this is not the behaviour I want to
2009 Oct 02
0
[PATCH] configurator: update some migration examples
We now give an example of how a before_fork hook can be used
to incrementally migrate off the old code base without hitting
a thundering herd (especially in the "preload_app false") case.
Also comment on the per-worker listen usage in the RDoc, not
just a hidden comment.
---
I just pushed this out earlier, this example was inspi...
2012 Nov 29
13
Fwd: Maintaining capacity during deploys
We''re using unicornctl restart with the default before/after hook
behavior, which is to reap old Unicorn workers via SIGQUIT after the
new one has finished booting.
Unfortunately, while the new workers are forking and begin processing
requests, we''re still seeing significant spikes in our haproxy request
queue. It seems as if after we restart, the unwarmed workers get
swamped by
2012 Dec 04
2
403 Forbidden from nginx when unicorn started in debug mode
...#39;'development''
pid
"/home/jet/RailsApps/spree/aceleathergoods/tmp/pids/unicorn.aceleathergoods.pid"
stderr_path "/var/www/aceleathergoods/shared/log/unicorn.stderr.log"
stdout_path "/var/www/aceleathergoods/shared/log/unicorn.stdout.log"
end
before_fork do |server, worker|
if defined?(ActiveRecord::Base)
ActiveRecord::Base.connection.disconnect!
end
old_pid = "#{shared_path}/pids/unicorn.aceleathergoods.pid.oldbin"
if File.exists?(old_pid) && server.pid != old_pid
begin
Process.kill("QUIT",...
2011 May 19
2
unicorn doesn't restart properly after cap deploy (not using Bundler)
...d "/var/www/lookbook/shared/pids/unicorn.pid"
stderr_path "/var/www/lookbook/shared/log/unicorn.stderr.log"
stdout_path "/var/www/lookbook/shared/log/unicorn.stdout.log"
preload_app true
if GC.respond_to?(:copy_on_write_friendly=)
? GC.copy_on_write_friendly = true
end
before_fork do |server, worker|
? STDERR.puts "BEFORE FORK:"
? STDERR.puts ENV.inspect
? defined?(ActiveRecord::Base) and
? ? ActiveRecord::Base.connection.disconnect!
? if old_pid != server.pid
? ? begin
? ? ? sig = (worker.nr?+ 1) >= server.worker_processes ? :QUIT : :TTOU
? ? ? Process.kill(sig...
2012 Dec 05
3
Fwd: Issue starting unicorn with non-ActiveRecord Rails app
Hi,
I''m trying to use unicorn in a test deployment of a Rails app that
uses Mongoid, so Activerecord isn''t included in the app. When I start
unicorn through Capistrano though, the stderr log fills up endlessly
with identical ActiveRecord-related errors:
I, [2012-12-05T04:19:25.375952 #5096] INFO -- : Refreshing Gem list
I, [2012-12-05T04:19:32.941249 #5096] INFO -- :
2010 Sep 09
4
Unicorn fails to restart gracefully on capistrano deploy
First off thanks very much for all the hard work on unicorn. Alas, we''ve encountered an issue where unicorn fails to spawn new workers that have loaded the incoming revision on a capistrano deploy. I''m not entirely sure the issue is due to unicorn as it appears that bundler was responsible for a similar issue in the past:
2010 May 06
5
Garbage collection outside of request cycle?
I''ve been analyzing our Unicorn-powered Rails app''s performance, and have found that garbage collection is a big factor in slow requests.
In the interest of avoiding those performance hits while handling requests, would it be possible to have a unicorn worker run garbage collection after handling a request and before waiting for the next one? Would this be a good idea?
Cheers,
2010 Oct 02
2
Unicorn doesn't reload the app after the HUP signal
...'
worker_processes (rails_env == ''production'' ? 3 : 1)
preload_app true
timeout 30
listen File.expand_path(File.join(__FILE__,
"../../tmp/sockets/unicorn.sock")), :backlog => 2048
if GC.respond_to?(:copy_on_write_friendly=)
GC.copy_on_write_friendly = true
end
before_fork do |server, worker|
old_pid = RAILS_ROOT + ''/tmp/pids/unicorn.pid.oldbin''
if File.exists?(old_pid) && server.pid != old_pid
begin
Process.kill("QUIT", File.read(old_pid).to_i)
rescue Errno::ENOENT, Errno::ESRCH
# someone else did our job f...
2012 Oct 24
2
Handling timeouts?
Hi Guys,
Thanks for Unicorn, it makes my world rock. You guy have done a wonderful job and also huge thanks to the predecessors too.
The default timeout on my Rails app is 30 seconds. The app works fine most of the time but there are some parts of the app which are slow and occasionally totter over the 30 sec response time and timeout. Is there a clean way for me to hook into timeouts and notify
2013 Dec 09
2
[PATCH] rework master-to-worker signaling to use a pipe
...rkers
end
@@ -498,6 +494,7 @@ class Unicorn::HttpServer
end
def after_fork_internal
+ SELF_PIPE.each { |io| io.close }.clear # this is master-only, now
@ready_pipe.close if @ready_pipe
Unicorn::Configurator::RACKUP.clear
@ready_pipe = @init_listeners = @before_exec = @before_fork = nil
@@ -517,6 +514,7 @@ class Unicorn::HttpServer
before_fork.call(self, worker)
if pid = fork
WORKERS[pid] = worker
+ worker.atfork_parent
else
after_fork_internal
worker_loop(worker)
@@ -531,9 +529,7 @@ class Unicorn::HttpServer
def main...
2013 May 25
1
Silent Failure when starting Unicorn on Heroku
...exited with status 1
State changed from starting to crashed
Procfile:
web: bundle exec unicorn start -p $PORT -c ./config/unicorn.rb
sidekiq: bundle exec sidekiq -c 10
unicorn.rb:
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3)
timeout 15
preload_app true
before_fork do |server, worker|
Signal.trap ''TERM'' do
puts ''Unicorn master intercepting TERM and sending myself QUIT
instead''
Process.kill ''QUIT'', Process.pid
end
defined?(ActiveRecord::Base) and
ActiveRecord::Bas...
2012 Jan 31
12
FreeBSD jail and unicorn
...version is
8.2-STABLE amd64.
That my config:
---
listen "/home/deploy/staging/unicorn.sock"
pid "/home/deploy/staging/unicorn.pid"
preload_app true
stderr_path "/home/deploy/staging/unicorn.stderr.log"
stdout_path "/home/deploy/staging/unicorn.stdout.log"
before_fork do |server, worker|
old_pid = "#{server.config[:pid]}.oldbin"
if old_pid != server.pid
begin
process_id = File.read(old_pid).to_i
puts "sending QUIT to #{process_id}"
Process.kill :QUIT, process_id
rescue Errno::ENOENT, Errno::ESRCH
end
end...
2011 Jun 16
7
[PATCH] replace fchmod()-based heartbeat with raindrops
...= tmp
next
end
@@ -472,7 +467,7 @@ class Unicorn::HttpServer
worker_nr = -1
until (worker_nr += 1) == @worker_processes
WORKERS.values.include?(worker_nr) and next
- worker = Worker.new(worker_nr, Unicorn::TmpIO.new)
+ worker = Worker.new(worker_nr)
before_fork.call(self, worker)
if pid = fork
WORKERS[pid] = worker
@@ -549,10 +544,8 @@ class Unicorn::HttpServer
proc_name "worker[#{worker.nr}]"
START_CTX.clear
init_self_pipe!
- WORKERS.values.each { |other| other.tmp.close rescue nil }
WORKERS.clear
LIS...
2009 Feb 11
16
Unicorn: UNIX+localhost/LAN-only Mongrel fork
...ng.
* should support all Rack applications (though only Sinatra has been tested)
* nginx-style binary re-execution without losing connections.
You can upgrade unicorn, your entire application, libraries
and even your Ruby interpreter as long as unicorn is
installed in the same path
* before_fork and after_fork hooks in case your application
has special needs when dealing with forked processes. These
can be used to setup signal handlers for logrotation, too.
* Ruby 1.9-compatible (at least the test cases all pass :>)
== Design
* Simplicity: Unicorn is a traditional UNIX prefo...
2012 Aug 31
1
after_fork - ActiveRecord::AdapterNotSpecified
...ses 3
preload_app true
GC.respond_to?(:copy_on_write_friendly=) and GC.copy_on_write_friendly = true
timeout 30
listen ''/tmp/sinatra.socket'', :backlog => 64
pid pidfile
stderr_path "#{@dir}log/unicorn.stderr.log"
stdout_path "#{@dir}log/unicorn.stdout.log"
before_fork do |server, worker|
? defined?(ActiveRecord::Base) and
??? ActiveRecord::Base.connection.disconnect!
? end
end
after_fork do |server, worker|
? defined?(ActiveRecord::Base) and
??? ActiveRecord::Base.establish_connection
end
when I start? unicorn
??? unicorn -c config/unicorn.rb -E production -D...
2012 Jul 19
5
Detecting unicorn / defining after_fork after master startup
Hey everyone,
Working on an engine for rails that needs specialized behavior with
forking and I had a couple questions.
1. What is the best way to determine whether the app is indeed running
inside a unicorn server?
Most of the attempts I can find to detect check to see if the main
modules for Unicorn are defined, but this really only checks to see
that Unicorn is present, not that you are
2013 May 20
2
Unicorn + RUnit Rails Not Killing Old Master
...> 100
working_directory ''/opt/myzippykid/deployment/current''
# What the timeout for killing busy workers is, in seconds
timeout 60
# Whether the app should be pre-loaded
preload_app false
# How many worker processes
worker_processes 1
# What to do before we fork a worker
before_fork do |server, worker|
sleep 1
end
https://gist.github.com/grahamc/7ca7e3942d19f60d339a:
#!/bin/bash
cd /opt/myzippykid/deployment/current
exec 2>&1
exec /usr/bin/chpst \
-u myzippykid:myzippykid \
/opt/myzippykid/bundle_wrapper.sh exec \
unicorn \
-E staging \
-c /etc/unicorn/m...