-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: #32
- Loading branch information
Showing
11 changed files
with
161 additions
and
85 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
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
Oops, something went wrong.