-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: #32 This remove a lot of busy work from the server, and allow to promote as soon as the condition is reached. The small downside is that we need a lock between processes to ensure two workers won't try to promote at the same time. This also means that the mold selector is removed. It wasn't that interesting anyway, because the Unicorn/Pitchfork architecute introduce a bias in request distribution, worker#0 will almost always get requests first so will almost always be the best candidate for promotion.
- Loading branch information
Showing
14 changed files
with
234 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM ruby:3.1 | ||
FROM ruby:3.2 | ||
RUN apt-get update -y && apt-get install -y ragel socat netcat smem apache2-utils | ||
WORKDIR /app | ||
CMD [ "bash" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
require 'tempfile' | ||
|
||
module Pitchfork | ||
class Flock | ||
Error = Class.new(StandardError) | ||
|
||
def initialize(name) | ||
@name = name | ||
@file = Tempfile.create([name, '.lock']) | ||
@file.write("#{Process.pid}\n") | ||
@file.flush | ||
@owned = false | ||
end | ||
|
||
def at_fork | ||
@owned = false | ||
@file.close | ||
@file = File.open(@file.path, "w") | ||
nil | ||
end | ||
|
||
def unlink | ||
File.unlink(@file.path) | ||
rescue Errno::ENOENT | ||
false | ||
end | ||
|
||
def try_lock | ||
raise Error, "Pitchfork::Flock(#{@name}) trying to lock an already owned lock" if @owned | ||
|
||
if @file.flock(File::LOCK_EX | File::LOCK_NB) | ||
@owned = true | ||
else | ||
false | ||
end | ||
end | ||
|
||
def unlock | ||
raise Error, "Pitchfork::Flock(#{@name}) trying to unlock a non-owned lock" unless @owned | ||
|
||
begin | ||
if @file.flock(File::LOCK_UN) | ||
@owned = false | ||
true | ||
else | ||
false | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.